Module: Voluntary::LayoutHelper

Defined in:
app/helpers/voluntary/layout_helper.rb

Instance Method Summary collapse

Instance Method Details



3
4
5
6
7
8
9
10
11
12
# File 'app/helpers/voluntary/layout_helper.rb', line 3

def breadcrumbs
  result = render_navigation context: application_navigation, renderer: :breadcrumbs_without_method_links, join_with: ' > '
  result = result && result.scan('<a').length > 1 ? result : ''
  
  if respond_to?(:resource) && resource.respond_to?(:ancestors)
    breadcrumbs_with_ancestors(result)
  else
    result
  end
end


14
15
16
17
18
19
20
# File 'app/helpers/voluntary/layout_helper.rb', line 14

def breadcrumbs_with_ancestors(links)
  links = links.split(' &gt; ')
  current_resource_link = links.pop
  links += resource.ancestors.map {|ancestor| link_to ancestor.name, ancestor }
  links << current_resource_link
  raw links.join(' &gt; ')    
end


29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/helpers/voluntary/layout_helper.rb', line 29

def footer_navigation
  links = []
  
  ['privacy-policy', 'terms-of-use', 'about-us'].each do |page_name|
    text = t("pages.#{page_name.gsub('-', '_')}.title")
    path = "#{controller_name}/#{params[:id]}"
    active = path == "#{controller_name}/#{page_name}"
    links << (active ? text : link_to(text, page_path(page_name)))
  end
  
  raw links.join(' | ')
end

#sidenav(links_count = 2) ⇒ Object



22
23
24
25
26
27
# File 'app/helpers/voluntary/layout_helper.rb', line 22

def sidenav(links_count = 2)
  links_count ||= 2
  result = render_navigation context: application_navigation, renderer: :twitter_sidenav, level: @twitter_sidenav_level
  
  result && result.scan('<a').length >= links_count ? result : ''
end