Module: Pulitzer::PostsHelper

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

Instance Method Summary collapse

Instance Method Details

#humanize_class_name(klass) ⇒ Object



34
35
36
# File 'app/helpers/pulitzer/posts_helper.rb', line 34

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


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

def link_back_to_posts(post_type, plural_label, singular_label)
  if post_type.plural?
    link_to plural_label, pulitzer.posts_path(post_type_id: post_type.id)
  else
    link_to singular_label, pulitzer.post_types_path
  end
end


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

def link_to_posts(post_type, plural_label, singular_label)
  if post_type.plural?
    link_to plural_label, posts_path(post_type_id: post_type.id)
  else
    link_to singular_label, edit_post_path(post_type.singleton_post)
  end
end

#render_element(element) ⇒ Object



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

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

#render_video(element) ⇒ Object



20
21
22
# File 'app/helpers/pulitzer/posts_helper.rb', line 20

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

#select2_html_options(tag_model) ⇒ Object



42
43
44
# File 'app/helpers/pulitzer/posts_helper.rb', line 42

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

#underscore_class_name(klass) ⇒ Object



38
39
40
# File 'app/helpers/pulitzer/posts_helper.rb', line 38

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