Module: Maglev::PagePreviewHelper
- Defined in:
- app/helpers/maglev/page_preview_helper.rb
Instance Method Summary collapse
- #maglev_alt_link(locale, links: nil) ⇒ Object
- #maglev_site_link ⇒ Object
- #render_maglev_alternate_links(links: nil, x_default_locale: nil) ⇒ Object
-
#render_maglev_section(type, site: nil, theme: nil, page: nil, page_sections: nil) ⇒ Object
rubocop:enable Rails/OutputSafety.
-
#render_maglev_sections(site: nil, theme: nil, page: nil, page_sections: nil) ⇒ Object
rubocop:disable Rails/OutputSafety.
- #rendering_maglev_page? ⇒ Boolean
Instance Method Details
#maglev_alt_link(locale, links: nil) ⇒ Object
45 46 47 48 49 50 51 |
# File 'app/helpers/maglev/page_preview_helper.rb', line 45 def maglev_alt_link(locale, links: nil) links ||= maglev_page_fullpaths link = links[locale] return nil if link.nil? "#{request.base_url}#{link}" end |
#maglev_site_link ⇒ Object
53 54 55 |
# File 'app/helpers/maglev/page_preview_helper.rb', line 53 def maglev_site_link maglev_site_root_fullpath end |
#render_maglev_alternate_links(links: nil, x_default_locale: nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/helpers/maglev/page_preview_helper.rb', line 31 def render_maglev_alternate_links(links: nil, x_default_locale: nil) links ||= maglev_page_fullpaths x_default_locale ||= maglev_site.default_locale_prefix.to_sym return '' if links.blank? || links.size < 2 safe_join( [tag.link(rel: 'alternate', hreflang: 'x-default', href: maglev_alt_link(x_default_locale))] + links.map do |(locale, _link)| tag.link(rel: 'alternate', hreflang: locale, href: maglev_alt_link(locale)) end ) end |
#render_maglev_section(type, site: nil, theme: nil, page: nil, page_sections: nil) ⇒ Object
rubocop:enable Rails/OutputSafety
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/maglev/page_preview_helper.rb', line 18 def render_maglev_section(type, site: nil, theme: nil, page: nil, page_sections: nil) sections = (page_sections || maglev_page_sections).find_all do |section| (section['type'] || section[:type]).start_with?(type.to_s) end render_maglev_sections( site: site, theme: theme, page: page, page_sections: sections ) end |
#render_maglev_sections(site: nil, theme: nil, page: nil, page_sections: nil) ⇒ Object
rubocop:disable Rails/OutputSafety
6 7 8 9 10 11 12 13 14 15 |
# File 'app/helpers/maglev/page_preview_helper.rb', line 6 def render_maglev_sections(site: nil, theme: nil, page: nil, page_sections: nil) PageComponent.new( site: site || maglev_site, theme: theme || maglev_theme, page: page || maglev_page, page_sections: page_sections || maglev_page_sections, templates_root_path: maglev_sections_path, config: maglev_config ).tap { |component| component.view_context = self }.render.html_safe end |
#rendering_maglev_page? ⇒ Boolean
57 58 59 |
# File 'app/helpers/maglev/page_preview_helper.rb', line 57 def rendering_maglev_page? controller.class.module_parent.to_s == 'Maglev' end |