aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/refinery
diff options
context:
space:
mode:
authorPhilip Arndt <parndt@gmail.com>2011-11-09 22:19:07 +1300
committerPhilip Arndt <parndt@gmail.com>2011-11-09 22:19:07 +1300
commit36c005ecd112b76d3c9c2d7092f22d6e06755d73 (patch)
tree23e37055e6c6aa79a9c5285387052acdc708ba30 /app/controllers/refinery
parentd18364d359359fa6564ad187d7303f8c167154cd (diff)
downloadrefinerycms-blog-36c005ecd112b76d3c9c2d7092f22d6e06755d73.tar.gz
refinerycms-blog-36c005ecd112b76d3c9c2d7092f22d6e06755d73.tar.bz2
refinerycms-blog-36c005ecd112b76d3c9c2d7092f22d6e06755d73.zip
Refactored everything (models, helpers) into proper namespace of Refinery::Blog. Requires refinery commit 25162b585b9c4023d39fd1a9796140bfa4ecb909
Diffstat (limited to 'app/controllers/refinery')
-rw-r--r--app/controllers/refinery/admin/blog/categories_controller.rb2
-rw-r--r--app/controllers/refinery/admin/blog/comments_controller.rb12
-rw-r--r--app/controllers/refinery/admin/blog/posts_controller.rb25
-rw-r--r--app/controllers/refinery/admin/blog/settings_controller.rb12
-rw-r--r--app/controllers/refinery/blog/base_controller.rb2
-rw-r--r--app/controllers/refinery/blog/categories_controller.rb4
-rw-r--r--app/controllers/refinery/blog/posts_controller.rb14
7 files changed, 36 insertions, 35 deletions
diff --git a/app/controllers/refinery/admin/blog/categories_controller.rb b/app/controllers/refinery/admin/blog/categories_controller.rb
index 12f22ce..0fe4eec 100644
--- a/app/controllers/refinery/admin/blog/categories_controller.rb
+++ b/app/controllers/refinery/admin/blog/categories_controller.rb
@@ -3,7 +3,7 @@ module Refinery
module Blog
class CategoriesController < ::Refinery::AdminController
- crudify :'refinery/blog_category',
+ crudify :'refinery/blog/category',
:title_attribute => :title,
:order => 'title ASC'
diff --git a/app/controllers/refinery/admin/blog/comments_controller.rb b/app/controllers/refinery/admin/blog/comments_controller.rb
index a3df235..6c1417e 100644
--- a/app/controllers/refinery/admin/blog/comments_controller.rb
+++ b/app/controllers/refinery/admin/blog/comments_controller.rb
@@ -5,23 +5,23 @@ module Refinery
cache_sweeper Refinery::BlogSweeper
- crudify :'refinery/blog_comment',
+ crudify :'refinery/blog/comment',
:title_attribute => :name,
:order => 'published_at DESC'
def index
- @blog_comments = Refinery::BlogComment.unmoderated.page(params[:page])
+ @blog_comments = Refinery::Blog::Comment.unmoderated.page(params[:page])
render :action => 'index'
end
def approved
unless params[:id].present?
- @blog_comments = Refinery::BlogComment.approved.page(params[:page])
+ @blog_comments = Refinery::Blog::Comment.approved.page(params[:page])
render :action => 'index'
else
- @blog_comment = Refinery::BlogComment.find(params[:id])
+ @blog_comment = Refinery::Blog::Comment.find(params[:id])
@blog_comment.approve!
flash[:notice] = t('approved', :scope => 'refinery.admin.blog.comments', :author => @blog_comment.name)
@@ -31,11 +31,11 @@ module Refinery
def rejected
unless params[:id].present?
- @blog_comments = Refinery::BlogComment.rejected.page(params[:page])
+ @blog_comments = Refinery::Blog::Comment.rejected.page(params[:page])
render :action => 'index'
else
- @blog_comment = Refinery::BlogComment.find(params[:id])
+ @blog_comment = Refinery::Blog::Comment.find(params[:id])
@blog_comment.reject!
flash[:notice] = t('rejected', :scope => 'refinery.admin.blog.comments', :author => @blog_comment.name)
diff --git a/app/controllers/refinery/admin/blog/posts_controller.rb b/app/controllers/refinery/admin/blog/posts_controller.rb
index 62b6949..aa40c85 100644
--- a/app/controllers/refinery/admin/blog/posts_controller.rb
+++ b/app/controllers/refinery/admin/blog/posts_controller.rb
@@ -2,20 +2,21 @@ module Refinery
module Admin
module Blog
class PostsController < ::Refinery::AdminController
-
+
cache_sweeper Refinery::BlogSweeper
- crudify :'refinery/blog_post',
+ crudify :'refinery/blog/post',
:title_attribute => :title,
- :order => 'published_at DESC'
-
+ :order => 'published_at DESC',
+ :redirect_to_url => "main_app.refinery_admin_blog_posts_path"
+
before_filter :find_all_categories,
:only => [:new, :edit, :create, :update]
- before_filter :check_category_ids, :only => :update
+ before_filter :check_category_ids, :only => :update
def uncategorized
- @blog_posts = Refinery::BlogPost.uncategorized.page(params[:page])
+ @blog_posts = Refinery::Blog::Post.uncategorized.page(params[:page])
end
def tags
@@ -31,7 +32,7 @@ module Refinery
else
'%'
end
- @tags = Refinery::BlogPost.tag_counts_on(:tags).where(
+ @tags = Refinery::Blog::Post.tag_counts_on(:tags).where(
["tags.name #{op} ?", "#{wildcard}#{params[:term].to_s.downcase}#{wildcard}"]
).map { |tag| {:id => tag.id, :value => tag.name}}
render :json => @tags.flatten
@@ -39,19 +40,19 @@ module Refinery
def create
# if the position field exists, set this object as last object, given the conditions of this class.
- if Refinery::BlogPost.column_names.include?("position")
+ if Refinery::Blog::Post.column_names.include?("position")
params[:blog_post].merge!({
- :position => ((Refinery::BlogPost.maximum(:position, :conditions => "")||-1) + 1)
+ :position => ((Refinery::Blog::Post.maximum(:position, :conditions => "")||-1) + 1)
})
end
- if Refinery::BlogPost.column_names.include?("user_id")
+ if Refinery::Blog::Post.column_names.include?("user_id")
params[:blog_post].merge!({
:user_id => current_refinery_user.id
})
end
- if (@blog_post = Refinery::BlogPost.create(params[:blog_post])).valid?
+ if (@blog_post = Refinery::Blog::Post.create(params[:blog_post])).valid?
(request.xhr? ? flash.now : flash).notice = t(
'refinery.crudify.created',
:what => "'#{@blog_post.title}'"
@@ -85,7 +86,7 @@ module Refinery
protected
def find_all_categories
- @blog_categories = Refinery::BlogCategory.find(:all)
+ @blog_categories = Refinery::Blog::Category.find(:all)
end
def check_category_ids
diff --git a/app/controllers/refinery/admin/blog/settings_controller.rb b/app/controllers/refinery/admin/blog/settings_controller.rb
index 1894ac6..ee71393 100644
--- a/app/controllers/refinery/admin/blog/settings_controller.rb
+++ b/app/controllers/refinery/admin/blog/settings_controller.rb
@@ -4,12 +4,12 @@ module Refinery
class SettingsController < ::Refinery::AdminController
def notification_recipients
- @recipients = Refinery::BlogComment::Notification.recipients
+ @recipients = Refinery::Blog::Comment::Notification.recipients
if request.post?
- Refinery::BlogComment::Notification.recipients = params[:recipients]
+ Refinery::Blog::Comment::Notification.recipients = params[:recipients]
flash[:notice] = t('updated', :scope => 'admin.blog.settings.notification_recipients',
- :recipients => Refinery::BlogComment::Notification.recipients)
+ :recipients => Refinery::Blog::Comment::Notification.recipients)
unless request.xhr? or from_dialog?
redirect_back_or_default(admin_blog_posts_path)
else
@@ -20,7 +20,7 @@ module Refinery
end
def moderation
- enabled = Refinery::BlogComment::Moderation.toggle!
+ enabled = Refinery::Blog::Comment::Moderation.toggle!
unless request.xhr?
redirect_back_or_default(admin_blog_posts_path)
else
@@ -30,7 +30,7 @@ module Refinery
end
def comments
- enabled = Refinery::BlogComment.toggle!
+ enabled = Refinery::Blog::Comment.toggle!
unless request.xhr?
redirect_back_or_default(admin_blog_posts_path)
else
@@ -40,7 +40,7 @@ module Refinery
end
def teasers
- enabled = Refinery::BlogPost.teaser_enabled_toggle!
+ enabled = Refinery::Blog::Post.teaser_enabled_toggle!
unless request.xhr?
redirect_back_or_default(admin_blog_posts_path)
else
diff --git a/app/controllers/refinery/blog/base_controller.rb b/app/controllers/refinery/blog/base_controller.rb
index 01892d1..919c180 100644
--- a/app/controllers/refinery/blog/base_controller.rb
+++ b/app/controllers/refinery/blog/base_controller.rb
@@ -4,7 +4,7 @@ module Refinery
include ControllerHelper
- helper :'refinery/blog_posts'
+ helper :'refinery/blog/posts'
before_filter :find_page, :find_all_blog_categories
protected
diff --git a/app/controllers/refinery/blog/categories_controller.rb b/app/controllers/refinery/blog/categories_controller.rb
index 80e54d9..60c8346 100644
--- a/app/controllers/refinery/blog/categories_controller.rb
+++ b/app/controllers/refinery/blog/categories_controller.rb
@@ -3,8 +3,8 @@ module Refinery
class CategoriesController < BaseController
def show
- @category = Refinery::BlogCategory.find(params[:id])
- @blog_posts = @category.posts.live.includes(:comments, :categories).page(params[:page])
+ @blog_category = Refinery::Blog::Category.find(params[:id])
+ @blog_posts = @blog_category.posts.live.includes(:comments, :categories).page(params[:page])
end
end
diff --git a/app/controllers/refinery/blog/posts_controller.rb b/app/controllers/refinery/blog/posts_controller.rb
index 7b09329..d3cd7a1 100644
--- a/app/controllers/refinery/blog/posts_controller.rb
+++ b/app/controllers/refinery/blog/posts_controller.rb
@@ -12,7 +12,7 @@ module Refinery
def index
# Rss feeders are greedy. Let's give them every blog post instead of paginating.
- (@blog_posts = Refinery::BlogPost.live.includes(:comments, :categories).all) if request.format.rss?
+ (@blog_posts = Refinery::Blog::Post.live.includes(:comments, :categories).all) if request.format.rss?
respond_with (@blog_posts) do |format|
format.html
format.rss
@@ -20,7 +20,7 @@ module Refinery
end
def show
- @blog_comment = Refinery::BlogComment.new
+ @blog_comment = Refinery::Blog::Comment.new
respond_with (@blog_post) do |format|
format.html { present(@blog_post) }
@@ -30,7 +30,7 @@ module Refinery
def comment
if (@blog_comment = @blog_post.comments.create(params[:blog_comment])).valid?
- if Refinery::BlogComment::Moderation.enabled? or @blog_comment.ham?
+ if Refinery::Blog::Comment::Moderation.enabled? or @blog_comment.ham?
begin
Refinery::Blog::CommentMailer.notification(@blog_comment, request).deliver
rescue
@@ -38,7 +38,7 @@ module Refinery
end
end
- if Refinery::BlogComment::Moderation.enabled?
+ if Refinery::Blog::Comment::Moderation.enabled?
flash[:notice] = t('thank_you_moderated', :scope => 'refinery.blog.posts.comments')
redirect_to main_app.blog_post_url(params[:id])
else
@@ -56,12 +56,12 @@ module Refinery
date = "#{params[:month]}/#{params[:year]}"
@archive_date = Time.parse(date)
@date_title = @archive_date.strftime('%B %Y')
- @blog_posts = Refinery::BlogPost.live.by_archive(@archive_date).page(params[:page])
+ @blog_posts = Refinery::Blog::Post.live.by_archive(@archive_date).page(params[:page])
else
date = "01/#{params[:year]}"
@archive_date = Time.parse(date)
@date_title = @archive_date.strftime('%Y')
- @blog_posts = Refinery::BlogPost.live.by_year(@archive_date).page(params[:page])
+ @blog_posts = Refinery::Blog::Post.live.by_year(@archive_date).page(params[:page])
end
respond_with (@blog_posts)
end
@@ -69,7 +69,7 @@ module Refinery
def tagged
@tag = ActsAsTaggableOn::Tag.find(params[:tag_id])
@tag_name = @tag.name
- @blog_posts = Refinery::BlogPost.tagged_with(@tag_name).page(params[:page])
+ @blog_posts = Refinery::Blog::Post.tagged_with(@tag_name).page(params[:page])
end
end
end