Module: Refinery::News::ItemsHelper
- Defined in:
- app/helpers/refinery/news/items_helper.rb
Instance Method Summary collapse
- #archive_date_format(date_for_month) ⇒ Object
- #news_item_archive_links ⇒ Object
- #news_item_archive_widget ⇒ Object (also: #news_archive_list)
- #news_item_teaser(item) ⇒ Object
- #news_item_teaser_enabled? ⇒ Boolean
- #next_or_previous?(item) ⇒ Boolean
Instance Method Details
#archive_date_format(date_for_month) ⇒ Object
43 44 45 |
# File 'app/helpers/refinery/news/items_helper.rb', line 43 def archive_date_format(date_for_month) date_for_month ? "%B %Y" : "%Y" end |
#news_item_archive_links ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/refinery/news/items_helper.rb', line 31 def news_item_archive_links html = '' item_months = ::Refinery::News::Item.archived.group_by {|i| i.publish_date.beginning_of_month} item_months.each do |month, items| if items.present? text = "#{t("date.month_names")[month.month]} #{month.year} (#{items.count})" html += "<li>#{link_to(text, refinery.news_items_archive_path(:year => month.year, :month => month.month))}</li>" end end content_tag('ul', raw(html)) end |
#news_item_archive_widget ⇒ Object Also known as: news_archive_list
4 5 6 7 8 9 |
# File 'app/helpers/refinery/news/items_helper.rb', line 4 def items = Refinery::News::Item.select('publish_date').all_previous return nil if items.blank? render "/refinery/news/items/widgets/news_archive", :items => items end |
#news_item_teaser(item) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/refinery/news/items_helper.rb', line 20 def (item) if item.respond_to?(:custom_teaser) && item..present? item..html_safe else truncate(item.body, { :length => Refinery::Setting.find_or_set(:news_item_teaser_length, 250), :preserve_html_tags => true }).html_safe end end |
#news_item_teaser_enabled? ⇒ Boolean
16 17 18 |
# File 'app/helpers/refinery/news/items_helper.rb', line 16 def Refinery::News::Item. end |
#next_or_previous?(item) ⇒ Boolean
12 13 14 |
# File 'app/helpers/refinery/news/items_helper.rb', line 12 def next_or_previous?(item) item.next.present? or item.prev.present? end |