Module: Pageflow::PagesHelper
- Included in:
- SocialShareHelper
- Defined in:
- app/helpers/pageflow/pages_helper.rb
Overview
rubocop:todo Style/Documentation
Instance Method Summary collapse
-
#page_css_class(page) ⇒ Object
rubocop:todo Metrics/PerceivedComplexity rubocop:todo Metrics/CyclomaticComplexity.
-
#page_default_content(page) ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/PerceivedComplexity.
- #page_has_content(page) ⇒ Object private
- #page_header(page) ⇒ Object
- #page_media_breakpoints ⇒ Object
- #page_navigation_css_class(page) ⇒ Object
- #page_print_image(page) ⇒ Object
- #page_text(page) ⇒ Object
- #page_thumbnail_file(page) ⇒ Object
- #page_thumbnail_image_class(page, hero) ⇒ Object
- #page_thumbnail_url(page) ⇒ Object
- #render_page_template(page, locals = {}) ⇒ Object
- #shadow_div(options = {}) ⇒ Object
Instance Method Details
#page_css_class(page) ⇒ Object
rubocop:todo Metrics/PerceivedComplexity rubocop:todo Metrics/CyclomaticComplexity
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/helpers/pageflow/pages_helper.rb', line 13 def page_css_class(page) # rubocop:todo Metrics/AbcSize classes = ['page'] classes << 'invert' if page.configuration['invert'] classes << 'hide_title' if page.configuration['hide_title'] if page.configuration['text_position'].present? classes << "text_position_#{page.configuration['text_position']}" end if page.configuration['scroll_indicator_mode'].present? classes << "scroll_indicator_mode_#{page.configuration['scroll_indicator_mode']}" end if page.configuration['scroll_indicator_orientation'].present? classes << "scroll_indicator_orientation_#{page.configuration['scroll_indicator_orientation']}" end if page.configuration['delayed_text_fade_in'].present? classes << "delayed_text_fade_in_#{page.configuration['delayed_text_fade_in']}" end classes << 'chapter_beginning' if page.position == 0 classes << 'first_page' if page.is_first classes << 'no_text_content' unless page_has_content(page) classes << 'hide_logo' if page.configuration['hide_logo'] classes.join(' ') end |
#page_default_content(page) ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/PerceivedComplexity
39 40 41 42 43 44 45 |
# File 'app/helpers/pageflow/pages_helper.rb', line 39 def page_default_content(page) safe_join([ page_header(page), page_print_image(page), page_text(page) ]) end |
#page_has_content(page) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
71 72 73 74 75 76 77 78 79 |
# File 'app/helpers/pageflow/pages_helper.rb', line 71 def page_has_content(page) has_title = ['title', 'subtitle', 'tagline'].any? do |attribute| page.configuration[attribute].present? end has_text = (page.configuration['text']).present? (has_title && !page.configuration['hide_title']) || has_text end |
#page_header(page) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/helpers/pageflow/pages_helper.rb', line 47 def page_header(page) content_tag(:h3, class: 'page_header') do safe_join([ content_tag(:span, page.configuration['tagline'], class: 'page_header-tagline'), content_tag(:span, page.configuration['title'], class: 'page_header-title'), content_tag(:span, page.configuration['subtitle'], class: 'page_header-subtitle') ]) end end |
#page_media_breakpoints ⇒ Object
97 98 99 100 101 102 |
# File 'app/helpers/pageflow/pages_helper.rb', line 97 def page_media_breakpoints { desktop: :default, mobile: 'max-width: 900px' } end |
#page_navigation_css_class(page) ⇒ Object
81 82 83 84 85 86 87 88 |
# File 'app/helpers/pageflow/pages_helper.rb', line 81 def (page) classes = [page.template] classes << 'chapter_beginning' if page.position == 0 classes << 'emphasized' if page.configuration['emphasize_in_navigation'] classes << "chapter_#{page.chapter.position}" classes << (page.chapter.position.even? ? 'chapter_even' : 'chapter_odd') classes.join(' ') end |
#page_print_image(page) ⇒ Object
60 61 62 |
# File 'app/helpers/pageflow/pages_helper.rb', line 60 def page_print_image(page) background_image_tag(page.configuration['background_image_id'], 'class' => 'print_image') end |
#page_text(page) ⇒ Object
64 65 66 67 68 |
# File 'app/helpers/pageflow/pages_helper.rb', line 64 def page_text(page) content_tag(:div, class: 'page_text') do content_tag(:div, raw(page.configuration['text']), class: 'paragraph') end end |
#page_thumbnail_file(page) ⇒ Object
113 114 115 116 |
# File 'app/helpers/pageflow/pages_helper.rb', line 113 def page_thumbnail_file(page) ThumbnailFileResolver.new(@entry, page.page_type.thumbnail_candidates, page.configuration) .find_thumbnail end |
#page_thumbnail_image_class(page, hero) ⇒ Object
104 105 106 107 |
# File 'app/helpers/pageflow/pages_helper.rb', line 104 def page_thumbnail_image_class(page, hero) file_thumbnail_css_class(page_thumbnail_file(page), hero ? :link_thumbnail_large : :link_thumbnail) end |
#page_thumbnail_url(page) ⇒ Object
109 110 111 |
# File 'app/helpers/pageflow/pages_helper.rb', line 109 def page_thumbnail_url(page, *) page_thumbnail_file(page).thumbnail_url(*) end |
#render_page_template(page, locals = {}) ⇒ Object
3 4 5 6 7 8 9 |
# File 'app/helpers/pageflow/pages_helper.rb', line 3 def render_page_template(page, locals = {}) page_type = Pageflow.config.page_types.find_by_name!(page.template) render(template: page_type.template_path, locals: locals.merge(page:, configuration: page.configuration)) end |
#shadow_div(options = {}) ⇒ Object
90 91 92 93 94 95 |
# File 'app/helpers/pageflow/pages_helper.rb', line 90 def shadow_div( = {}) style = [:opacity] ? "opacity: #{[:opacity] / 100.0};" : nil content_tag(:div, '', class: 'shadow_wrapper') do content_tag(:div, '', class: 'shadow', style:) end end |