Module: Umlaut::FooterHelper
- Included in:
- Helper
- Defined in:
- app/helpers/umlaut/footer_helper.rb
Overview
Some rails view helpers useful for debugging links, and rendering credits in footer.
Instance Method Summary collapse
-
#link_to_direct_sfx ⇒ Object
tiny [S] link directly to SFX, in footer.
-
#link_to_test_resolve ⇒ Object
If you have a config.test_resolve_base configured, will output a [T] link, usually for footer, for staff debugging.
- #link_to_toggle_debug_info(options = {}) ⇒ Object
-
#render_service_credits ⇒ Object
Renders list of external services used by currently configured Umlaut, with URLs.
Instance Method Details
#link_to_direct_sfx ⇒ Object
tiny [S] link directly to SFX, in footer. For debugging. Only if sfx.sfx_base_url is configured.
45 46 47 48 49 50 51 52 53 |
# File 'app/helpers/umlaut/footer_helper.rb', line 45 def link_to_direct_sfx if (base = umlaut_config.lookup!("sfx.sfx_base_url")) && @user_request url = base.chomp("?") + "?" url += @user_request.to_context_object.kev url += "&sfx.ignore_date_threshold=1" if respond_to?(:title_level_request) && title_level_request? link_to "[S]", url, :title => "View in SFX" end end |
#link_to_test_resolve ⇒ Object
If you have a config.test_resolve_base configured, will output a [T] link, usually for footer, for staff debugging.
58 59 60 61 62 |
# File 'app/helpers/umlaut/footer_helper.rb', line 58 def link_to_test_resolve if (test_base = umlaut_config.lookup!("test_resolve_base")) && @user_request link_to "[T]", test_base.chomp("?") + "?" + @user_request.to_context_object.kev, :title => "View in Test #{umlaut_config.app_name}" end end |
#link_to_toggle_debug_info(options = {}) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'app/helpers/umlaut/footer_helper.rb', line 64 def link_to_toggle_debug_info( = {}) = {:text => "[D]", :title => "Toggle on-screen debug info"}.merge() text = .delete(:text) javascript = " jQuery('.debug_info').toggle();" return link_to_function(text, javascript, ) end |
#render_service_credits ⇒ Object
Renders list of external services used by currently configured Umlaut, with URLs. In some cases ToS of third party services may require this. Gets list from “credits” config in Service plugins. Requires @collection ivar in controller holding an umlaut Collection object, as there will be in ResolveController.
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 39 40 41 |
# File 'app/helpers/umlaut/footer_helper.rb', line 10 def render_service_credits if @collection content = "".html_safe content << "Powered by ".html_safe + link_to("Umlaut", "https://github.com/team-umlaut/umlaut") + ". ".html_safe credit_segments = [] services = @collection.instantiate_services! # put em all in one hash to eliminate exact-name dups credits = {} services.each {|s| credits.merge! s.credits } credits.keys.sort.each do |name| if credits[name].blank? credit_segments << html_escape(name) else credit_segments << link_to(name, credits[name]) end end if credit_segments.length > 0 content << "Using services from ".html_safe content << credit_segments.join(", ").html_safe content << " and others.".html_safe end return content end end |