Module: PostsHelper

Included in:
ApplicationHelper
Defined in:
app/helpers/posts_helper.rb

Instance Method Summary collapse

Instance Method Details



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'app/helpers/posts_helper.rb', line 57

def breadcrumb(options={})
  id_name = options[:id] || "breadcrumb"
  class_name = options[:class] || ""
  if @post
    list = ""
    @post.path.each do |art|
      link_name = link_to(art.breadcrumb_name, art.public_url)
      list << (:li, raw(link_name))
    end
    content_list = (:ol, raw(list))
    if id_name.present?
      result = (:nav, raw(content_list), :id => "#{id_name}", :class => "#{class_name}")
    else
      result = (:nav, raw(content_list), :class => "#{class_name}")
    end
    return raw(result)
  end
end

#index_of_posts(options = {}) ⇒ Object



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

def index_of_posts(options={})
  if @post && @post.post_for_index_id.present? && master_index_post = Post.find_by_id(@post.post_for_index_id)
    result_list = ""
    result_list += (:h2, raw("&nbsp;"), class: "boxheader")
    result_list += (:h1, "#{master_index_post.title}", class: "headline")
    dom_element = (options[:wrapper]).present? ? options[:wrapper] : :div
    master_index_post.descendants.order(:created_at).limit(@post.post_for_index_limit).each do |art|
      if @post.post_for_index_levels.to_i == 0 || (@post.depth + @post.post_for_index_levels.to_i > art.depth)
        rendered_post_list_item = render_post_list_item(art)
        result_list += (dom_element, rendered_post_list_item, :id => "post_index_list_item_#{art.id}", :class => "post_index_list_item")
      end
    end
    return (:post, raw(result_list), :id => "post_index_list")
  end
end

def render_post_image_gallery

if @post
  result = ""
  uploads = Upload.tagged_with(@post.image_gallery_tags.present? ? @post.image_gallery_tags.split(",") : "" )
  if uploads && uploads.count > 0
    uploads.order(:sorter_number).each do |upload|
      result << ("li", link_to(image_tag(upload.image.url(:thumb), {alt: upload.alt_text}), upload.image.url(:large), title: raw(upload.description)))
    end
  end
  return ("ul", raw(result), :class => "post_image_gallery")
end

end



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/helpers/posts_helper.rb', line 31

def navigation_menu(menu_id, options={})
  return "id can't be blank" if menu_id.blank?
  #0 = unlimited, 1 = self, 2 = self and children 1. grades, 3 = self and up to children 2.grades
  depth = options[:depth] || 0
  class_name = options[:class] || ""
  id_name = options[:id] || ""
  if menu_id.class == String
    master_menu = Menu.active.find_by_title(menu_id)
  else
    master_menu = Menu.active.find_by_id(menu_id)
  end

  if master_menu.present?
    content = ""
    master_menu.children.active.includes(:image).collect do |child|
      content << navigation_menu_helper(child, depth, 1, options)
    end
    if id_name.present?
      result = (:ul, raw(content),:id => "#{id_name}", :class => "#{class_name} #{depth} navigation #{master_menu.css_class.to_s.gsub(/\W/,' ')}".squeeze(' ').strip)
    else
      result = (:ul, raw(content), :class => "#{class_name} #{depth} navigation #{master_menu.css_class.to_s.gsub(/\W/,' ')}".squeeze(' ').strip)
    end
  end
  return raw(result)
end

#read_on(post) ⇒ Object

‘Read on’ link to post for index-pages If external_url_redirect is set and a link_title is given, display this link title. Otherwise display a generic link title.



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

def read_on(post)
  if post.redirect_link_title.present?
    link_to post.redirect_link_title, post.external_url_redirect, class: 'more'
  else
    link_to t(:read_on, scope: [:posts]), post.public_url, class: 'more'
  end
end

#render_post_content_parts(post) ⇒ Object



14
15
16
# File 'app/helpers/posts_helper.rb', line 14

def render_post_content_parts(post)
  render :partial => "/posts/show", :locals => {:post => post}
end

#render_post_type_content(options = {}) ⇒ Object



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

def render_post_type_content(options={})
  if @post && @post.post_type.present? && @post.kind_of_post_type.present?
    render :partial => "posttypes/#{@post.post_type_form_file.downcase}/#{@post.kind_of_post_type.downcase}"
  else
    render :partial => "posttypes/default/show"
  end
end