Module: Pwb::NavigationHelper
- Defined in:
- app/helpers/pwb/navigation_helper.rb
Instance Method Summary collapse
- #footer_link_for(page) ⇒ Object
- #render_footer_links ⇒ Object
- #render_omniauth_sign_in(provider) ⇒ Object
- #render_top_navigation_links ⇒ Object
- #top_nav_link_for(page) ⇒ Object
Instance Method Details
#footer_link_for(page) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/helpers/pwb/navigation_helper.rb', line 38 def (page) html = "" begin if page[:link_path].present? # link_path should be valid - below checks that target_path = pwb.send(page[:link_path], [page[:link_path_params]], {locale: locale}) # below works in most routes but had to change to above to support devise routes # target_path = send(page[:link_path], {locale: locale}) # else # target_path = self.pwb.send("show_page_path", page[:slug], {locale: locale}) elsif page[:link_url].present? target_path = page[:link_url] end rescue NoMethodError # target_path = '/' # rescue Exception => e end if target_path html = " \#{link_to page.link_title, target_path}.\n HTML\n end\n html\nend\n" |
#render_footer_links ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'app/helpers/pwb/navigation_helper.rb', line 29 def html = "" @ftr_links ||= Pwb::Link. @ftr_links.each do |page| html += ( page) || "" end html.html_safe end |
#render_omniauth_sign_in(provider) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/helpers/pwb/navigation_helper.rb', line 3 def render_omniauth_sign_in(provider) # will only render sign_in link for a provider for which config is present app_id_present = Rails.application.secrets["#{provider}_app_id"].present? app_secret_present = Rails.application.secrets["#{provider}_app_secret"].present? unless app_id_present && app_secret_present return end link_title = t('.sign_in_with_provider', provider: provider.to_s.titleize) link_path = pwb.send("localized_omniauth_path", provider) # link_path has to adapted to localised scope # https://github.com/plataformatec/devise/wiki/How-To:-OmniAuth-inside-localized-scope link_to link_title, link_path # pwb.localized_omniauth_path(provider) end |
#render_top_navigation_links ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'app/helpers/pwb/navigation_helper.rb', line 18 def html = "" @tn_links ||= Pwb::Link.ordered_visible_top_nav @tn_links.each do |page| unless page.slug == "top_nav_admin" html += (top_nav_link_for page) || "" end end html.html_safe end |
#top_nav_link_for(page) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'app/helpers/pwb/navigation_helper.rb', line 63 def top_nav_link_for(page) html = "" begin if page[:link_path].present? # link_path should be valid - below checks that target_path = pwb.send(page[:link_path], [page[:link_path_params]], {locale: locale}) # below works in most routes but had to change to above to support devise routes # target_path = send(page[:link_path], {locale: locale}) # else # target_path = self.pwb.send("show_page_path", page[:slug], {locale: locale}) elsif page[:link_url].present? target_path = page[:link_url] end rescue NoMethodError # target_path = '/' # rescue Exception => e end if target_path style_class = 'selected active' if current_page?( target_path ) if current_page?("/") && (page[:link_path] == "home_path") # so correct tab is higlighted when at root path style_class = 'selected active' end html = " <li class=\"\#{style_class}\">\n \#{link_to page.link_title, target_path, target: page[:href_target]}\n </li>\n HTML\n end\n html\nend\n" |