Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

various akismet tweaks and fixes -- verified working

The :akismet option is now :akismet_key. There are also :akismet_url
and :akismet_always options. The former allows the URL passed to
Akismet to be specified (if different from the :url option). The
latter can be set to enable Akismet checking in development.
  • Loading branch information...
commit 145d678e2214da69906d8e00ed891891fc7895cb 1 parent a3b1e84
@rtomayko rtomayko authored
View
20 lib/wink.rb
@@ -29,7 +29,16 @@
set :password, nil
# The site's Akismet key, if spam detection should be performed.
- set :akismet, nil
+ set :akismet_key, nil
+
+ # The URL of the site as registered with Akismet. Defaults to the
+ # +url+ option.
+ set :akismet_url, nil
+
+ # Boolean specifying whether Akismet checks should be performed in all
+ # environments. Default is to check w/ Akismet only when in production
+ # environment.
+ set :akismet_always, false
# A del.icio.us username/password as a two-tuple: ['username', 'password'].
# When set, del.icio.us bookmark synchronization may be performed by calling
@@ -90,6 +99,15 @@ def method_missing(name, *args, &block)
private :method_missing
+ # Options ====================================================================
+
+ def akismet_url
+ self[:url]
+ end
+
+
+ # Configuration ==============================================================
+
# Load configuration from the file specified and/or by executing the block. If
# both a file and block are given, the config file is loaded first and then
# the block is executed.
View
1  lib/wink/akismet.rb
@@ -75,6 +75,7 @@ class Akismet
attr_reader :key
# A Hash of request headers delivered with each request.
+ attr_reader :headers
# Create a new Akismet call site. The +key+ and +url+ arguments are
# required and
View
9 lib/wink/models.rb
@@ -1,5 +1,4 @@
require 'wink'
-require 'wink/akismet'
class Entry
include DataMapper::Persistence
@@ -374,7 +373,7 @@ def ham!
# Should comments be checked with Akismet before saved?
def akismet?
- Wink[:akismet] && production?
+ Wink.akismet_key && (production? || Wink.akismet_always)
end
# Send an Akismet request with parameters from the receiver's model. Return
@@ -397,7 +396,11 @@ def akismet_params(others={})
# The Wink::Akismet instance used for checking comments.
def akismet_connection
- @akismet_connection ||= Akismet::new(Wink[:akismet], Wink[:url])
+ @akismet_connection ||=
+ begin
+ require 'wink/akismet'
+ Wink::Akismet::new(Wink.akismet_key, Wink.akismet_url)
+ end
end
end
View
2  wink.conf.example
@@ -28,7 +28,7 @@ set :begin_date, 2008
#set :log_stream, File.open('development.log', 'ab')
## This site's Akismet key (should pair with the url option).
-#set :akismet, 'd3cafbad'
+set :akismet_key, 'd3cafbad'
## The del.icio.us username/password used for bookmark synchronization.
#set :delicious, %w[username password]
Please sign in to comment.
Something went wrong with that request. Please try again.