public
Description: The kick ass (non-commercial) home for musicians and their music
Homepage: http://alonetone.com
Clone URL: git://github.com/sudara/alonetone.git
allow the browsing of spam and explicit marking of spam as well as 
un-spamming comments
sudara (author)
Wed Jul 09 03:30:50 -0700 2008
commit  d3cfdfbb17ae4ee873a33377ac4fac89347f861c
tree    21fa6b1216ba54539eb3abaced1dc68d6bd0d617
parent  ca88a3733fd0e1efdd9ca06ee8ba5fc7d9a3cb8c
...
1
2
3
 
 
4
5
6
...
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
 
 
40
41
 
 
42
43
44
45
 
 
 
 
46
47
48
...
61
62
63
 
64
65
66
67
68
69
 
 
 
 
 
 
 
 
70
71
72
...
1
2
3
4
5
6
7
8
...
28
29
30
 
 
 
 
 
 
 
 
 
 
 
31
32
33
34
 
35
36
37
38
39
40
41
42
43
44
45
46
47
...
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
0
@@ -1,6 +1,8 @@
0
 class CommentsController < ApplicationController
0
   
0
   before_filter :find_user
0
+ before_filter :find_comment, :only => [:destroy, :unspam]
0
+ before_filter :login_required, :only => [:destroy, :unspam]
0
   
0
   def create
0
     respond_to do |wants|
0
@@ -26,23 +28,20 @@ class CommentsController < ApplicationController
0
   end
0
   
0
   def destroy
0
- @comment = Comment.find(params[:id], :include => [:commenter, :user])
0
- if logged_in? && (current_user.admin? || (@comment.user.id == @comment.commentable.user.id))
0
- if current_user.id.to_s == @comment.commenter_id.to_s
0
- # if the person who made the comment is the person deleting it, just delete it
0
- @comment.destroy
0
- flash[:ok] = 'We threw away that comment'
0
- else
0
- # otherwise mark as spam
0
- @comment.report_as_false_negative
0
- flash[:ok] = 'We marked that comment as spam'
0
- end
0
+ if params[:spam] == true
0
+ @comment.report_as_false_negative
0
+ flash[:ok] = 'We marked that comment as spam'
0
     else
0
- flash[:error] = "Um, sorry, you can't do that"
0
+ @comment.destroy
0
+ flash[:ok] = 'We threw away that comment'
0
     end
0
     redirect_to :back
0
   end
0
   
0
+ def unspam
0
+ @comment.report_as_false_positive
0
+ redirect_to :back
0
+ end
0
   
0
   def index
0
     if params[:login]
0
@@ -61,12 +60,21 @@ class CommentsController < ApplicationController
0
       @page_title = "Recent Comments"
0
       @comments = Comment.public.paginate(:all, :per_page => 10, :page => params[:page]) unless admin?
0
       @comments = Comment.include_private.paginate(:all, :per_page => 10, :page => params[:page]) if admin?
0
+ @spam = Comment.paginate_by_spam(true, :order => 'created_at DESC', :per_page => 10, :page => params[:spam_page]) if moderator? or admin?
0
     end
0
   end
0
   
0
   
0
   protected
0
   
0
+ def find_comment
0
+ @comment = Comment.find(params[:id], :include => [:commenter, :user])
0
+ end
0
+
0
+ def authorized?
0
+ logged_in? && (current_user.moderator? || current_user.admin? || (@comment.user.id == @comment.commentable.user.id))
0
+ end
0
+
0
   def shared_attributes
0
     {:commenter => find_commenter,
0
     :body => params[:comment][:body],
...
19
20
21
22
23
 
24
25
26
27
28
29
 
 
 
 
 
 
 
 
 
 
30
31
...
19
20
21
 
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
0
@@ -19,12 +19,22 @@
0
 
0
     <% end %>
0
 <% else %>
0
- <h1>All recent alonetone comments</h1>
0
     <% content_for :left do %>
0
+ <h1>Recent Comments</h1>
0
     <div class="mini_paginator">
0
           <%= will_paginate @comments, :param_name => :page%>
0
         </div>
0
         <%= render :partial => 'shared/comment', :collection => @comments %>
0
     <% end %>
0
 
0
+ <% if moderator? or admin? %>
0
+ <% content_for :right do %>
0
+ <h1>Recent SPAM</h1>
0
+ <div class="mini_paginator">
0
+ <%= will_paginate @spam, :param_name => :spam_page%>
0
+ </div>
0
+ <%= render :partial => 'shared/comment', :collection => @spam %>
0
+ <% end %>
0
+ <% end %>
0
+
0
 <% end %>
0
\ No newline at end of file
...
20
21
22
23
 
 
 
 
 
 
24
25
26
...
20
21
22
 
23
24
25
26
27
28
29
30
31
0
@@ -20,7 +20,12 @@
0
     </span>
0
   
0
   <% if authorized_for_comment(comment) %>
0
- <%= link_to 'Delete', comment_path(comment), :class=> 'delete button', :confirm => 'Are you sure you want to mark this comment as spam and delete it?', :method => :delete %>
0
+ <% if comment.spam == false %>
0
+ <%= link_to 'SPAM', comment_path(comment, :spam => true), :class => 'remove button', :style => 'margin-right: 40px;', :confirm => 'Are you sure you want to mark this as SPAM? This will make it harder for the user who posted this comment to post again', :method => :delete%>
0
+ <% else %>
0
+ <%= link_to 'un-SPAM', unspam_comment_path(comment), :class => 'unspam button', :style => 'margin-right: 40px;', :confirm => 'This will make the comment public. Are you sure?' %>
0
+ <% end %>
0
+ <%= link_to 'Delete', comment_path(comment), :class=> 'delete button', :confirm => 'Are you sure you want to delete this comment?', :method => :delete %>
0
   <% end %>
0
   </div>
0
   <div class="comment_body">
...
4
5
6
7
 
 
8
9
10
...
4
5
6
 
7
8
9
10
11
0
@@ -4,7 +4,8 @@ ActionController::Routing::Routes.draw do |map|
0
   
0
   map.blog 'blog', :controller => 'updates', :action => 'index'
0
   map.feedback 'feedback', :controller => 'user_reports'
0
- map.resources :features, :sessions, :comments, :user_reports, :updates
0
+ map.resources :features, :sessions, :user_reports, :updates
0
+ map.resources :comments, :member => {:unspam => :get}
0
     
0
   # RESTFUL WORKAROUND FOR FACEBOOK
0
   map.facebook_home '', :controller => 'facebook_accounts', :conditions => {:canvas => true}
...
265
266
267
268
 
269
270
271
...
276
277
278
279
 
 
 
280
281
282
...
265
266
267
 
268
269
270
271
...
276
277
278
 
279
280
281
282
283
284
0
@@ -265,7 +265,7 @@ a.button
0
   &.sort
0
     :background url(../images/icons/latest.png) no-repeat left center
0
     
0
- &.delete, &.remove
0
+ &.delete, &.remove, &.unspam
0
     :position absolute
0
     :background url(../images/icons/delete.png) no-repeat center top
0
     :display block
0
@@ -276,7 +276,9 @@ a.button
0
     :top 5px
0
     :right 10px
0
     :padding-top 8px
0
-.asset div.button a.remove, .asset.hover div.button a.remove
0
+a.button.unspam
0
+ :background url(../images/icons/comment.png) no-repeat center top
0
+.asset div.button a.remove, .asset.hover div.button a.remove, a.button.remove
0
   :background url(../images/icons/remove.png) no-repeat center top
0
   :height 30px
0
   :width 30px

Comments

    No one has commented yet.