Module: Refinery::News::ItemsHelper

Defined in:
app/helpers/refinery/news/items_helper.rb

Instance Method Summary collapse

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


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
  ('ul', raw(html))
end

#news_item_archive_widgetObject Also known as: news_archive_list



4
5
6
7
8
9
# File 'app/helpers/refinery/news/items_helper.rb', line 4

def news_item_archive_widget
  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 news_item_teaser(item)
  if item.respond_to?(:custom_teaser) && item.custom_teaser.present?
    item.custom_teaser.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

Returns:

  • (Boolean)


16
17
18
# File 'app/helpers/refinery/news/items_helper.rb', line 16

def news_item_teaser_enabled?
  Refinery::News::Item.teasers_enabled?
end

#next_or_previous?(item) ⇒ Boolean

Returns:

  • (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