aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/blog/posts_controller.rb
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/controllers/blog/posts_controller.rb
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/controllers/blog/posts_controller.rb')
-rw-r--r--app/controllers/blog/posts_controller.rb23
1 files changed, 17 insertions, 6 deletions
diff --git a/app/controllers/blog/posts_controller.rb b/app/controllers/blog/posts_controller.rb
index f7b6f3c..576073e 100644
--- a/app/controllers/blog/posts_controller.rb
+++ b/app/controllers/blog/posts_controller.rb
@@ -45,12 +45,23 @@ class Blog::PostsController < BlogController
end
def archive
- date = "#{params[:month]}/#{params[:year]}"
- @archive_date = Time.parse(date)
- @blog_posts = BlogPost.live.by_archive(@archive_date).paginate({
- :page => params[:page],
- :per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
- })
+ if params[:month].present?
+ date = "#{params[:month]}/#{params[:year]}"
+ @archive_date = Time.parse(date)
+ @date_title = @archive_date.strftime('%B %Y')
+ @blog_posts = BlogPost.live.by_archive(@archive_date).paginate({
+ :page => params[:page],
+ :per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
+ })
+ else
+ date = "01/#{params[:year]}"
+ @archive_date = Time.parse(date)
+ @date_title = @archive_date.strftime('%Y')
+ @blog_posts = BlogPost.live.by_year(@archive_date).paginate({
+ :page => params[:page],
+ :per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10)
+ })
+ end
respond_with (@blog_posts)
end