Module: Pulitzer::PostsHelper

Defined in:
app/helpers/pulitzer/posts_helper.rb

Instance Method Summary collapse

Instance Method Details

#humanize_class_name(klass) ⇒ Object



47
48
49
# File 'app/helpers/pulitzer/posts_helper.rb', line 47

def humanize_class_name(klass)
  underscore_class_name(klass).humanize
end

#import_post_submit_hash(post_type_version) ⇒ Object



59
60
61
62
63
64
65
# File 'app/helpers/pulitzer/posts_helper.rb', line 59

def import_post_submit_hash(post_type_version)
  if post_type_version.plural?
    {}
  else
    {confirm: 'This will delete the existing post if any exists.'}
  end
end


14
15
16
17
18
19
20
# File 'app/helpers/pulitzer/posts_helper.rb', line 14

def link_back_to_posts(post_type_version, plural_label, singular_label)
  if post_type_version.plural?
    ajax_link plural_label, pulitzer.posts_path(post_type_version_id: post_type_version.id), {}, '[data-tab-id="templates"]'
  else
    ajax_link singular_label, pulitzer.post_types_path, {}, '[data-tab-id="templates"]'
  end
end


4
5
6
7
8
9
10
11
12
# File 'app/helpers/pulitzer/posts_helper.rb', line 4

def link_to_posts(post_type_version, plural_label, singular_label)
  if post_type_version.plural?
    ajax_link plural_label, posts_path(post_type_version_id: post_type_version.id), {}, '[data-tab-id="templates"]'
  elsif post_type_version.singleton_post
    ajax_link singular_label, edit_post_path(post_type_version.singleton_post), {}, '[data-tab-id="templates"]'
  else
    ''
  end
end

#render_clickable(element) ⇒ Object



26
27
28
29
30
31
32
33
# File 'app/helpers/pulitzer/posts_helper.rb', line 26

def render_clickable(element)
  (:span, 'clickabe text:&nbsp'.html_safe, class: 'pulitzer-span heading') +
  (:span, element.title, class: 'pulitzer-span margin') +
  (:span, 'action: '.html_safe, class: 'pulitzer-span heading') +
  (:span, element.content_display, class: 'pulitzer-span margin') +
  (:span, 'style: '.html_safe, class: 'pulitzer-span heading') +
  (:span, element.style_display, class: 'pulitzer-span margin')
end

#render_element(element) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'app/helpers/pulitzer/posts_helper.rb', line 35

def render_element(element)
  if element.image_type?
    image_tag(element.image_url(:thumb)) if element.image?
  elsif element.video_type?
    render_video(element)
  elsif element.clickable_type?
    render_clickable(element)
  else
    element.body.html_safe if element.body
  end
end

#render_video(element) ⇒ Object



22
23
24
# File 'app/helpers/pulitzer/posts_helper.rb', line 22

def render_video(element)
  (:iframe, nil, src: element.video_link) if element.video_link
end

#select2_html_options(tag_model) ⇒ Object



55
56
57
# File 'app/helpers/pulitzer/posts_helper.rb', line 55

def select2_html_options(tag_model)
  { class: 'seletct2-pulitzer-tags', data: { select2_trigger: true } }
end

#underscore_class_name(klass) ⇒ Object



51
52
53
# File 'app/helpers/pulitzer/posts_helper.rb', line 51

def underscore_class_name(klass)
  klass.delete(":").underscore
end