def get_profile_script(env)
path = if ENV["PASSENGER_BASE_URI"] then
"#{ENV['PASSENGER_BASE_URI']}#{@config.base_url_path}"
elsif env["action_controller.instance"]
env["action_controller.instance"].url_for("#{@config.base_url_path}")
else
"#{env['RACK_MINI_PROFILER_ORIGINAL_SCRIPT_NAME']}#{@config.base_url_path}"
end
settings = {
:path => path,
:version => MiniProfiler::ASSET_VERSION,
:position => @config.position,
:showTrivial => false,
:showChildren => false,
:maxTracesToShow => 10,
:showControls => false,
:authorized => true,
:toggleShortcut => @config.toggle_shortcut,
:startHidden => @config.start_hidden,
:collapseResults => @config.collapse_results
}
if current && current.page_struct
settings[:ids] = ids_comma_separated(env)
settings[:currentId] = current.page_struct[:id]
else
settings[:ids] = []
settings[:currentId] = ""
end
script = IO.read(::File.expand_path('../html/profile_handler.js', ::File.dirname(__FILE__)))
settings.each do |k,v|
regex = Regexp.new("\\{#{k.to_s}\\}")
script.gsub!(regex, v.to_s)
end
current.inject_js = false if current
script
end