gluttonberg-blog 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +3 -0
  4. data/Rakefile +38 -0
  5. data/app/assets/javascripts/blog/application.js +15 -0
  6. data/app/assets/stylesheets/blog/application.css +13 -0
  7. data/app/controllers/gluttonberg/admin/blog/application_controller.rb +6 -0
  8. data/app/controllers/gluttonberg/admin/blog/articles_controller.rb +168 -0
  9. data/app/controllers/gluttonberg/admin/blog/blogs_controller.rb +95 -0
  10. data/app/controllers/gluttonberg/admin/blog/comments_controller.rb +117 -0
  11. data/app/controllers/gluttonberg/public/blog/articles_controller.rb +88 -0
  12. data/app/controllers/gluttonberg/public/blog/blogs_controller.rb +47 -0
  13. data/app/controllers/gluttonberg/public/blog/comments_controller.rb +54 -0
  14. data/app/helpers/gluttonberg/blog/application_helper.rb +6 -0
  15. data/app/mailers/blog_notifier.rb +26 -0
  16. data/app/models/gluttonberg/blog/article.rb +120 -0
  17. data/app/models/gluttonberg/blog/comment.rb +152 -0
  18. data/app/models/gluttonberg/blog/comment_subscription.rb +31 -0
  19. data/app/models/gluttonberg/blog/weblog.rb +25 -0
  20. data/app/views/blog_notifier/comment_notification.html.haml +17 -0
  21. data/app/views/blog_notifier/comment_notification_for_admin.html.haml +19 -0
  22. data/app/views/gluttonberg/admin/blog/articles/_form.html.haml +106 -0
  23. data/app/views/gluttonberg/admin/blog/articles/edit.html.haml +12 -0
  24. data/app/views/gluttonberg/admin/blog/articles/import.html.haml +36 -0
  25. data/app/views/gluttonberg/admin/blog/articles/index.html.haml +82 -0
  26. data/app/views/gluttonberg/admin/blog/articles/new.html.haml +11 -0
  27. data/app/views/gluttonberg/admin/blog/blogs/_form.html.haml +53 -0
  28. data/app/views/gluttonberg/admin/blog/blogs/edit.html.haml +10 -0
  29. data/app/views/gluttonberg/admin/blog/blogs/index.html.haml +35 -0
  30. data/app/views/gluttonberg/admin/blog/blogs/new.html.haml +10 -0
  31. data/app/views/gluttonberg/admin/blog/comments/index.html.haml +66 -0
  32. data/app/views/gluttonberg/public/blog/articles/index.rss.builder +21 -0
  33. data/app/views/gluttonberg/public/blog/blogs/show.rss.builder +21 -0
  34. data/app/views/layouts/blog/application.html.erb +14 -0
  35. data/config/routes.rb +53 -0
  36. data/lib/generators/gluttonberg/blog/blog_generator.rb +42 -0
  37. data/lib/generators/gluttonberg/blog/templates/articles_index.html.haml +18 -0
  38. data/lib/generators/gluttonberg/blog/templates/articles_show.html.haml +63 -0
  39. data/lib/generators/gluttonberg/blog/templates/articles_tag.html.haml +25 -0
  40. data/lib/generators/gluttonberg/blog/templates/blog_migration.rb +94 -0
  41. data/lib/generators/gluttonberg/blog/templates/blogs_index.html.haml +15 -0
  42. data/lib/generators/gluttonberg/blog/templates/blogs_show.html.haml +26 -0
  43. data/lib/gluttonberg/blog.rb +9 -0
  44. data/lib/gluttonberg/blog/engine.rb +22 -0
  45. data/lib/gluttonberg/blog/tasks/blog_tasks.rake +12 -0
  46. data/lib/gluttonberg/blog/version.rb +5 -0
  47. data/spec/dummy/README.rdoc +261 -0
  48. data/spec/dummy/Rakefile +7 -0
  49. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  50. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  51. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  52. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  53. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  54. data/spec/dummy/config.ru +4 -0
  55. data/spec/dummy/config/application.rb +59 -0
  56. data/spec/dummy/config/boot.rb +10 -0
  57. data/spec/dummy/config/database.yml +8 -0
  58. data/spec/dummy/config/environment.rb +5 -0
  59. data/spec/dummy/config/environments/development.rb +37 -0
  60. data/spec/dummy/config/environments/production.rb +67 -0
  61. data/spec/dummy/config/environments/test.rb +37 -0
  62. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  63. data/spec/dummy/config/initializers/inflections.rb +15 -0
  64. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  65. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  66. data/spec/dummy/config/initializers/session_store.rb +8 -0
  67. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  68. data/spec/dummy/config/locales/en.yml +5 -0
  69. data/spec/dummy/config/routes.rb +3 -0
  70. data/spec/dummy/db/schema.rb +476 -0
  71. data/spec/dummy/public/404.html +26 -0
  72. data/spec/dummy/public/422.html +26 -0
  73. data/spec/dummy/public/500.html +25 -0
  74. data/spec/dummy/public/favicon.ico +0 -0
  75. data/spec/dummy/script/rails +6 -0
  76. data/spec/fixtures/assets/gb_banner.jpg +0 -0
  77. data/spec/fixtures/assets/gb_logo.png +0 -0
  78. data/spec/fixtures/assets/high_res_photo.jpg +0 -0
  79. data/spec/fixtures/assets/untitled +0 -0
  80. data/spec/fixtures/members.csv +5 -0
  81. data/spec/fixtures/staff_profiles.csv +4 -0
  82. data/spec/helpers/page_info_spec.rb +213 -0
  83. data/spec/mailers/blog_notifier_spec.rb +127 -0
  84. data/spec/models/article_spec.rb +213 -0
  85. data/spec/spec_helper.rb +67 -0
  86. metadata +203 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 624aa971448a2627dcf108241474ecd9ec0e45e2
