6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/perimeterx/utils/px_template_factory.rb', line 6
def self.get_template(px_ctx, px_config, px_template_object)
logger = px_config[:logger]
if (px_config[:challenge_enabled] && px_ctx.context[:block_action] == 'challenge')
logger.debug('PxTemplateFactory[get_template]: px challenge triggered')
return px_ctx.context[:block_action_data].html_safe
end
view = Mustache.new
if (px_ctx.context[:block_action] == 'rate_limit')
logger.debug('PxTemplateFactory[get_template]: rendering ratelimit template')
template_type = RATELIMIT_TEMPLATE
else
logger.debug('PxTemplateFactory[get_template]: rendering template')
template_type = CHALLENGE_TEMPLATE
end
Mustache.template_file = "#{File.dirname(__FILE__) }/templates/#{template_type}#{PxModule::TEMPLATE_EXT}"
view[PxModule::PROP_APP_ID] = px_config[:app_id]
view[PxModule::PROP_VID] = px_ctx.context[:vid]
view[PxModule::PROP_UUID] = px_ctx.context[:uuid]
view[PxModule::PROP_CUSTOM_LOGO] = px_config[:custom_logo]
view[PxModule::PROP_CSS_REF] = px_config[:css_ref]
view[PxModule::PROP_JS_REF] = px_config[:js_ref]
view[PxModule::PROP_HOST_URL] = px_template_object[:host_url]
view[PxModule::PROP_BLOCK_SCRIPT] = px_template_object[:block_script]
view[PxModule::PROP_ALT_BLOCK_SCRIPT] = px_template_object[:alt_block_script]
view[PxModule::PROP_JS_CLIENT_SRC] = px_template_object[:js_client_src]
view[PxModule::PROP_FIRST_PARTY_ENABLED] = px_ctx.context[:first_party_enabled]
return view.render.html_safe
end
|