Module: WhatsonPostsHelper

Defined in:
app/helpers/whatson_posts_helper.rb

Instance Method Summary collapse

Instance Method Details

#next_or_previous?(post) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'app/helpers/whatson_posts_helper.rb', line 38

def next_or_previous?(post)
  post.next.present? or post.prev.present?
end

#whatson_archive_listObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/helpers/whatson_posts_helper.rb', line 2

def whatson_archive_list
  posts = WhatsonPost.live.select('published_at').all_previous
  return nil if posts.blank?
  html = ''
  links = []
  super_old_links = []

  posts.each do |e|
    if e.published_at >= Time.now.end_of_year.advance(:years => -3)
      links << e.published_at.strftime('%m/%Y') 
    else
      super_old_links << e.published_at.strftime('01/%Y')
    end
  end
  links.uniq!
  super_old_links.uniq!
  links.each do |l|
    year = l.split('/')[1]
    month = l.split('/')[0]
    count = WhatsonPost.live.by_archive(Time.parse(l)).size
    text = t("date.month_names")[month.to_i] + " #{year} (#{count})"      
    html << "<li>"
    html << link_to(text, archive_whatson_posts_path(:year => year, :month => month))
    html << "</li>"
  end
  super_old_links.each do |l|
    year = l.split('/')[1]
    count = WhatsonPost.live.by_year(Time.parse(l)).size
    text = "#{year} (#{count})"
    html << "<li>"
    html << link_to(text, archive_whatson_posts_path(:year => year))
    html << "</li>"
  end
  html.html_safe
end

#whatson_post_teaser(post) ⇒ Object



46
47
48
49
50
51
52
53
54
55
# File 'app/helpers/whatson_posts_helper.rb', line 46

def (post)
  if post.respond_to?(:custom_teaser) && post.custom_teaser.present?
   post.custom_teaser.html_safe
  else
   truncate(post.body, {
     :length => RefinerySetting.find_or_set(:whatson_post_teaser_length, 250),
     :preserve_html_tags => true
    }).html_safe
  end
end

#whatson_post_teaser_enabled?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/helpers/whatson_posts_helper.rb', line 42

def 
  WhatsonPost.teasers_enabled?
end