4
+ data.tar.gz: e54b8c8a4cd272cf7f7524611636fa88c0ce4a86
5
+ SHA512:
6
+ metadata.gz: e381727b030cb6733e24f459ad3e42259756827de715572cba5ed5c19f572ee36ab5067309b88cfdba82cd72d1f4603614bf9cb0fedb0fc1a1bb0548e16b3ecd
7
+ data.tar.gz: cd868f42debce1703cbfb23f0663c409e86b83d1ce37ae3932161bd9d03fadecb78683612247db6ce604adc700ff911a9bc9ffe02c8bbbd1a93b8e7693ad3f6d
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ = Blog
2
+
3
+ This project rocks and uses MIT-LICENSE.
@@ -0,0 +1,38 @@
1
+ #encoding: utf-8
2
+
3
+ # setup bundler
4
+ begin
5
+ require 'bundler/setup'
6
+ rescue LoadError
7
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
8
+ end
9
+
10
+ Bundler::GemHelper.install_tasks
11
+
12
+ #setup rdoc
13
+
14
+ begin
15
+ require 'rdoc/task'
16
+ rescue LoadError
17
+ require 'rdoc/rdoc'
18
+ require 'rake/rdoctask'
19
+ RDoc::Task = Rake::RDocTask
20
+ end
21
+
22
+ RDoc::Task.new(:rdoc) do |rdoc|
23
+ rdoc.rdoc_dir = 'rdoc'
24
+ rdoc.title = 'Gluttonberg-blog'
25
+ rdoc.options << '--line-numbers'
26
+ rdoc.rdoc_files.include('README.rdoc')
27
+ rdoc.rdoc_files.include('lib/**/*.rb')
28
+ end
29
+
30
+ # setup dummy app and rspec
31
+
32
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
33
+ load 'rails/tasks/engine.rake'
34
+ require 'rspec/core/rake_task'
35
+ RSpec::Core::RakeTask.new(:spec)
36
+
37
+ # RSpec as default
38
+ task :default => :spec
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,6 @@
1
+ module Gluttonberg
2
+ module Blog
3
+ class ApplicationController < ActionController::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,168 @@
1
+ # encoding: utf-8
2
+
3
+ module Gluttonberg
4
+ module Admin
5
+ module Blog
6
+ class ArticlesController < Gluttonberg::Admin::BaseController
7
+ before_filter :find_blog , :except => [:create]
8
+ before_filter :find_article, :only => [:show, :edit, :update, :delete, :destroy , :duplicate]
9
+ before_filter :authorize_user , :except => [:destroy , :delete]
10
+ before_filter :authorize_user_for_destroy , :only => [:destroy , :delete]
11
+ record_history :@article , :title
12
+ before_filter :all_articles, :only => [:index, :export]
13
+
14
+ def index
15
+ @articles = @articles.paginate({
16
+ :per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items"),
17
+ :page => params[:page]
18
+ })
19
+ end
20
+
21
+ def show
22
+ @comment = Gluttonberg::Blog::Comment.new
23
+ end
24
+
25
+ def new
26
+ @article = Gluttonberg::Blog::Article.new
27
+ @article_localization = Gluttonberg::Blog::ArticleLocalization.new(:article => @article , :locale_id => Locale.first_default.id)
28
+ @authors = User.all
29
+ end
30
+
31
+ def create
32
+ params[:gluttonberg_blog_article_localization][:article][:name] = params[:gluttonberg_blog_article_localization][:title]
33
+ article_attributes = params["gluttonberg_blog_article_localization"].delete(:article)
34
+ @article = Gluttonberg::Blog::Article.new(article_attributes)
35
+ if @article.save
36
+ @article.create_localizations(params["gluttonberg_blog_article_localization"])
37
+ flash[:notice] = "The article was successfully created."
38
+ redirect_to edit_admin_blog_article_path(@article.blog, @article)
39
+ else
40
+ render :edit
41
+ end
42
+ end
43
+
44
+ def edit
45
+ @authors = User.all
46
+ unless params[:version].blank?
47
+ @version = params[:version]
48
+ @article_localization.revert_to(@version)
49
+ end
50
+ end
51
+
52
+ def update
53
+ article_attributes = params["gluttonberg_blog_article_localization"].delete(:article)
54
+ @article_localization.article.assign_attributes(article_attributes)
55
+ @article_localization.current_user_id = current_user.id
56
+ @article_localization.updated_at = Time.now
57
+
58
+ if @article_localization.update_attributes(params[:gluttonberg_blog_article_localization])
59
+ @article_localization.article.save
60
+ _log_article_changes
61
+
62
+ flash[:notice] = "The article was successfully updated."
63
+ redirect_to edit_admin_blog_article_path(@article.blog, @article) + (@article_localization.reload && @article_localization.versions.latest.version != @article_localization.version ? "?version=#{@article_localization.versions.latest.version}" : "")
64
+ else
65
+ flash[:error] = "Sorry, The article could not be updated."
66
+ render :edit
67
+ end
68
+ end
69
+
70
+ def delete
71
+ display_delete_confirmation(
72
+ :title => "Delete Article '#{@article.title}'?",
73
+ :url => admin_blog_article_path(@blog, @article),
74
+ :return_url => admin_blog_articles_path(@blog),
75
+ :warning => ""
76
+ )
77
+ end
78
+
79
+ def destroy
80
+ @article.current_localization
81
+ generic_destroy(@article, {
82
+ :name => "article",
83
+ :success_path => admin_blog_articles_path(@blog),
84
+ :failure_path => admin_blog_articles_path(@blog)
85
+ })
86
+ end
87
+
88
+ def duplicate
89
+ @duplicated_article = @article.duplicate
90
+ @duplicated_article.user_id = current_user.id
91
+ if @duplicated_article
92
+ flash[:notice] = "The article was successfully duplicated."
93
+ redirect_to edit_admin_blog_article_path(@blog, @duplicated_article)
94
+ else
95
+ flash[:error] = "There was an error duplicating the article."
96
+ redirect_to admin_blog_articles_path(@blog)
97
+ end
98
+ end
99
+
100
+ def import
101
+ unless params[:csv].blank?
102
+ @feedback = Gluttonberg::Blog::Article.importCSV(params[:csv].tempfile.path, {
103
+ :additional_attributes => {
104
+ :blog_id => @blog.id,
105
+ :author_id => current_user.id,
106
+ :user_id => current_user.id
107
+ }
108
+ })
109
+ if @feedback == true
110
+ flash[:notice] = "All contacts were successfully imported."
111
+ redirect_to admin_blog_articles_path(@blog)
112
+ end
113
+ end
114
+ end
115
+
116
+ def export
117
+ csv_data = Gluttonberg::Blog::Article.exportCSV(@articles.all)
118
+ unless csv_data.blank?
119
+ send_data csv_data, :type => 'text/csv; charset=utf-8' , :disposition => 'attachment' , :filename => "#{@blog.name} posts at #{Time.now.strftime('%Y-%m-%d')}.csv"
120
+ end
121
+ end
122
+
123
+ protected
124
+
125
+ def find_blog
126
+ @blog = Gluttonberg::Blog::Weblog.where(:id => params[:blog_id]).first
127
+ authorize! :manage_object, @blog
128
+ end
129
+
130
+ def find_article
131
+ @article = Gluttonberg::Blog::Article.where(:id => params[:id]).first
132
+ if params[:localization_id].blank?
133
+ conditions = { :article_id => params[:id] , :locale_id => Gluttonberg::Locale.first_default.id}
134
+ @article_localization = Gluttonberg::Blog::ArticleLocalization.where(conditions).first
135
+ else
136
+ @article_localization = Gluttonberg::Blog::ArticleLocalization.where(:id => params[:localization_id]).first
137
+ end
138
+ @article.instance_variable_set(:@current_localization, @article_localization)
139
+ @article
140
+ end
141
+
142
+ def authorize_user
143
+ authorize! :manage, Gluttonberg::Blog::Article
144
+ end
145
+
146
+ def authorize_user_for_destroy
147
+ authorize! :destroy, Gluttonberg::Blog::Article
148
+ end
149
+
150
+ def _log_article_changes
151
+ localization_detail = ""
152
+ if Gluttonberg.localized?
153
+ localization_detail = " (#{@article_localization.locale.slug}) "
154
+ end
155
+ if Gluttonberg.localized?
156
+ Gluttonberg::Feed.log(current_user,@article_localization,"#{@article_localization.title}#{localization_detail}" , "updated")
157
+ end
158
+ end
159
+
160
+ def all_articles
161
+ conditions = {:blog_id => params[:blog_id]}
162
+ @articles = Gluttonberg::Blog::Article.where(conditions).includes(:localizations).order("created_at DESC")
163
+ end
164
+
165
+ end
166
+ end
167
+ end
168
+ end
@@ -0,0 +1,95 @@
1
+ # encoding: utf-8
2
+
3
+ module Gluttonberg
4
+ module Admin
5
+ module Blog
6
+ class BlogsController < Gluttonberg::Admin::BaseController
7
+ before_filter :find_blog, :only => [:show, :edit, :update, :delete, :destroy]
8
+ before_filter :require_super_admin_user , :except => [:index]
9
+ before_filter :authorize_user , :except => [:destroy , :delete]
10
+ before_filter :authorize_user_for_destroy , :only => [:destroy , :delete]
11
+ record_history :@blog
12
+
13
+ def index
14
+ @blogs = Gluttonberg::Blog::Weblog.all
15
+ @blogs = @blogs.find_all{|blog| can?(:manage_object, blog) }
16
+ if @blogs && @blogs.size == 1
17
+ redirect_to admin_blog_articles_path(@blogs.first)
18
+ end
19
+ @blogs = @blogs.paginate(:per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items"), :page => params[:page])
20
+ end
21
+
22
+ def show
23
+ if @blog
24
+ redirect_to admin_blog_articles_path(@blog)
25
+ else
26
+ redirect_to admin_blog_path
27
+ end
28
+ end
29
+
30
+ def new
31
+ @blog = Gluttonberg::Blog::Weblog.new
32
+ end
33
+
34
+ def create
35
+ @blog = Gluttonberg::Blog::Weblog.new(params[:gluttonberg_blog_weblog])
36
+ @blog.current_user_id = current_user.id
37
+ generic_create(@blog, {
38
+ :name => "blog",
39
+ :success_path => admin_blogs_path
40
+ })
41
+ end
42
+
43
+ def edit
44
+ unless params[:version].blank?
45
+ @version = params[:version]
46
+ @blog.revert_to(@version)
47
+ end
48
+ end
49
+
50
+ def update
51
+ @blog.assign_attributes(params[:gluttonberg_blog_weblog])
52
+ @blog.current_user_id = current_user.id
53
+ generic_update(@blog, {
54
+ :name => "blog",
55
+ :success_path => admin_blogs_path
56
+ })
57
+ end
58
+
59
+ def delete
60
+ display_delete_confirmation(
61
+ :title => "Delete Blog '#{@blog.name}'?",
62
+ :url => admin_blog_path(@blog),
63
+ :return_url => admin_blogs_path,
64
+ :warning => "This will delete all the articles that belong to this blog"
65
+ )
66
+ end
67
+
68
+ def destroy
69
+ generic_destroy(@blog, {
70
+ :name => "blog",
71
+ :success_path => admin_blogs_path,
72
+ :failure_path => admin_blogs_path
73
+ })
74
+ end
75
+
76
+
77
+ protected
78
+
79
+ def find_blog
80
+ @blog = Gluttonberg::Blog::Weblog.where(:id => params[:id]).first
81
+ authorize! :manage_object, @blog
82
+ end
83
+
84
+ def authorize_user
85
+ authorize! :manage, Gluttonberg::Blog::Weblog
86
+ end
87
+
88
+ def authorize_user_for_destroy
89
+ authorize! :destroy, Gluttonberg::Blog::Weblog
90
+ end
91
+
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,117 @@
1
+ # encoding: utf-8
2
+
3
+ module Gluttonberg
4
+ module Admin
5
+ module Blog
6
+ class CommentsController < Gluttonberg::Admin::BaseController
7
+ include ActionView::Helpers::TextHelper
8
+ before_filter :find_blog , :except => [:all , :approved, :rejected , :pending , :spam , :moderation , :delete , :destroy , :spam_detection_for_all_pending , :block_author]
9
+ before_filter :find_article , :except => [:index, :all , :approved , :rejected , :pending , :spam , :moderation , :delete , :destroy , :spam_detection_for_all_pending , :block_author]
10
+ before_filter :authorize_user , :except => [:moderation]
11
+
12
+
13
+ def index
14
+ find_article([:comments])
15
+ @comments = @article.comments.order("created_at DESC").paginate(:per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items"), :page => params[:page] , :order => "created_at DESC")
16
+ end
17
+
18
+ def delete
19
+ @comment = Gluttonberg::Blog::Comment.where(:id => params[:id]).first
20
+ display_delete_confirmation(
21
+ :title => "Delete Comment ?",
22
+ :url => admin_comments_destroy_path(@comment),
23
+ :return_url => :back,
24
+ :warning => ""
25
+ )
26
+ end
27
+
28
+ def moderation
29
+ authorize_user_for_moderation
30
+ @comment = Gluttonberg::Blog::Comment.where(:id => params[:id]).first
31
+ @comment.moderate(params[:moderation])
32
+ Gluttonberg::Feed.log(current_user,@comment, truncate(@comment.body, :length => 100) , params[:moderation])
33
+ redirect_to :back
34
+ end
35
+
36
+ def destroy
37
+ @comment = Gluttonberg::Blog::Comment.where(:id => params[:id]).first
38
+ if @comment.delete
39
+ flash[:notice] = "The comment was successfully deleted."
40
+ Gluttonberg::Feed.log(current_user,@comment, truncate(@comment.body, :length => 100) , "deleted")
41
+ redirect_to admin_comments_pending_path
42
+ else
43
+ flash[:error] = "There was an error deleting the comment."
44
+ redirect_to admin_comments_pending_path
45
+ end
46
+ end
47
+
48
+
49
+ def pending
50
+ @comments = ordering_and_pagination(Gluttonberg::Blog::Comment.all_pending)
51
+ render_comments_list
52
+ end
53
+
54
+ def approved
55
+ @comments = ordering_and_pagination(Gluttonberg::Blog::Comment.all_approved)
56
+ render_comments_list
57
+ end
58
+
59
+ def rejected
60
+ @comments = ordering_and_pagination(Gluttonberg::Blog::Comment.all_rejected)
61
+ render_comments_list
62
+ end
63
+
64
+ def spam
65
+ @comments = ordering_and_pagination(Gluttonberg::Blog::Comment.all_spam)
66
+ render_comments_list
67
+ end
68
+
69
+ def spam_detection_for_all_pending
70
+ Gluttonberg::Blog::Comment.spam_detection_for_all
71
+ redirect_to admin_comments_pending_path
72
+ end
73
+
74
+ def block_author
75
+ @comment = Gluttonberg::Blog::Comment.where(:id => params[:id]).first
76
+ @comment.black_list_author
77
+ redirect_to admin_comments_pending_path
78
+ end
79
+
80
+
81
+
82
+ protected
83
+
84
+ def find_blog
85
+ @blog = Gluttonberg::Blog::Weblog.where(:id => params[:blog_id]).first
86
+ raise ActiveRecord::RecordNotFound unless @blog
87
+ end
88
+
89
+ def find_article(include_model=[])
90
+ conditions = { :id => params[:article_id] }
91
+ conditions[:user_id] = current_user.id unless current_user.super_admin?
92
+ @article = Gluttonberg::Blog::Article.where(conditions).includes(include_model).first
93
+ raise ActiveRecord::RecordNotFound unless @article
94
+ end
95
+
96
+ def authorize_user
97
+ authorize! :manage, Gluttonberg::Blog::Comment
98
+ end
99
+
100
+ def authorize_user_for_moderation
101
+ authorize! :moderate, Gluttonberg::Blog::Comment
102
+ end
103
+
104
+ def ordering_and_pagination(comments)
105
+ comments.order("created_at DESC").paginate({
106
+ :per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items"),
107
+ :page => params[:page]
108
+ })
109
+ end
110
+
111
+ def render_comments_list
112
+ render :template => "/gluttonberg/admin/blog/comments/index"
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end