Module: NavigationHelper

Defined in:
app/helpers/navigation_helper.rb

Instance Method Summary collapse

Instance Method Details

#current_featureObject



11
12
13
14
15
16
# File 'app/helpers/navigation_helper.rb', line 11

def current_feature
  return nil unless current_project && current_project.persisted?
  @current_feature ||= current_project.features.find do |feature|
    current_page? feature_path(current_project, feature)
  end
end

#render_nav_for_feature(feature) ⇒ Object



18
19
20
21
22
23
# File 'app/helpers/navigation_helper.rb', line 18

def render_nav_for_feature(feature)
  feature = Houston.config.get_project_feature feature
  return unless feature.permitted?(current_ability, current_project)

  render_nav_link feature.name, feature.project_path(current_project), icon: feature.icon
end


42
43
44
45
46
47
48
# File 'app/helpers/navigation_helper.rb', line 42

def render_nav_link(name, href, icon: "fa-circle-thin")
  if current_page? href
    "<li class=\"current\">#{_render_nav(name, icon: icon)}</li>".html_safe
  else
    "<li><a href=\"#{href}\" title=\"#{h name}\">#{_render_nav(name, icon: icon)}</a></li>".html_safe
  end
end

#render_nav_menu(name, items: [], icon: "fa-circle-thin") ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/helpers/navigation_helper.rb', line 25

def render_nav_menu(name, items: [], icon: "fa-circle-thin")
  items.flatten!

  return "" if items.empty?

  <<-HTML.html_safe
  <li class="dropdown">
    <a href="#" title="#{h name}" class="dropdown-toggle" data-toggle="dropdown">
      #{_render_nav(name, icon: icon)} <b class="caret"></b>
    </a>
    <ul class="dropdown-menu releases-menu">
      #{items.map(&:to_html).join("")}
    </ul>
  </li>
  HTML
end

#render_navigation(key) ⇒ Object



3
4
5
6
7
8
9
# File 'app/helpers/navigation_helper.rb', line 3

def render_navigation(key)
  renderer = Houston.config.get_navigation_renderer(key)
  instance_eval &renderer
rescue KeyError
  Rails.logger.error "\e[31;1mThere is no navigation renderer named #{key.inspect}\e[0m"
  nil
end