Module: PostsHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/posts_helper.rb
Instance Method Summary collapse
- #breadcrumb(options = {}) ⇒ Object
- #index_of_posts(options = {}) ⇒ Object
-
#navigation_menu(menu_id, options = {}) ⇒ Object
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 << content_tag(“li”, link_to(image_tag(upload.image.url(:thumb), upload.alt_text), upload.image.url(:large), title: raw(upload.description))) end end return content_tag(“ul”, raw(result), :class => “post_image_gallery”) end 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.
- #render_post_content_parts(post) ⇒ Object
- #render_post_type_content(options = {}) ⇒ Object
Instance Method Details
#breadcrumb(options = {}) ⇒ Object
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 (={}) id_name = [:id] || "breadcrumb" class_name = [:class] || "" if @post list = "" @post.path.each do |art| link_name = link_to(art., art.public_url) list << content_tag(:li, raw(link_name)) end content_list = content_tag(:ol, raw(list)) if id_name.present? result = content_tag(:nav, raw(content_list), :id => "#{id_name}", :class => "#{class_name}") else result = content_tag(: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(={}) if @post && @post.post_for_index_id.present? && master_index_post = Post.find_by_id(@post.post_for_index_id) result_list = "" result_list += content_tag(:h2, raw(" "), class: "boxheader") result_list += content_tag(:h1, "#{master_index_post.title}", class: "headline") dom_element = ([:wrapper]).present? ? [: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 += content_tag(dom_element, rendered_post_list_item, :id => "post_index_list_item_#{art.id}", :class => "post_index_list_item") end end return content_tag(:post, raw(result_list), :id => "post_index_list") end end |
#navigation_menu(menu_id, options = {}) ⇒ Object
def render_post_image_gallery
if @post
result = ""
uploads = Upload.tagged_with(@post..present? ? @post..split(",") : "" )
if uploads && uploads.count > 0
uploads.order(:sorter_number).each do |upload|
result << content_tag("li", link_to(image_tag(upload.image.url(:thumb), {alt: upload.alt_text}), upload.image.url(:large), title: raw(upload.description)))
end
end
return content_tag("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 (, ={}) return "id can't be blank" if .blank? #0 = unlimited, 1 = self, 2 = self and children 1. grades, 3 = self and up to children 2.grades depth = [:depth] || 0 class_name = [:class] || "" id_name = [:id] || "" if .class == String = Menu.active.find_by_title() else = Menu.active.find_by_id() end if .present? content = "" .children.active.includes(:image).collect do |child| content << (child, depth, 1, ) end if id_name.present? result = content_tag(:ul, raw(content),:id => "#{id_name}", :class => "#{class_name} #{depth} navigation #{.css_class.to_s.gsub(/\W/,' ')}".squeeze(' ').strip) else result = content_tag(:ul, raw(content), :class => "#{class_name} #{depth} navigation #{.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(={}) 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 |