Module: Refinery::Admin::PagesHelper
- Defined in:
- pages/app/helpers/refinery/admin/pages_helper.rb
Instance Method Summary collapse
- #default_layout_template(current_page) ⇒ Object
- #default_view_template(current_page) ⇒ Object
-
#page_meta_information(page) ⇒ Object
In the admin area we use a slightly different title to inform the which pages are draft or hidden pages.
- #parent_id_nested_set_options(current_page) ⇒ Object
- #template_options(template_type, current_page) ⇒ Object
Instance Method Details
#default_layout_template(current_page) ⇒ Object
31 32 33 |
# File 'pages/app/helpers/refinery/admin/pages_helper.rb', line 31 def default_layout_template(current_page) "application" end |
#default_view_template(current_page) ⇒ Object
27 28 29 |
# File 'pages/app/helpers/refinery/admin/pages_helper.rb', line 27 def default_view_template(current_page) current_page.link_url == "/" ? "home" : "show" end |
#page_meta_information(page) ⇒ Object
In the admin area we use a slightly different title to inform the which pages are draft or hidden pages
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'pages/app/helpers/refinery/admin/pages_helper.rb', line 37 def (page) = ActiveSupport::SafeBuffer.new << content_tag(:span, :class => 'label') do ::I18n.t('hidden', :scope => 'refinery.admin.pages.page') end unless page. << content_tag(:span, :class => 'label') do ::I18n.t('skip_to_first_child', :scope => 'refinery.admin.pages.page') end if page.skip_to_first_child? << content_tag(:span, :class => 'label') do ::I18n.t('redirected', :scope => 'refinery.admin.pages.page') end if page.link_url? << content_tag(:span, :class => 'label notice') do ::I18n.t('draft', :scope => 'refinery.admin.pages.page') end if page.draft? end |
#parent_id_nested_set_options(current_page) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'pages/app/helpers/refinery/admin/pages_helper.rb', line 4 def (current_page) pages = [] (::Refinery::Page, current_page) { |page| pages << page} # page.title needs the :translations association, doing something like # nested_set_options(::Refinery::Page.includes(:translations), page) doesn't work, yet. # See https://github.com/collectiveidea/awesome_nested_set/pull/123 ActiveRecord::Associations::Preloader.new.preload(pages, :translations) pages.map { |page| ["#{'-' * page.level} #{page.title}", page.id]} end |
#template_options(template_type, current_page) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'pages/app/helpers/refinery/admin/pages_helper.rb', line 14 def (template_type, current_page) = { :selected => send("default_#{template_type}", current_page) } if (template = current_page.send(template_type).presence) .update :selected => template elsif current_page.parent_id? && !current_page.send(template_type).presence template = current_page.parent.send(template_type).presence .update :selected => template if template end end |