aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authordjones <dgjones@gmail.com>2010-09-06 16:22:13 +1200
committerdjones <dgjones@gmail.com>2010-09-06 16:22:13 +1200
commitbd50bdb415346329e772a90f26828376a6a1cffb (patch)
tree3722ac255f4b96a0e4adf8ec2493dfbd002ade68 /app/controllers
parent6f342c1314dfbc8a02a2d4276f6ae7b0bc951661 (diff)
downloadrefinerycms-blog-bd50bdb415346329e772a90f26828376a6a1cffb.tar.gz
refinerycms-blog-bd50bdb415346329e772a90f26828376a6a1cffb.tar.bz2
refinerycms-blog-bd50bdb415346329e772a90f26828376a6a1cffb.zip
refactoring the frontend to use more partials, separate out the categories into it's own controller, namespace the blog into it's own folder and create a base blog controller for handling common front end tasks
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/blog/categories_controller.rb7
-rw-r--r--app/controllers/blog/posts_controller.rb (renamed from app/controllers/blog_posts_controller.rb)29
-rw-r--r--app/controllers/blog_controller.rb15
3 files changed, 25 insertions, 26 deletions
diff --git a/app/controllers/blog/categories_controller.rb b/app/controllers/blog/categories_controller.rb
new file mode 100644
index 0000000..71ceec1
--- /dev/null
+++ b/app/controllers/blog/categories_controller.rb
@@ -0,0 +1,7 @@
+class Blog::CategoriesController < BlogController
+
+ def show
+ @category = BlogCategory.find(params[:id])
+ end
+
+end \ No newline at end of file
diff --git a/app/controllers/blog_posts_controller.rb b/app/controllers/blog/posts_controller.rb
index 73b9dfa..8a10604 100644
--- a/app/controllers/blog_posts_controller.rb
+++ b/app/controllers/blog/posts_controller.rb
@@ -1,15 +1,8 @@
-class BlogPostsController < ApplicationController
+class Blog::PostsController < BlogController
- before_filter :find_all_blog_posts, :find_all_blog_categories
- before_filter :find_page
+ before_filter :find_all_blog_posts
before_filter :find_blog_post, :only => [:show, :comment]
- def index
- # you can use meta fields from your model instead (e.g. browser_title)
- # by swapping @page for @blogs in the line below:
- present(@page)
- end
-
def show
@blog_comment = BlogComment.new
@@ -40,23 +33,7 @@ protected
end
def find_all_blog_posts
- unless params[:category_id].present?
- @blog_posts = BlogPost.live
- else
- if (category = BlogCategory.find(params[:category_id])).present?
- @blog_posts = category.posts
- else
- error_404
- end
- end
- end
-
- def find_all_blog_categories
- @blog_categories = BlogCategory.all
- end
-
- def find_page
- @page = Page.find_by_link_url("/blog")
+ @blog_posts = BlogPost.live
end
end
diff --git a/app/controllers/blog_controller.rb b/app/controllers/blog_controller.rb
new file mode 100644
index 0000000..0931cbd
--- /dev/null
+++ b/app/controllers/blog_controller.rb
@@ -0,0 +1,15 @@
+class BlogController < ApplicationController
+
+ before_filter :find_page, :find_all_blog_categories
+
+protected
+
+ def find_page
+ @page = Page.find_by_link_url("/blog")
+ end
+
+ def find_all_blog_categories
+ @blog_categories = BlogCategory.all
+ end
+
+end \ No newline at end of file