Sha256: d7cc3e45c3436badde3a020fcd9c5dd42ff359700acbefc14d8535872513d617

Contents?: true

Size: 964 Bytes

Versions: 3

Compression:

Stored size: 964 Bytes

Contents

module RadminHelper
  def current_url?(options)
    url = case options
    when Hash
      url_for options
    else
      options.to_s
    end
    request.fullpath =~ Regexp.new('^' + Regexp.quote(clean(url)))
  end
  
  def clean(url)
    uri = URI.parse(url)
    uri.path.gsub(%r{/+}, '/').gsub(%r{/$}, '')
  end

  def admin
    Radmin::AdminUI.instance
  end

  def nav_tabs
    admin.nav
  end

  def current_tab?(tab)
    @current_tab ||= tab if tab.any? {|item| current_url?(item.relative_url) }
    @current_tab == tab
  end
   
  def nav_link_to(name, options)
    klass = current_url?(options) ? "current" : ""
    content_tag :li, :class => "#{klass}" do
      link_to name, options
    end
  end

  def title(page_title, show_title = true)    
    content_for(:title) { page_title.to_s }
    @show_title = show_title
  end
  
  def show_title?
    @show_title
  end

  def has_role?(role)
    current_admin.role_symbols.include?(role.to_sym)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
radmin-0.3.3 app/helpers/radmin_helper.rb
radmin-0.3.2 app/helpers/radmin_helper.rb
radmin-0.3.1 app/helpers/radmin_helper.rb