Module: Pageflow::EntriesHelper
- Included in:
- SocialShareHelper
- Defined in:
- app/helpers/pageflow/entries_helper.rb
Overview
rubocop:todo Style/Documentation
Defined Under Namespace
Modules: PrettyUrl
Instance Method Summary collapse
- #entry_css_class(entry) ⇒ Object
- #entry_file_rights(entry) ⇒ Object
-
#entry_global_links(entry) ⇒ Object
rubocop:todo Metrics/PerceivedComplexity rubocop:todo Metrics/CyclomaticComplexity.
- #entry_header_css_class(entry) ⇒ Object
- #entry_mobile_navigation_pages(entry) ⇒ Object
- #entry_privacy_link_url(entry) ⇒ Object
- #entry_stylesheet_link_tag(entry) ⇒ Object
- #entry_summary(entry) ⇒ Object
-
#entry_theme_stylesheet_link_tag(entry) ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/PerceivedComplexity.
- #pretty_entry_title(entry) ⇒ Object
- #pretty_entry_url(entry, options = {}) ⇒ Object
Instance Method Details
#entry_css_class(entry) ⇒ Object
175 176 177 178 179 180 |
# File 'app/helpers/pageflow/entries_helper.rb', line 175 def entry_css_class(entry) [ (entry), entry.emphasize_chapter_beginning ? 'emphasize_chapter_beginning' : nil ].compact.join(' ') end |
#entry_file_rights(entry) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'app/helpers/pageflow/entries_helper.rb', line 81 def entry_file_rights(entry) rights = Pageflow.config.file_types.map { |file_type| entry.find_files(file_type.model).map do |file| file.rights.presence || entry.account.default_file_rights.presence end }.flatten.compact.sort.uniq if rights.any? content_tag :p, class: 'rights' do "#{I18n.t('pageflow.helpers.entries.image_rights')}: #{rights * ', '}" end else '' end end |
#entry_global_links(entry) ⇒ Object
rubocop:todo Metrics/PerceivedComplexity rubocop:todo Metrics/CyclomaticComplexity
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'app/helpers/pageflow/entries_helper.rb', line 99 def entry_global_links(entry) # rubocop:todo Metrics/AbcSize links = [] if entry.site.imprint_link_label.present? && entry.site.imprint_link_url.present? links << link_to( raw(entry.site.imprint_link_label), entry.site.imprint_link_url, target: entry.site.imprint_link_url.start_with?('javascript:') ? nil : '_blank', tabindex: 2, class: 'legal' ) end if entry.site.copyright_link_label.present? && entry.site.copyright_link_url.present? links << link_to( raw(entry.site.copyright_link_label), entry.site.copyright_link_url, target: entry.site.copyright_link_url.start_with?('javascript:') ? nil : '_blank', tabindex: 2, class: 'copy' ) end if entry.site.privacy_link_url.present? links << link_to( I18n.t('pageflow.public.privacy_notice'), entry_privacy_link_url(entry), target: entry.site.privacy_link_url.start_with?('javascript:') ? nil : '_blank', tabindex: 2, class: 'privacy' ) end if links.any? content_tag(:span, I18n.t('pageflow.helpers.entries.global_links'), class: 'hidden') + safe_join(links, ''.html_safe) else '' end end |
#entry_header_css_class(entry) ⇒ Object
182 183 184 185 186 |
# File 'app/helpers/pageflow/entries_helper.rb', line 182 def entry_header_css_class(entry) css_class = 'header' css_class += ' invert' if entry.pages.any? && entry.pages.first.configuration['invert'] css_class end |
#entry_mobile_navigation_pages(entry) ⇒ Object
167 168 169 170 171 172 173 |
# File 'app/helpers/pageflow/entries_helper.rb', line 167 def (entry) entry.pages..tap do |pages| if entry.pages.any? && !entry.pages.first. [entry.pages.first, pages].flatten end end end |
#entry_privacy_link_url(entry) ⇒ Object
74 75 76 77 78 79 |
# File 'app/helpers/pageflow/entries_helper.rb', line 74 def entry_privacy_link_url(entry) return unless entry.site.privacy_link_url.present? return entry.site.privacy_link_url if entry.site.privacy_link_url.start_with?('javascript:') "#{entry.site.privacy_link_url}?lang=#{entry.locale}" end |
#entry_stylesheet_link_tag(entry) ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'app/helpers/pageflow/entries_helper.rb', line 148 def entry_stylesheet_link_tag(entry) url = pageflow.polymorphic_path(entry.stylesheet_model, action: :stylesheet, v: entry.stylesheet_cache_key, p: Pageflow::VERSION, format: 'css') # We cannot use stylesheet_link_tag here since that always uses # the asset host. Entry stylesheet requests are subject to # `Configuration#public_entry_request_scope` and # `Configuration#public_entry_redirect` which might depend on # the hostname. tag(:link, rel: 'stylesheet', href: url, media: 'all', data: {name: 'entry'}) end |
#entry_summary(entry) ⇒ Object
188 189 190 191 192 |
# File 'app/helpers/pageflow/entries_helper.rb', line 188 def entry_summary(entry) return '' if entry.summary.blank? (entry.summary.gsub(%r{<br ?/?>}, ' ').squish) end |
#entry_theme_stylesheet_link_tag(entry) ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/PerceivedComplexity
142 143 144 145 146 |
# File 'app/helpers/pageflow/entries_helper.rb', line 142 def entry_theme_stylesheet_link_tag(entry) stylesheet_link_tag(entry.theme.stylesheet_path, media: 'all', data: {name: 'theme'}) end |
#pretty_entry_title(entry) ⇒ Object
3 4 5 6 7 8 |
# File 'app/helpers/pageflow/entries_helper.rb', line 3 def pretty_entry_title(entry) return entry.title if entry.site.title == ' ' [entry.title, entry.site.display_title].compact.join(' - ') end |