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

Instance Method Details

tiny [S] link directly to SFX, in footer. For debugging. Only if sfx.sfx_base_url is configured.


43
44
45
46
47
48
49
50
51
# File 'app/helpers/umlaut/footer_helper.rb', line 43

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

If you have a config.test_resolve_base configured, will output a [T] link, usually for footer, for staff debugging.


56
57
58
59
60
# File 'app/helpers/umlaut/footer_helper.rb', line 56

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

62
63
64
65
66
67
68
69
# File 'app/helpers/umlaut/footer_helper.rb', line 62

def link_to_toggle_debug_info(options = {})
  options = {:text => "[D]", :title => "Toggle on-screen debug info"}.merge(options)
  
  text = options.delete(:text)
  options[:onclick] ||= " jQuery('.debug_info').toggle();"  

  return link_to(text, "#", options)  
end

#render_service_creditsObject

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
# File 'app/helpers/umlaut/footer_helper.rb', line 10

def render_service_credits
  if @collection
    content = "".html_safe
          
    content << t('umlaut.misc.powered_by_umlaut').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 << t("umlaut.misc.credits_html", :credits => safe_join(credit_segments, ", "))
    end
    
    return content
  end
end