Module: Locomotive::Shared::PagesHelper
- Defined in:
- app/helpers/locomotive/shared/pages_helper.rb
Defined Under Namespace
Classes: Node
Instance Method Summary collapse
- #build_page_tree ⇒ Object
- #localized_preview_page_paths(page, mounted_on: false) ⇒ Object
- #nice_preview_page_path(page) ⇒ Object
- #preview_page_path(page, locale: nil, mounted_on: false, prefix_default_locale: nil) ⇒ Object
- #render_pages ⇒ Object
- #response_type_name(page) ⇒ Object
Instance Method Details
#build_page_tree ⇒ Object
52 53 54 |
# File 'app/helpers/locomotive/shared/pages_helper.rb', line 52 def build_page_tree @page_tree ||= Locomotive::PageTreeService.new(current_site).build_tree end |
#localized_preview_page_paths(page, mounted_on: false) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'app/helpers/locomotive/shared/pages_helper.rb', line 26 def localized_preview_page_paths(page, mounted_on: false) current_site.locales.inject({}) do |memo, locale| memo[locale] = preview_page_path(page, locale: locale, mounted_on: mounted_on, prefix_default_locale: true ) memo end end |
#nice_preview_page_path(page) ⇒ Object
5 6 7 8 9 10 11 |
# File 'app/helpers/locomotive/shared/pages_helper.rb', line 5 def nice_preview_page_path(page) path = preview_page_path(page) path = '/index' if path == '/' || path == "/#{current_site.default_locale}" path += response_type_name(page) truncate(path, length: 50) end |
#preview_page_path(page, locale: nil, mounted_on: false, prefix_default_locale: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/locomotive/shared/pages_helper.rb', line 13 def preview_page_path(page, locale: nil, mounted_on: false, prefix_default_locale: nil) locale = locale || current_content_locale.to_s _page = decorated_steam_page(page, locale) if page.content_entry _page.content_entry = decorated_steam_content_entry(page.content_entry) end steam_url_builder.mounted_on = mounted_on ? preview_path(current_site) : nil steam_url_builder.url_for(_page, locale, prefix_default_locale) end |
#render_pages ⇒ Object
45 46 47 48 49 50 |
# File 'app/helpers/locomotive/shared/pages_helper.rb', line 45 def render_pages tree = build_page_tree nodes = tree.map { |page, children| Node.new(page, children, controller) } render 'locomotive/shared/sidebar/pages', nodes: nodes, root: tree.first.first end |
#response_type_name(page) ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/helpers/locomotive/shared/pages_helper.rb', line 37 def response_type_name(page) if page.default_response_type? '' else '.' + (MIME::Types[page.response_type.to_s].first.try(:preferred_extension) || 'html') end end |