Module: ArticlesHelper
- Defined in:
- app/helpers/articles_helper.rb
Instance Method Summary collapse
- #breadcrumb(options = {}) ⇒ Object
- #index_of_articles(options = {}) ⇒ Object
- #navigation_menu(menu_id, options = {}) ⇒ Object
-
#read_on(article) ⇒ Object
‘Read on’ link to article for index-pages If external_url_redirect is set and a link_title is given, display this link title.
- #render_article_content_parts(article) ⇒ Object
- #render_article_image_gallery ⇒ Object
- #render_article_type_content(options = {}) ⇒ Object
- #render_article_widgets(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/articles_helper.rb', line 57 def (={}) id_name = [:id] || "breadcrumb" class_name = [:class] || "" if @article list = "" @article.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_articles(options = {}) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/helpers/articles_helper.rb', line 76 def index_of_articles(={}) if @article && @article.article_for_index_id.present? && master_index_article = Article.find_by_id(@article.article_for_index_id) result_list = "" result_list += content_tag(:h2, raw(" "), class: "boxheader") result_list += content_tag(:h1, "#{master_index_article.title}", class: "headline") dom_element = ([:wrapper]).present? ? [:wrapper] : :div master_index_article.descendants.order(:created_at).limit(@article.article_for_index_limit).each do |art| if @article.article_for_index_levels.to_i == 0 || (@article.depth + @article.article_for_index_levels.to_i > art.depth) rendered_article_list_item = render_article_list_item(art) result_list += content_tag(dom_element, rendered_article_list_item, :id => "article_index_list_item_#{art.id}", :class => "article_index_list_item") end end return content_tag(:article, raw(result_list), :id => "article_index_list") end end |
#navigation_menu(menu_id, options = {}) ⇒ Object
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/articles_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(article) ⇒ Object
‘Read on’ link to article 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/articles_helper.rb', line 6 def read_on(article) if article.redirect_link_title.present? link_to article.redirect_link_title, article.external_url_redirect, class: 'more' else link_to t(:read_on, scope: [:articles]), article.public_url, class: 'more' end end |
#render_article_content_parts(article) ⇒ Object
14 15 16 |
# File 'app/helpers/articles_helper.rb', line 14 def render_article_content_parts(article) render :partial => "/articles/show", :locals => {:article => article} end |
#render_article_image_gallery ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/articles_helper.rb', line 18 def render_article_image_gallery if @article result = "" uploads = Upload.tagged_with(@article..present? ? @article..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 => "article_image_gallery") end end |
#render_article_type_content(options = {}) ⇒ Object
92 93 94 95 96 97 98 |
# File 'app/helpers/articles_helper.rb', line 92 def render_article_type_content(={}) if @article && @article.article_type.present? && @article.kind_of_article_type.present? render :partial => "articletypes/#{@article.article_type_form_file.downcase}/#{@article.kind_of_article_type.downcase}" else render :partial => "articletypes/default/show" end end |
#render_article_widgets(options = {}) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'app/helpers/articles_helper.rb', line 100 def (={}) custom_css = [:class] || "" = [:tagged_with] || "" default = [:default] || "false" = [:wrapper] || "section" result = "" if @article = @article..active if .present? && default == "false" = .tagged_with(.split(",")) elsif default == true && .present? = Widget.active.where(:default => true).tagged_with(.split(",")) else = .where(:tag_list => "") end = .order(:sorter) .each do || template = Liquid::Template.parse(.content) alt_template = Liquid::Template.parse(.alternative_content) = {"class" => "#{.css_name} #{custom_css} rdcms_widget", "id" => .id_name.present? ? .id_name : "widget_id_#{.id}", 'data-date-start' => .offline_date_start_display, 'data-date-end' => .offline_date_end_display, 'data-offline-active' => .offline_time_active, 'data-id' => .id } = .merge(.offline_time_week) result << content_tag(, raw(template.render(Article::LiquidParser)), ) result << content_tag(, raw(alt_template.render(Article::LiquidParser)), class: "#{.css_name} #{custom_css} hidden rdcms_widget", id: .id_name, 'data-id' => .id) end end return raw(result) end |