Skip to content

Commit

Permalink
Display only ham comments on page. Spammers are getting a wee bit tir…
Browse files Browse the repository at this point in the history
…esome.
  • Loading branch information
karmi committed Feb 16, 2009
1 parent 1570465 commit 045454a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 4 additions & 0 deletions app/lib/comment.rb
Expand Up @@ -20,6 +20,10 @@ class Comment < ActiveRecord::Base
def report_as_spam
Akismetor.submit_spam(akismet_attributes)
end

def ham?
!self.spam?
end

private

Expand Down
4 changes: 2 additions & 2 deletions app/lib/post.rb
Expand Up @@ -46,7 +46,7 @@ def self.find_all(options={})
posts = []
self.extract_posts_from_directory(options).each do |file|
attributes = self.extract_post_info_from(file, options)
attributes.merge!( :comments => Marley::Comment.find_all_by_post_id(attributes[:id], :select => ['id']) )
attributes.merge!( :comments => Marley::Comment.find_all_by_post_id(attributes[:id], :select => ['id']) ).ham
posts << self.new( attributes )
end
return posts.reverse
Expand All @@ -60,7 +60,7 @@ def self.find_one(id, options={})
directory = directory.first
return unless directory or !File.exist?(directory)
file = Dir["#{directory}/*.txt"].first
self.new( self.extract_post_info_from(file, options).merge( :comments => Marley::Comment.find_all_by_post_id(id) ) )
self.new( self.extract_post_info_from(file, options).merge( :comments => Marley::Comment.find_all_by_post_id(id).ham ) )
end

# Returns directories in data directory. Default is published only (no <tt>.draft</tt> in name)
Expand Down
7 changes: 3 additions & 4 deletions themes/restafari/views/post.erb
Expand Up @@ -35,15 +35,14 @@
<form action="/admin/<%= @post.id %>/spam" method="post">
<input type="hidden" name="_method" value="delete">
<% end %>
<% @post.comments.each_with_index do |comment, index| %>
<% if params[:thank_you] && comment == @post.comments.last %>
<% if params[:thank_you] && comment == @post.comments.last && comment.ham? %>
<div id="comment_added_thanks"><div class="in"><p>Thank you for your comment!</p></div></div>
<% end %>
<div class="comment<%= ' spam' if comment.spam? %>" id="comment_<%= comment.id %>">
<% if authorized? %>
<input type="checkbox" name="spam_comment_ids[]" value="<%= comment.id %>" id="spam_comment_id_<%= comment.id %>"<%= ' checked="checked"' if comment.spam? %> />
<label for="spam_comment_id_<%= comment.id %>">Spam?</label>
<input type="checkbox" name="spam_comment_ids[]" value="<%= comment.id %>" id="spam_comment_id_<%= comment.id %>"<%= ' checked="checked"' if comment.spam? %> style="z-index: 997" />
<label for="spam_comment_id_<%= comment.id %>" style="z-index: 998">Spam?</label>
<% end %>
<div class="number"><span class="nodisplay"># </span><%= index.succ %></div>
<div class="author">
Expand Down

0 comments on commit 045454a

Please sign in to comment.