aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
authorJoe Sak <joe@joesak.com>2011-01-10 16:11:53 -0600
committerJoe Sak <joe@joesak.com>2011-01-10 16:11:53 -0600
commitbf74b32f3fbdd50957bdf308b79846eeda7ee1fa (patch)
treeba836797c939e54c60bf92c30323e2e7c666a8dc /app/helpers
parentb29b7df9acd67e8d2059766db4a743bc98d3effd (diff)
downloadrefinerycms-blog-bf74b32f3fbdd50957bdf308b79846eeda7ee1fa.tar.gz
refinerycms-blog-bf74b32f3fbdd50957bdf308b79846eeda7ee1fa.tar.bz2
refinerycms-blog-bf74b32f3fbdd50957bdf308b79846eeda7ee1fa.zip
Archives group by year after 2 years
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/blog_posts_helper.rb20
1 files changed, 17 insertions, 3 deletions
diff --git a/app/helpers/blog_posts_helper.rb b/app/helpers/blog_posts_helper.rb
index 965eb8f..9cc637f 100644
--- a/app/helpers/blog_posts_helper.rb
+++ b/app/helpers/blog_posts_helper.rb
@@ -6,18 +6,32 @@ module BlogPostsHelper
html << t('blog.shared.archives')
html << '</h2><nav><ul>'
links = []
+ super_old_links = []
posts.each do |e|
- links << e.published_at.strftime('%m/%Y')
+ 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 = BlogPost.by_archive(Time.parse(l)).size
+ count = NewsItem.by_archive(Time.parse(l)).size
text = t("date.month_names")[month.to_i] + " #{year} (#{count})"
html << "<li>"
- html << link_to(text, archive_blog_posts_path(:year => year, :month => month))
+ html << link_to(text, archive_news_items_path(:year => year, :month => month))
+ html << "</li>"
+ end
+ super_old_links.each do |l|
+ year = l.split('/')[1]
+ count = NewsItem.by_year(Time.parse(l)).size
+ text = "#{year} (#{count})"
+ html << "<li>"
+ html << link_to(text, archive_news_items_path(:year => year))
html << "</li>"
end
html << '</ul></nav></section>'