gluttonberg-core 2.5.5 → 2.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/gb_application.js +34 -0
- data/app/assets/stylesheets/gb_admin-override.sass +17 -1
- data/app/controllers/gluttonberg/admin/asset_library/assets_controller.rb +4 -2
- data/app/controllers/gluttonberg/admin/content/articles_controller.rb +22 -22
- data/app/controllers/gluttonberg/admin/content/comments_controller.rb +80 -23
- data/app/controllers/gluttonberg/admin/main_controller.rb +1 -1
- data/app/controllers/gluttonberg/public/comments_controller.rb +9 -8
- data/app/helpers/gluttonberg/admin.rb +3 -3
- data/app/helpers/gluttonberg/asset_library.rb +14 -11
- data/app/models/gluttonberg/asset.rb +8 -6
- data/app/models/gluttonberg/comment.rb +57 -3
- data/app/models/gluttonberg/comment_subscription.rb +2 -0
- data/app/models/gluttonberg/setting.rb +11 -5
- data/app/views/gluttonberg/admin/asset_library/assets/_browser_root.html.haml +20 -3
- data/app/views/gluttonberg/admin/asset_library/assets/search.json.haml +1 -1
- data/app/views/gluttonberg/admin/content/comments/index.html.haml +36 -10
- data/app/views/gluttonberg/admin/content/main/_sidebar.html.haml +6 -3
- data/app/views/gluttonberg/admin/main/index.html.haml +4 -4
- data/app/views/gluttonberg/admin/settings/generic_settings/index.html.haml +11 -7
- data/config/routes.rb +10 -0
- data/db/migrate/20130201025800_spam_flag_for_comments.rb +6 -0
- data/lib/engine.rb +3 -2
- data/lib/generators/gluttonberg/installer/installer_generator.rb +33 -32
- data/lib/gluttonberg/content/block.rb +2 -0
- data/lib/gluttonberg/content/clean_html.rb +16 -14
- data/lib/gluttonberg/content/despamilator/conf/unusual_characters.txt +6674 -0
- data/lib/gluttonberg/content/despamilator/filter/emails.rb +49 -0
- data/lib/gluttonberg/content/despamilator/filter/gtubs_test_filter.rb +25 -0
- data/lib/gluttonberg/content/despamilator/filter/html_tags.rb +134 -0
- data/lib/gluttonberg/content/despamilator/filter/ip_address_url.rb +27 -0
- data/lib/gluttonberg/content/despamilator/filter/long_words.rb +29 -0
- data/lib/gluttonberg/content/despamilator/filter/mixed_case.rb +25 -0
- data/lib/gluttonberg/content/despamilator/filter/naughty_words.rb +80 -0
- data/lib/gluttonberg/content/despamilator/filter/no_vowels.rb +28 -0
- data/lib/gluttonberg/content/despamilator/filter/numbers_and_words.rb +55 -0
- data/lib/gluttonberg/content/despamilator/filter/obfuscated_urls.rb +45 -0
- data/lib/gluttonberg/content/despamilator/filter/prices.rb +23 -0
- data/lib/gluttonberg/content/despamilator/filter/script_tag.rb +25 -0
- data/lib/gluttonberg/content/despamilator/filter/shouting.rb +38 -0
- data/lib/gluttonberg/content/despamilator/filter/spammy_tlds.rb +26 -0
- data/lib/gluttonberg/content/despamilator/filter/square_brackets.rb +27 -0
- data/lib/gluttonberg/content/despamilator/filter/trailing_number.rb +25 -0
- data/lib/gluttonberg/content/despamilator/filter/unusual_characters.rb +51 -0
- data/lib/gluttonberg/content/despamilator/filter/urls.rb +45 -0
- data/lib/gluttonberg/content/despamilator/filter/very_long_domain_name.rb +31 -0
- data/lib/gluttonberg/content/despamilator/filter/weird_punctuation.rb +48 -0
- data/lib/gluttonberg/content/despamilator/filter.rb +57 -0
- data/lib/gluttonberg/content/despamilator/subject/text.rb +36 -0
- data/lib/gluttonberg/content/despamilator/subject.rb +34 -0
- data/lib/gluttonberg/content/despamilator/version.rb +7 -0
- data/lib/gluttonberg/content/despamilator.rb +79 -0
- data/lib/gluttonberg/content.rb +12 -11
- data/lib/gluttonberg/library/attachment_mixin.rb +52 -269
- data/lib/gluttonberg/library/config/image_sizes.rb +61 -0
- data/lib/gluttonberg/library/config.rb +10 -0
- data/lib/gluttonberg/library/processor/audio.rb +42 -0
- data/lib/gluttonberg/library/processor/image.rb +134 -0
- data/lib/gluttonberg/library/processor.rb +11 -0
- data/lib/gluttonberg/library/storage/filesystem.rb +76 -0
- data/lib/gluttonberg/library/storage/s3.rb +196 -0
- data/lib/gluttonberg/library/storage.rb +11 -0
- data/lib/gluttonberg/library.rb +87 -86
- data/lib/gluttonberg/record_history.rb +14 -15
- data/lib/gluttonberg/tasks/asset.rake +25 -3
- data/lib/gluttonberg/version.rb +1 -1
- metadata +53 -2
@@ -296,6 +296,20 @@ var AssetBrowser = {
|
|
296
296
|
e.preventDefault();
|
297
297
|
});
|
298
298
|
|
299
|
+
// same height for all elements within same row
|
300
|
+
$.each(AssetBrowser.browser.find(".tab-pane") , function(index , element){
|
301
|
+
AssetBrowser.sameHeightForAllElementsOfSameRow($(element));
|
302
|
+
});
|
303
|
+
|
304
|
+
try{
|
305
|
+
$().collapse({parent: "#accordion_for_collections"});
|
306
|
+
}catch(e){
|
307
|
+
console.log(e);
|
308
|
+
}
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
299
313
|
$("#assetsDialog").css({
|
300
314
|
height: ($(window).height()*0.9) + "px",
|
301
315
|
width: ($(window).width()*0.7) + "px",
|
@@ -322,6 +336,26 @@ var AssetBrowser = {
|
|
322
336
|
|
323
337
|
})
|
324
338
|
},
|
339
|
+
sameHeightForAllElementsOfSameRow: function(parent_element){
|
340
|
+
|
341
|
+
var all_spans = parent_element.find(".thumbnails .span3");
|
342
|
+
var row_num = 1;
|
343
|
+
var ASSET_MAX_COLUMNS = 5;
|
344
|
+
var row_max_height = 0;
|
345
|
+
$.each(all_spans , function(index , element){
|
346
|
+
if($(element).height() > row_max_height){
|
347
|
+
row_max_height = $(element).height();
|
348
|
+
}
|
349
|
+
$(element).attr('data-row' , row_num);
|
350
|
+
if( (index+1) % ASSET_MAX_COLUMNS == 0 ){
|
351
|
+
if(row_max_height > 0){
|
352
|
+
parent_element.find("[data-row="+row_num+"]").height(row_max_height);
|
353
|
+
}
|
354
|
+
row_num++;
|
355
|
+
row_max_height = 0;
|
356
|
+
}
|
357
|
+
});
|
358
|
+
},
|
325
359
|
resizeDisplay: function() {
|
326
360
|
// var newHeight = AssetBrowser.browser.innerHeight() - AssetBrowser.offsetHeight;
|
327
361
|
// AssetBrowser.display.height(newHeight);
|
@@ -491,6 +491,15 @@ legend.collapsed
|
|
491
491
|
-moz-border-radius: 3px 0 0 3px
|
492
492
|
border-radius: 3px 0 0 3px
|
493
493
|
|
494
|
+
span.gap
|
495
|
+
float: left
|
496
|
+
padding: 0 30px
|
497
|
+
line-height: 34px
|
498
|
+
text-decoration: none
|
499
|
+
border: 1px solid #ddd
|
500
|
+
border-left-width: 0
|
501
|
+
font-weight: bold
|
502
|
+
|
494
503
|
|
495
504
|
table
|
496
505
|
thead
|
@@ -570,4 +579,11 @@ table
|
|
570
579
|
:float left
|
571
580
|
|
572
581
|
form .span5 input.span2, form .span5 textarea.span2, form .span5 .uneditable-input.span2
|
573
|
-
width: 130px
|
582
|
+
width: 130px
|
583
|
+
|
584
|
+
.editable
|
585
|
+
:display block
|
586
|
+
:padding-left 20px
|
587
|
+
:background url('/assets/gb_icon_blog.png') no-repeat
|
588
|
+
&:hover
|
589
|
+
:cursor pointer
|
@@ -75,7 +75,6 @@ module Gluttonberg
|
|
75
75
|
end
|
76
76
|
end # category#all
|
77
77
|
page = params[:page].blank? ? 1 : params[:page].to_i
|
78
|
-
puts "----#{Gluttonberg::Setting.get_setting("number_of_per_page_items")} #{page}"
|
79
78
|
@assets = @assets.paginate( :per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items") , :page => page ).order(get_order)
|
80
79
|
end
|
81
80
|
|
@@ -84,7 +83,10 @@ module Gluttonberg
|
|
84
83
|
end
|
85
84
|
|
86
85
|
def destroy_assets_in_bulk
|
87
|
-
@assets = Asset.
|
86
|
+
@assets = Asset.where(:id => params[:asset_ids].split(",")).all
|
87
|
+
@assets.each do |asset|
|
88
|
+
asset.destroy
|
89
|
+
end
|
88
90
|
redirect_to "/admin/browse/all/page/1"
|
89
91
|
end
|
90
92
|
|
@@ -2,32 +2,32 @@
|
|
2
2
|
|
3
3
|
module Gluttonberg
|
4
4
|
module Admin
|
5
|
-
module Content
|
5
|
+
module Content
|
6
6
|
class ArticlesController < Gluttonberg::Admin::BaseController
|
7
|
-
|
7
|
+
|
8
8
|
before_filter :find_blog , :except => [:create]
|
9
9
|
before_filter :find_article, :only => [:show, :edit, :update, :delete, :destroy , :duplicate]
|
10
|
-
before_filter :authorize_user , :except => [:destroy , :delete]
|
11
|
-
before_filter :authorize_user_for_destroy , :only => [:destroy , :delete]
|
10
|
+
before_filter :authorize_user , :except => [:destroy , :delete]
|
11
|
+
before_filter :authorize_user_for_destroy , :only => [:destroy , :delete]
|
12
12
|
record_history :@article , :title
|
13
|
-
|
13
|
+
|
14
14
|
def index
|
15
15
|
conditions = {:blog_id => @blog.id}
|
16
16
|
conditions[:user_id] = current_user.id unless current_user.super_admin?
|
17
|
-
@articles = Article.where( conditions).paginate(:per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items"), :page => params[:page])
|
17
|
+
@articles = Article.where( conditions).order("created_at DESC").paginate(:per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items"), :page => params[:page])
|
18
18
|
end
|
19
|
-
|
20
|
-
|
19
|
+
|
20
|
+
|
21
21
|
def show
|
22
22
|
@comment = Comment.new
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def new
|
26
26
|
@article = Article.new
|
27
27
|
@article_localization = ArticleLocalization.new(:article => @article , :locale_id => Locale.first_default.id)
|
28
28
|
@authors = User.all
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def create
|
32
32
|
params[:gluttonberg_article_localization][:article][:name] = params[:gluttonberg_article_localization][:title]
|
33
33
|
article_attributes = params["gluttonberg_article_localization"].delete(:article)
|
@@ -42,7 +42,7 @@ module Gluttonberg
|
|
42
42
|
render :edit
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
def edit
|
47
47
|
@authors = User.all
|
48
48
|
unless params[:version].blank?
|
@@ -50,7 +50,7 @@ module Gluttonberg
|
|
50
50
|
@article.revert_to(@version)
|
51
51
|
end
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
def update
|
55
55
|
article_attributes = params["gluttonberg_article_localization"].delete(:article)
|
56
56
|
if @article_localization.update_attributes(params[:gluttonberg_article_localization])
|
@@ -59,7 +59,7 @@ module Gluttonberg
|
|
59
59
|
article.assign_attributes(article_attributes)
|
60
60
|
article.previous_slug = article.current_slug if article.slug_changed?
|
61
61
|
article.save
|
62
|
-
|
62
|
+
|
63
63
|
localization_detail = ""
|
64
64
|
if Gluttonberg.localized?
|
65
65
|
localization_detail = " (#{@article_localization.locale.slug}) "
|
@@ -69,22 +69,22 @@ module Gluttonberg
|
|
69
69
|
end
|
70
70
|
|
71
71
|
flash[:notice] = "The article was successfully updated."
|
72
|
-
redirect_to
|
72
|
+
redirect_to edit_admin_blog_article_path(@article.blog, @article)
|
73
73
|
else
|
74
74
|
flash[:error] = "Sorry, The article could not be updated."
|
75
75
|
render :edit
|
76
76
|
end
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
def delete
|
80
80
|
display_delete_confirmation(
|
81
81
|
:title => "Delete Article '#{@article.title}'?",
|
82
82
|
:url => admin_blog_article_path(@blog, @article),
|
83
|
-
:return_url => admin_blog_articles_path(@blog),
|
83
|
+
:return_url => admin_blog_articles_path(@blog),
|
84
84
|
:warning => ""
|
85
85
|
)
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
def destroy
|
89
89
|
title = @article.current_localization.title
|
90
90
|
if @article.destroy
|
@@ -107,13 +107,13 @@ module Gluttonberg
|
|
107
107
|
redirect_to admin_blog_articles_path(@blog)
|
108
108
|
end
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
protected
|
112
|
-
|
112
|
+
|
113
113
|
def find_blog
|
114
114
|
@blog = Blog.find(params[:blog_id])
|
115
115
|
end
|
116
|
-
|
116
|
+
|
117
117
|
def find_article
|
118
118
|
if params[:localization_id].blank?
|
119
119
|
conditions = { :article_id => params[:id] , :locale_id => Locale.first_default.id}
|
@@ -124,7 +124,7 @@ module Gluttonberg
|
|
124
124
|
end
|
125
125
|
@article = Article.find(:first , :conditions => {:id => params[:id]})
|
126
126
|
end
|
127
|
-
|
127
|
+
|
128
128
|
def authorize_user
|
129
129
|
authorize! :manage, Gluttonberg::Article
|
130
130
|
end
|
@@ -132,7 +132,7 @@ module Gluttonberg
|
|
132
132
|
def authorize_user_for_destroy
|
133
133
|
authorize! :destroy, Gluttonberg::Article
|
134
134
|
end
|
135
|
-
|
135
|
+
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|
@@ -2,68 +2,125 @@
|
|
2
2
|
|
3
3
|
module Gluttonberg
|
4
4
|
module Admin
|
5
|
-
module Content
|
5
|
+
module Content
|
6
6
|
class CommentsController < Gluttonberg::Admin::BaseController
|
7
7
|
include ActionView::Helpers::TextHelper
|
8
|
-
|
9
|
-
before_filter :find_blog
|
10
|
-
before_filter :find_article , :except => [:index]
|
8
|
+
|
9
|
+
before_filter :find_blog , :except => [:all , :approved, :rejected , :pending , :spam , :moderation , :delete , :destroy , :spam_detection_for_all_pending , :block_comment_author]
|
10
|
+
before_filter :find_article , :except => [:index, :all , :approved , :rejected , :pending , :spam , :moderation , :delete , :destroy , :spam_detection_for_all_pending , :block_comment_author]
|
11
11
|
before_filter :authorize_user , :except => [:moderation]
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
|
14
14
|
def index
|
15
15
|
find_article([:comments])
|
16
|
-
@comments = @article.comments.paginate(:per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items"), :page => params[:page])
|
16
|
+
@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")
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def delete
|
20
|
-
@comment = Comment.find(params[:id]
|
20
|
+
@comment = Comment.find(params[:id])
|
21
21
|
display_delete_confirmation(
|
22
22
|
:title => "Delete Comment ?",
|
23
|
-
:url =>
|
24
|
-
:return_url =>
|
23
|
+
:url => admin_comment_destroy_path(@comment),
|
24
|
+
:return_url => :back,
|
25
25
|
:warning => ""
|
26
26
|
)
|
27
27
|
end
|
28
|
-
|
29
|
-
def moderation
|
28
|
+
|
29
|
+
def moderation
|
30
30
|
authorize_user_for_moderation
|
31
|
-
@comment = Comment.find(params[:id]
|
31
|
+
@comment = Comment.find(params[:id])
|
32
32
|
@comment.moderate(params[:moderation])
|
33
33
|
Gluttonberg::Feed.log(current_user,@comment, truncate(@comment.body, :length => 100) , params[:moderation])
|
34
|
-
redirect_to
|
34
|
+
redirect_to :back
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def destroy
|
38
38
|
@comment = Comment.find(params[:id])
|
39
39
|
if @comment.delete
|
40
40
|
flash[:notice] = "The comment was successfully deleted."
|
41
41
|
Gluttonberg::Feed.log(current_user,@comment, truncate(@comment.body, :length => 100) , "deleted")
|
42
|
-
redirect_to
|
42
|
+
redirect_to admin_pending_comments_path()
|
43
43
|
else
|
44
44
|
flash[:error] = "There was an error deleting the comment."
|
45
|
-
redirect_to
|
45
|
+
redirect_to admin_pending_comments_path()
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def pending
|
51
|
+
@comments = Comment.all_pending.order("created_at DESC").paginate(:per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items"), :page => params[:page] , :order => "created_at DESC")
|
52
|
+
render :template => "/gluttonberg/admin/content/comments/index"
|
53
|
+
end
|
54
|
+
|
55
|
+
def approved
|
56
|
+
@comments = Comment.all_approved.order("created_at DESC").paginate(:per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items"), :page => params[:page] , :order => "created_at DESC")
|
57
|
+
render :template => "/gluttonberg/admin/content/comments/index"
|
58
|
+
end
|
59
|
+
|
60
|
+
def rejected
|
61
|
+
@comments = Comment.all_rejected.order("created_at DESC").paginate(:per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items"), :page => params[:page] , :order => "created_at DESC")
|
62
|
+
render :template => "/gluttonberg/admin/content/comments/index"
|
63
|
+
end
|
64
|
+
|
65
|
+
def spam
|
66
|
+
@comments = Comment.all_spam.order("created_at DESC").paginate(:per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items"), :page => params[:page] , :order => "created_at DESC")
|
67
|
+
render :template => "/gluttonberg/admin/content/comments/index"
|
68
|
+
end
|
69
|
+
|
70
|
+
def spam_detection_for_all_pending
|
71
|
+
Comment.spam_detection_for_all
|
72
|
+
redirect_to admin_pending_comments_path
|
73
|
+
end
|
74
|
+
|
75
|
+
def block_comment_author
|
76
|
+
@comment = Comment.find(params[:id])
|
77
|
+
|
78
|
+
author_string = ""
|
79
|
+
unless @comment.author_name.blank? || @comment.author_name == "NULL" || @comment.author_name.length < 3
|
80
|
+
author_string += @comment.author_name
|
81
|
+
end
|
82
|
+
unless @comment.author_email.blank? || @comment.author_email == "NULL" || @comment.author_email.length < 3
|
83
|
+
author_string += ", " unless author_string.blank?
|
84
|
+
author_string += @comment.author_email
|
85
|
+
end
|
86
|
+
unless @comment.author_website.blank? || @comment.author_website == "NULL" || @comment.author_website.length < 3
|
87
|
+
author_string += ", " unless author_string.blank?
|
88
|
+
author_string += @comment.author_website
|
46
89
|
end
|
90
|
+
unless author_string.blank?
|
91
|
+
author_string
|
92
|
+
gb_blacklist_settings = Gluttonberg::Setting.get_setting("comment_blacklist")
|
93
|
+
if gb_blacklist_settings.blank?
|
94
|
+
gb_blacklist_settings = author_string
|
95
|
+
else
|
96
|
+
gb_blacklist_settings = gb_blacklist_settings + ", " + author_string
|
97
|
+
end
|
98
|
+
Gluttonberg::Setting.update_settings("comment_blacklist" => gb_blacklist_settings)
|
99
|
+
Comment.spam_detection_for_all
|
100
|
+
end
|
101
|
+
redirect_to admin_pending_comments_path
|
47
102
|
end
|
48
|
-
|
103
|
+
|
104
|
+
|
105
|
+
|
49
106
|
protected
|
50
|
-
|
107
|
+
|
51
108
|
def find_blog
|
52
109
|
@blog = Blog.find(params[:blog_id])
|
53
110
|
raise ActiveRecord::RecordNotFound unless @blog
|
54
111
|
end
|
55
|
-
|
112
|
+
|
56
113
|
def find_article(include_model=[])
|
57
114
|
conditions = { :id => params[:article_id] }
|
58
115
|
conditions[:user_id] = current_user.id unless current_user.super_admin?
|
59
116
|
@article = Article.find(:first , :conditions => conditions , :include => include_model )
|
60
117
|
raise ActiveRecord::RecordNotFound unless @article
|
61
118
|
end
|
62
|
-
|
119
|
+
|
63
120
|
def authorize_user
|
64
121
|
authorize! :manage, Gluttonberg::Comment
|
65
122
|
end
|
66
|
-
|
123
|
+
|
67
124
|
def authorize_user_for_moderation
|
68
125
|
authorize! :moderate, Gluttonberg::Comment
|
69
126
|
end
|
@@ -16,7 +16,7 @@ module Gluttonberg
|
|
16
16
|
end
|
17
17
|
|
18
18
|
if Comment.table_exists?
|
19
|
-
@comments = Comment.
|
19
|
+
@comments = Comment.all_pending.where({:commentable_type => "Gluttonberg::Article" , :moderation_required => true }).order("created_at DESC").limit(5)
|
20
20
|
@article = Article.new
|
21
21
|
@article_localization = ArticleLocalization.new(:article => @article , :locale_id => Locale.first_default.id)
|
22
22
|
@blogs = Gluttonberg::Blog.all
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module Gluttonberg
|
2
2
|
module Public
|
3
3
|
class CommentsController < Gluttonberg::Public::BaseController
|
4
|
-
|
4
|
+
|
5
5
|
def create
|
6
6
|
@blog = Gluttonberg::Blog.first(:conditions => {:slug => params[:blog_id]})
|
7
7
|
@article = Gluttonberg::Article.first(:conditions => {:slug => params[:article_id], :blog_id => @blog.id})
|
8
|
-
@comment = @article.comments.new(params[:comment]
|
8
|
+
@comment = @article.comments.new(params[:comment])
|
9
|
+
@comment.blog_slug = params[:blog_id]
|
9
10
|
@comment.author_id = current_member.id if current_member
|
10
11
|
if @comment.save
|
11
12
|
if Setting.get_setting("comment_notification") == "Yes" || @blog.moderation_required == true
|
@@ -13,16 +14,16 @@ module Gluttonberg
|
|
13
14
|
Notifier.comment_notification_for_admin(user , @article , @comment).deliver
|
14
15
|
end
|
15
16
|
end
|
16
|
-
|
17
|
+
|
17
18
|
@subscription = CommentSubscription.find(:first , :conditions => {:article_id => @article.id , :author_email => @comment.writer_email })
|
18
19
|
if @comment.subscribe_to_comments == "1" && @subscription.blank?
|
19
20
|
@subscription = CommentSubscription.create( {:article_id => @article.id , :author_email => @comment.writer_email , :author_name => @comment.writer_name } )
|
20
21
|
elsif (@comment.subscribe_to_comments.blank? || @comment.subscribe_to_comments == "0") && !@subscription.blank?
|
21
22
|
#unsubscribe
|
22
|
-
@subscription.destroy
|
23
|
+
@subscription.destroy
|
23
24
|
end
|
24
25
|
else
|
25
|
-
|
26
|
+
|
26
27
|
end
|
27
28
|
if Gluttonberg.localized?
|
28
29
|
redirect_to blog_article_path(current_localization_slug , @blog.slug, @article.slug)
|
@@ -30,8 +31,8 @@ module Gluttonberg
|
|
30
31
|
redirect_to blog_article_path(:blog_id => @blog.slug, :id => @article.slug)
|
31
32
|
end
|
32
33
|
end
|
33
|
-
|
34
|
-
private
|
34
|
+
|
35
|
+
private
|
35
36
|
def current_localization_slug
|
36
37
|
if @locale
|
37
38
|
@locale.slug
|
@@ -40,6 +41,6 @@ module Gluttonberg
|
|
40
41
|
end
|
41
42
|
end
|
42
43
|
end
|
43
|
-
|
44
|
+
|
44
45
|
end
|
45
46
|
end
|
@@ -136,7 +136,7 @@ module Gluttonberg
|
|
136
136
|
def nav_link(*args)
|
137
137
|
class_names = "button"
|
138
138
|
class_names = "#{class_names} #{args[2][:class]}" if args.length >= 3
|
139
|
-
content_tag(:li,
|
139
|
+
content_tag(:li, active_link_to(args[0] , args[1] , :title => args[0]), :class => class_names)
|
140
140
|
end
|
141
141
|
|
142
142
|
# Writes out the back control for the sub nav.
|
@@ -279,7 +279,7 @@ module Gluttonberg
|
|
279
279
|
|
280
280
|
|
281
281
|
def honeypot_field_tag
|
282
|
-
html = label_tag(Rails.configuration.honeypot_field_name ,
|
282
|
+
html = label_tag(Rails.configuration.honeypot_field_name , Rails.configuration.honeypot_field_name.humanize )
|
283
283
|
html << text_field_tag( Rails.configuration.honeypot_field_name )
|
284
284
|
content_tag :div , html , :class => Rails.configuration.honeypot_field_name , :style => "display:none"
|
285
285
|
end
|
@@ -350,7 +350,7 @@ module Gluttonberg
|
|
350
350
|
height : '20px',
|
351
351
|
cancel : 'Cancel',
|
352
352
|
submit : 'OK',
|
353
|
-
indicator : '#{image_tag('/assets/
|
353
|
+
indicator : '#{image_tag('/assets/gb_spinner.gif')}'
|
354
354
|
};
|
355
355
|
$.extend(args, #{args.to_json});
|
356
356
|
$(".editable[data-id='#{object.id}'][data-name='#{name}']").editable("#{update_url}", args);
|
@@ -1,20 +1,23 @@
|
|
1
1
|
module Gluttonberg
|
2
2
|
module AssetLibrary
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
# nice and clean public url of assets
|
5
|
+
def asset_url(asset , opts = {})
|
6
|
+
url = ""
|
7
|
+
if Rails.configuration.asset_storage == :s3
|
8
|
+
url = asset.url
|
9
|
+
else
|
10
|
+
if Rails.env=="development"
|
8
11
|
url = "http://#{request.host}:#{request.port}/user_asset/#{asset.asset_hash[0..3]}/#{asset.id}"
|
9
|
-
|
12
|
+
else
|
10
13
|
url = "http://#{request.host}/user_asset/#{asset.asset_hash[0..3]}/#{asset.id}"
|
11
|
-
|
14
|
+
end
|
12
15
|
|
13
|
-
|
16
|
+
if opts[:thumb_name]
|
14
17
|
url << "/#{opts[:thumb_name]}"
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
+
end
|
19
|
+
end
|
20
|
+
url
|
18
21
|
end
|
19
22
|
|
20
23
|
|
@@ -134,7 +137,7 @@ module Gluttonberg
|
|
134
137
|
end
|
135
138
|
|
136
139
|
def asset_panel(assets, name_or_id , type )
|
137
|
-
render :partial => "gluttonberg/admin/shared/asset_panel
|
140
|
+
render :partial => "/gluttonberg/admin/shared/asset_panel" , :locals => {:assets => assets , :name_or_id => name_or_id , :type => type} , :formats => [:html]
|
138
141
|
end
|
139
142
|
|
140
143
|
|
@@ -4,7 +4,7 @@ module Gluttonberg
|
|
4
4
|
has_many :set_elements, :as => :element
|
5
5
|
has_many :asset_thumbnails
|
6
6
|
|
7
|
-
after_save :update_file
|
7
|
+
#after_save :update_file
|
8
8
|
before_validation :set_category_and_type
|
9
9
|
|
10
10
|
acts_as_taggable_on :locations , :characters , :themes, :photographers
|
@@ -27,6 +27,8 @@ module Gluttonberg
|
|
27
27
|
attr_accessible :description, :synopsis, :copyrights, :year_of_production, :duration
|
28
28
|
attr_accessible :artist_name, :link, :width, :height, :alt , :processed, :copied_to_s3
|
29
29
|
|
30
|
+
attr_accessor :type
|
31
|
+
|
30
32
|
# constants for formatted file size
|
31
33
|
GIGA_SIZE = 1073741824.0
|
32
34
|
MEGA_SIZE = 1048576.0
|
@@ -78,9 +80,9 @@ module Gluttonberg
|
|
78
80
|
self.asset_type = AssetType.for_file(mime_type, file_name)
|
79
81
|
cat = self.category.to_s.downcase
|
80
82
|
if cat == "image"
|
81
|
-
self
|
83
|
+
self.type = "Photo"
|
82
84
|
elsif cat == "video"
|
83
|
-
self
|
85
|
+
self.type = "Video"
|
84
86
|
end
|
85
87
|
end
|
86
88
|
|
@@ -165,9 +167,9 @@ module Gluttonberg
|
|
165
167
|
private
|
166
168
|
|
167
169
|
# make a new asset folder if not exist. then make backup of asset. generate thumbnails
|
168
|
-
def update_file
|
169
|
-
|
170
|
-
end
|
170
|
+
# def update_file
|
171
|
+
# update_file_on_disk
|
172
|
+
# end
|
171
173
|
|
172
174
|
|
173
175
|
end
|
@@ -9,11 +9,15 @@ module Gluttonberg
|
|
9
9
|
belongs_to :author, :class_name => "Gluttonberg::Member"
|
10
10
|
|
11
11
|
before_save :init_moderation
|
12
|
+
before_validation :spam_detection
|
12
13
|
after_save :send_notifications_if_needed
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
scope :
|
15
|
+
validates_presence_of :body
|
16
|
+
|
17
|
+
scope :all_approved, :conditions => ["approved = ? AND ( spam = ? OR spam IS NULL)",true , false]
|
18
|
+
scope :all_pending, :conditions => ["moderation_required = ? AND ( spam = ? OR spam IS NULL)",true , false]
|
19
|
+
scope :all_rejected, :conditions => ["moderation_required = ? AND approved = ? AND ( spam = ? OR spam IS NULL)",false , false , false]
|
20
|
+
scope :all_spam, :conditions => { :spam => true }
|
17
21
|
|
18
22
|
attr_accessor :subscribe_to_comments , :blog_slug
|
19
23
|
attr_accessible :body , :author_name , :author_email , :author_website , :commentable_id , :commentable_type , :author_id
|
@@ -26,6 +30,7 @@ module Gluttonberg
|
|
26
30
|
if params == "approve"
|
27
31
|
self.moderation_required = false
|
28
32
|
self.approved = true
|
33
|
+
self.spam = false
|
29
34
|
self.save
|
30
35
|
elsif params == "disapprove"
|
31
36
|
self.moderation_required = false
|
@@ -36,6 +41,27 @@ module Gluttonberg
|
|
36
41
|
end
|
37
42
|
end
|
38
43
|
|
44
|
+
def self.all_comments_count
|
45
|
+
self.count
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.approved_comments_count
|
49
|
+
self.all_approved.count
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.rejected_comments_count
|
53
|
+
self.all_rejected.count
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.pending_comments_count
|
57
|
+
self.all_pending.count
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.spam_comments_count
|
61
|
+
self.all_spam.count
|
62
|
+
end
|
63
|
+
|
64
|
+
|
39
65
|
def user_id
|
40
66
|
self.author_id
|
41
67
|
end
|
@@ -66,6 +92,13 @@ module Gluttonberg
|
|
66
92
|
write_attribute(:approved, val)
|
67
93
|
end
|
68
94
|
|
95
|
+
def self.spam_detection_for_all
|
96
|
+
self.all_pending.each do |c|
|
97
|
+
c.send("spam_detection")
|
98
|
+
c.save(:validate => false)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
69
102
|
protected
|
70
103
|
def init_moderation
|
71
104
|
if self.commentable.respond_to?(:moderation_required)
|
@@ -84,5 +117,26 @@ module Gluttonberg
|
|
84
117
|
end
|
85
118
|
end
|
86
119
|
|
120
|
+
def spam_detection
|
121
|
+
unless self.body.blank?
|
122
|
+
dspam = Gluttonberg::Content::Despamilator.new(self.body)
|
123
|
+
self.spam = (dspam.score >= 1.0)
|
124
|
+
self.spam_score = dspam.score
|
125
|
+
unless self.spam
|
126
|
+
naughty_word_parser = Gluttonberg::Content::DespamilatorFilter::NaughtyWords.new
|
127
|
+
if !self.author_email.blank? && naughty_word_parser.local_parse(self.author_email) >= 1.0
|
128
|
+
self.spam = true
|
129
|
+
elsif !self.author_name.blank? && naughty_word_parser.local_parse(self.author_name) >= 1.0
|
130
|
+
self.spam = true
|
131
|
+
elsif !self.author_website.blank? && naughty_word_parser.local_parse(self.author_website) >= 1.0
|
132
|
+
self.spam = true
|
133
|
+
end
|
134
|
+
end
|
135
|
+
else
|
136
|
+
self.spam = true
|
137
|
+
self.spam_score = 1.0
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
87
141
|
end
|
88
142
|
end
|
@@ -5,6 +5,8 @@ module Gluttonberg
|
|
5
5
|
before_save :generate_reference_hash
|
6
6
|
belongs_to :article
|
7
7
|
|
8
|
+
attr_accessible :article_id , :author_email , :author_name
|
9
|
+
|
8
10
|
def self.notify_subscribers_of(article , comment)
|
9
11
|
subscribers = self.find(:all , :conditions => {:article_id => article.id})
|
10
12
|
subscribers.each do |subscriber|
|