diff options
Diffstat (limited to 'app/controllers/blog/posts_controller.rb')
-rw-r--r-- | app/controllers/blog/posts_controller.rb | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/app/controllers/blog/posts_controller.rb b/app/controllers/blog/posts_controller.rb index f7b6f3c..9c413ed 100644 --- a/app/controllers/blog/posts_controller.rb +++ b/app/controllers/blog/posts_controller.rb @@ -2,6 +2,7 @@ class Blog::PostsController < BlogController before_filter :find_all_blog_posts, :except => [:archive] before_filter :find_blog_post, :only => [:show, :comment, :update_nav] + before_filter :find_tags respond_to :html, :js, :rss @@ -45,13 +46,32 @@ 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({ + 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 + + def tagged + @tag_name = params[:tag_name] + @blog_posts = BlogPost.tagged_with(@tag_name.titleize).paginate({ :page => params[:page], :per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10) }) - respond_with (@blog_posts) end protected @@ -72,5 +92,9 @@ protected :per_page => RefinerySetting.find_or_set(:blog_posts_per_page, 10) }) end + + def find_tags + @tags = BlogPost.tag_counts_on(:tags) + end end |