blob: 418f3603af7a885774e0f7f394f7452f114c23de (
plain) (
blame)
1
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
module Refinery
module Blog
module PostsHelper
def blog_archive_widget
posts = Refinery::Blog::Post.select('published_at').all_previous
return nil if posts.blank?
render :partial => "/refinery/blog/widgets/blog_archive", :locals => { :posts => posts }
end
alias_method :blog_archive_list, :blog_archive_widget
def next_or_previous?(post)
post.next.present? or post.prev.present?
end
def blog_post_teaser_enabled?
Refinery::Blog::Post.teasers_enabled?
end
def blog_post_teaser(post)
if post.respond_to?(:custom_teaser) && post.custom_teaser.present?
post.custom_teaser.html_safe
else
truncate(post.body, {
:length => Refinery::Setting.find_or_set(:blog_post_teaser_length, 250),
:preserve_html_tags => true
}).html_safe
end
end
def archive_link(post)
if post.published_at >= Time.now.end_of_year.advance(:years => -3)
post_date = post.published_at.strftime('%m/%Y')
year = post_date.split('/')[1]
month = post_date.split('/')[0]
count = Blog::Post.by_archive(Time.parse(post_date)).size
text = t("date.month_names")[month.to_i] + " #{year} (#{count})"
link_to(text, main_app.archive_blog_posts_path(:year => year, :month => month))
else
post_date = post.published_at.strftime('01/%Y')
year = post_date.split('/')[1]
count = Refinery::Blog::Post.by_year(Time.parse(post_date)).size
text = "#{year} (#{count})"
link_to(text, main_app.archive_blog_posts_path(:year => year))
end
end
end
end
end
|