Module: Pageflow::EntriesHelper

Includes:
RenderJsonHelper
Defined in:
app/helpers/pageflow/entries_helper.rb

Constant Summary

Constants included from RenderJsonHelper

RenderJsonHelper::ESCAPED_CHARS, RenderJsonHelper::ESCAPED_CHARS_REGEX

Instance Method Summary collapse

Methods included from RenderJsonHelper

#render_html_partial, #render_json_partial, #render_json_seed, #render_with_format, #sanitize_json

Instance Method Details

#entry_css_class(entry) ⇒ Object



57
58
59
60
61
62
# File 'app/helpers/pageflow/entries_helper.rb', line 57

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



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/pageflow/entries_helper.rb', line 9

def entry_file_rights(entry)
  rights = [:audio_files, :image_files, :video_files].map do |collection|
    entry.send(collection).map do |file|
      file.rights.presence || entry..default_file_rights
    end
  end.flatten.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



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/helpers/pageflow/entries_helper.rb', line 25

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 links.any?
    (:h2, I18n.t('pageflow.helpers.entries.global_links'), :class => 'hidden') + safe_join(links, ''.html_safe)
  else
    ''
  end
end

#entry_header_css_class(entry) ⇒ Object



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

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



49
50
51
52
53
54
55
# File 'app/helpers/pageflow/entries_helper.rb', line 49

def entry_mobile_navigation_pages(entry)
  entry.pages.displayed_in_navigation.tap do |pages|
    if entry.pages.any? && !entry.pages.first.display_in_navigation
      pages.unshift(entry.pages.first)
    end
  end
end

#entry_pages_json_seed(entry) ⇒ Object



77
78
79
# File 'app/helpers/pageflow/entries_helper.rb', line 77

def entry_pages_json_seed(entry)
  sanitize_json(entry.pages.to_json(only: [:id, :perma_id, :configuration])).html_safe
end

#entry_stylesheet_link_tag(entry) ⇒ Object



45
46
47
# File 'app/helpers/pageflow/entries_helper.rb', line 45

def entry_stylesheet_link_tag(entry)
  stylesheet_link_tag(polymorphic_path(entry.stylesheet_model, v: entry.stylesheet_cache_key, format: 'css'), media: 'all')
end

#entry_summary(entry) ⇒ Object



72
73
74
75
# File 'app/helpers/pageflow/entries_helper.rb', line 72

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

#entry_theme_stylesheet_link_tag(entry) ⇒ Object



41
42
43
# File 'app/helpers/pageflow/entries_helper.rb', line 41

def entry_theme_stylesheet_link_tag(entry)
  stylesheet_link_tag(entry.theming.theme.stylesheet_path, :media => 'all')
end

#pretty_entry_url(entry) ⇒ Object



5
6
7
# File 'app/helpers/pageflow/entries_helper.rb', line 5

def pretty_entry_url(entry)
  pageflow.short_entry_url(entry.to_model, Pageflow.config.theming_url_options(entry.theming))
end