Module: RadminHelper
- Defined in:
- app/helpers/radmin_helper.rb
Instance Method Summary collapse
- #admin ⇒ Object
- #clean(url) ⇒ Object
- #current_tab?(tab) ⇒ Boolean
- #current_url?(options) ⇒ Boolean
- #has_role?(role) ⇒ Boolean
- #nav_link_to(name, options) ⇒ Object
- #nav_tabs ⇒ Object
- #show_title? ⇒ Boolean
- #title(page_title, show_title = true) ⇒ Object
Instance Method Details
#admin ⇒ Object
17 18 19 |
# File 'app/helpers/radmin_helper.rb', line 17 def admin Radmin::AdminUI.instance end |
#clean(url) ⇒ Object
12 13 14 15 |
# File 'app/helpers/radmin_helper.rb', line 12 def clean(url) uri = URI.parse(url) uri.path.gsub(%r{/+}, '/').gsub(%r{/$}, '') end |
#current_tab?(tab) ⇒ Boolean
25 26 27 28 |
# File 'app/helpers/radmin_helper.rb', line 25 def current_tab?(tab) @current_tab ||= tab if tab.any? {|item| current_url?(item.relative_url) } @current_tab == tab end |
#current_url?(options) ⇒ Boolean
2 3 4 5 6 7 8 9 10 |
# File 'app/helpers/radmin_helper.rb', line 2 def current_url?() url = case when Hash url_for else .to_s end request.fullpath =~ Regexp.new('^' + Regexp.quote(clean(url))) end |
#has_role?(role) ⇒ Boolean
46 47 48 |
# File 'app/helpers/radmin_helper.rb', line 46 def has_role?(role) current_admin.role_symbols.include?(role.to_sym) end |
#nav_link_to(name, options) ⇒ Object
30 31 32 33 34 35 |
# File 'app/helpers/radmin_helper.rb', line 30 def nav_link_to(name, ) klass = current_url?() ? "current" : "" content_tag :li, :class => "#{klass}" do link_to name, end end |
#nav_tabs ⇒ Object
21 22 23 |
# File 'app/helpers/radmin_helper.rb', line 21 def nav_tabs admin.nav end |
#show_title? ⇒ Boolean
42 43 44 |
# File 'app/helpers/radmin_helper.rb', line 42 def show_title? @show_title end |
#title(page_title, show_title = true) ⇒ Object
37 38 39 40 |
# File 'app/helpers/radmin_helper.rb', line 37 def title(page_title, show_title = true) content_for(:title) { page_title.to_s } @show_title = show_title end |