Sha256: d8dac4f6b6b49a43f539a1eb8383c011178c33866c35aa3eee66a201fea1905c

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 KB

Contents

module NavigationHelper

  def render_navigation(key)
    renderer = Houston.get_navigation_renderer(key)
    return unless renderer.permitted?(current_ability)

    render_nav_link renderer.name, renderer.path
  rescue KeyError
    Rails.logger.error "\e[31;1mThere is no navigation renderer named #{key.inspect}\e[0m"
    nil
  end

  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

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

    render_nav_link feature.name, feature.project_path(current_project)
  rescue KeyError
    Rails.logger.error "\e[31;1mThere is no project feature named #{feature.inspect}\e[0m"
    nil
  end

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

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
houston-core-0.8.4 app/helpers/navigation_helper.rb
houston-core-0.8.3 app/helpers/navigation_helper.rb
houston-core-0.8.2 app/helpers/navigation_helper.rb
houston-core-0.8.1 app/helpers/navigation_helper.rb
houston-core-0.8.0 app/helpers/navigation_helper.rb
houston-core-0.8.0.pre2 app/helpers/navigation_helper.rb