Module: Pageflow::EntriesHelper

Included in:
SocialShareHelper
Defined in:
app/helpers/pageflow/entries_helper.rb

Instance Method Summary collapse

Instance Method Details

#entry_css_class(entry) ⇒ Object



100
101
102
103
104
105
# File 'app/helpers/pageflow/entries_helper.rb', line 100

def entry_css_class(entry)
  [
    present_widgets_css_class(entry),
    entry.emphasize_chapter_beginning ? 'emphasize_chapter_beginning' : nil
  ].compact.join(' ')
end

#entry_file_rights(entry) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/helpers/pageflow/entries_helper.rb', line 17

def entry_file_rights(entry)
  rights = Pageflow.config.file_types.map do |file_type|
    entry.find_files(file_type.model).map do |file|
      file.rights.presence || entry..default_file_rights.presence
    end
  end.flatten.compact.sort.uniq

  if rights.any?
     :p, class: 'rights' do
      I18n.t('pageflow.helpers.entries.image_rights') + ": " + rights * ', '
    end
  else
    ''
  end
end

#entry_global_links(entry) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/helpers/pageflow/entries_helper.rb', line 33

def entry_global_links(entry)
  links = []

  if entry.theming.imprint_link_label.present? && entry.theming.imprint_link_url.present?
    links << link_to(raw(entry.theming.imprint_link_label),
                     entry.theming.imprint_link_url,
                     target: '_blank',
                     tabindex: 2,
                     class: 'legal')
  end

  if entry.theming.copyright_link_label.present? && entry.theming.copyright_link_url.present?
    links << link_to(raw(entry.theming.copyright_link_label),
                     entry.theming.copyright_link_url,
                     target: '_blank',
                     tabindex: 2,
                     class: 'copy')
  end

  if entry.theming.privacy_link_url.present?
    links << link_to(I18n.t('pageflow.public.privacy_notice'),
                     entry_privacy_link_url(entry),
                     target: '_blank',
                     tabindex: 2,
                     class: 'privacy')
  end

  if links.any?
    (:span, I18n.t('pageflow.helpers.entries.global_links'), class: 'hidden') + safe_join(links, ''.html_safe)
  else
    ''
  end
end

#entry_header_css_class(entry) ⇒ Object



107
108
109
110
111
112
113
# File 'app/helpers/pageflow/entries_helper.rb', line 107

def entry_header_css_class(entry)
  css_class = 'header'
  if entry.pages.any? && entry.pages.first.configuration['invert']
    css_class += ' invert'
  end
  css_class
end

#entry_mobile_navigation_pages(entry) ⇒ Object



92
93
94
95
96
97
98
# File 'app/helpers/pageflow/entries_helper.rb', line 92

def entry_mobile_navigation_pages(entry)
  entry.pages.displayed_in_navigation.tap do |pages|
    if entry.pages.any? && !entry.pages.first.display_in_navigation
      [entry.pages.first, pages].flatten
    end
  end
end

#entry_privacy_link_url(entry) ⇒ Object



12
13
14
15
# File 'app/helpers/pageflow/entries_helper.rb', line 12

def entry_privacy_link_url(entry)
  return unless entry.theming.privacy_link_url.present?
  "#{entry.theming.privacy_link_url}?lang=#{entry.locale}"
end

#entry_stylesheet_link_tag(entry) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'app/helpers/pageflow/entries_helper.rb', line 73

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



115
116
117
118
# File 'app/helpers/pageflow/entries_helper.rb', line 115

def entry_summary(entry)
  return '' if entry.summary.blank?
  strip_tags(entry.summary.gsub(/<br ?\/?>/, ' ').squish)
end

#entry_theme_stylesheet_link_tag(entry) ⇒ Object



67
68
69
70
71
# File 'app/helpers/pageflow/entries_helper.rb', line 67

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
# File 'app/helpers/pageflow/entries_helper.rb', line 3

def pretty_entry_title(entry)
  [entry.title, entry.theming.cname_domain.presence].compact.join(' - ')
end

#pretty_entry_url(entry, options = {}) ⇒ Object



7
8
9
10
# File 'app/helpers/pageflow/entries_helper.rb', line 7

def pretty_entry_url(entry, options = {})
  params = options.reverse_merge(Pageflow.config.theming_url_options(entry.theming) || {})
  pageflow.short_entry_url(entry.to_model, params)
end