Module: Locomotive::PagesHelper
- Defined in:
- app/helpers/locomotive/pages_helper.rb
Instance Method Summary collapse
- #add_children_to_options(page, children, list) ⇒ Object
- #display_page_layouts? ⇒ Boolean
- #display_slug?(page) ⇒ Boolean
- #options_for_page_layouts ⇒ Object
- #options_for_page_redirect_type ⇒ Object
- #parent_pages_options ⇒ Object
Instance Method Details
#add_children_to_options(page, children, list) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/locomotive/pages_helper.rb', line 14 def (page, children, list) return list if page.parent_ids.include?(@page.id) || page == @page offset = '- ' * (page.depth || 0) * 2 list << ["#{offset}#{page.title}", page.id] if children children.each { |(_page, _children)| (_page, _children, list) } end list end |
#display_page_layouts? ⇒ Boolean
32 33 34 35 |
# File 'app/helpers/locomotive/pages_helper.rb', line 32 def display_page_layouts? ((@page.persisted? && @page.allow_layout? && @page.use_layout?) || !@page.persisted?) && !current_site.pages.layouts.empty? end |
#display_slug?(page) ⇒ Boolean
28 29 30 |
# File 'app/helpers/locomotive/pages_helper.rb', line 28 def display_slug?(page) !page.index? && !page.not_found? && (!page.templatized? || page.templatized_from_parent?) end |
#options_for_page_layouts ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/helpers/locomotive/pages_helper.rb', line 37 def layouts = current_site.pages.layouts.map do |_layout| [_layout.title, _layout._id] end @page.index? ? layouts : [[t(:no_layout, scope: 'locomotive.pages.form'), 'parent']] + layouts end |
#options_for_page_redirect_type ⇒ Object
45 46 47 48 49 50 |
# File 'app/helpers/locomotive/pages_helper.rb', line 45 def [ [t('redirect_type.permanent', scope: 'locomotive.pages.form'), 301], [t('redirect_type.temporary', scope: 'locomotive.pages.form'), 302] ] end |
#parent_pages_options ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'app/helpers/locomotive/pages_helper.rb', line 4 def [].tap do |list| build_page_tree.each do |(page, children)| next if page.not_found? (page, children, list) end end end |