Every repository with this icon (
Every repository with this icon (
tree c27e15b916d1e4290a143a229818018f4b735c3a
parent be95ec98ca27bf085ab6339c9c286601f3b0133c parent 20feb5b277d85524d9182f7f81b44f9b824521a7
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Sat Apr 05 12:34:03 -0700 2008 | [rsl] |
| |
CHANGELOG | Sat Apr 05 12:34:03 -0700 2008 | [rsl] |
| |
MIT-LICENSE | Sat Apr 05 12:34:03 -0700 2008 | [rsl] |
| |
README.rdoc | Sat Apr 05 12:40:41 -0700 2008 | [rsl] |
| |
Rakefile | Sat Apr 05 12:34:03 -0700 2008 | [rsl] |
| |
init.rb | Sat Apr 05 12:34:03 -0700 2008 | [rsl] |
| |
lib/ | Tue Apr 15 14:14:06 -0700 2008 | [rsl] |
| |
tasks/ | Sat Apr 05 12:34:03 -0700 2008 | [rsl] |
| |
test/ | Tue May 13 17:02:31 -0700 2008 | [rsl] |
ActsAsSnook
ActsAsSnook is a simple and elegant method of handling comment spam that doesn’t rely on CAPTCHAS or Javascript or external web services. It uses a point based system to detect common traits of comment spam. The details of this implementation can be found in the source code and tests as well as the original blog post I based this plugin on (see "Thanks and credits").
Setup
ActsAsSnook assumes that you have the following fields on your comment model: author [string], email [string], url [string], body [text], and spam_status [string]. The name of these attributes can be changed as shown in the next section.
Usage
acts_as_snook
That’s it if you want to use the default attributes I mentioned above. If you need to customize them, just specify them as arguments to acts_as_snook:
acts_as_snook :author_field => :user, :body_field => :comment # Etc, etc
You may also add your own keywords to the list of spam keywords that ActsAsSnook uses to detect spam by adding them to the arguments:
acts_as_snook :spam_words => %{hatespeech ignorantlanguage blathering}
ActsAsSnook also provides some helper methods for determining the spam status of a comment.
| comment.ham?: | Returns true for comments not marked as spam. "Ham" comments are safe for displaying on your site as is. This is the method you should most likely be using to check an individual comment. |
| comment.spam?: | Returns true for comments marked as spam. These are should not be shown on your site. |
| comment.moderate?: | Returns true for comments that were not marked as actual spam but did not get enough points to be marked as "ham" either. The spam_status field for these will contain "moderate". |
| Comment#ham: | Shortcut for Comment#find(:all, :conditions => {:spam_status => "ham"}) |
| Comment#spam: | Shortcut for Comment#find(:all, :conditions => {:spam_status => "spam"}) |
| Comment#moderate: | Shortcut for Comment#find(:all, :conditions => {:spam_status => "moderate"}) |
Credits and Thanks
Much love to Jonathan Snook, web developer extraordinaire. Most of the algorithms of ActsAsSnook [as well as the name, obviously] come from his blog post which you can find here[http://snook.ca/archives/other/effective_blog_comment_spam_blocker] The actual implementation I myself wrote.
Copyright © 2008 Lucky Sneaks, released under the MIT license




