Sha256: f0413e9d86cd55a86c70956e9db8f08e620768f87912f71741b00284978507ad

Contents?: true

Size: 881 Bytes

Versions: 1

Compression:

Stored size: 881 Bytes

Contents

module AdminHelper
  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
radmin-0.2.0 app/helpers/admin_helper.rb