public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
add akismet support

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@1154 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Sat May 27 20:46:15 -0700 2006
commit  0b5ddb97f7d8101c924c4c2fdfceb24dd4f3ecbf
tree    154aa2c2276a47ff5e37f9c100f947571d8ed537
parent  191fa9642e18a93d6fdc78fdf515ba51b8fa02d5
...
75
76
77
 
 
 
 
 
 
 
 
78
79
80
...
75
76
77
78
79
80
81
82
83
84
85
86
87
88
0
@@ -75,6 +75,14 @@ class Admin::ArticlesController < Admin::BaseController
0
     @comment.save
0
   end
0
 
0
+ def set_akismet
0
+ Akismet.api_key = params[:api_key]
0
+ Akismet.blog = params[:blog]
0
+ render :update do |page|
0
+ page[:akismet].visual_effect :drop_out
0
+ end
0
+ end
0
+
0
   protected
0
   def save_or_draft
0
     if draft?(params[:submit])
...
11
12
13
 
 
 
 
 
 
 
 
 
 
 
 
 
14
15
16
...
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
0
@@ -11,6 +11,19 @@ class CommentsController < ApplicationController
0
     end
0
 
0
     @comment = @article.comments.create(params[:comment].merge(:author_ip => request.remote_ip))
0
+ if @comment.valid? && Akismet.api_key && Akismet.blog
0
+ ak = Akismet.new(Akismet.api_key, Akismet.blog)
0
+ @comment.approved = ak.comment_check \
0
+ :user_ip => @comment.author_ip,
0
+ :user_agent => request.user_agent,
0
+ :referrer => request.referer,
0
+ :permalink => article_url(@article.hash_for_permalink),
0
+ :comment_author => @comment.author,
0
+ :comment_author_email => @comment.author_email,
0
+ :comment_author_url => @comment.author_url,
0
+ :comment_content => @comment.body
0
+ end
0
+
0
     if @comment.new_record?
0
       @comments = @article.comments.select { |c| not c.new_record? }.collect { |c| c.to_liquid }
0
       @article = @article.to_liquid(:single)
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
0
@@ -1,3 +1,28 @@
0
+<% unless Akismet.api_key && Akismet.blog -%>
0
+<%= form_remote_tag :url => { :action => 'set_akismet' }, :html => { :id => 'akismet' } %>
0
+ <p>
0
+ Set an <%= link_to 'Akismet', 'http://akismet.com' %> to automatically approve spam.
0
+ <%= link_to_function 'How?', "Effect.toggle('akismet-how', 'blind')" %>
0
+ </p>
0
+ <pre id="akismet-how" style="display:none">
0
+# database.yml
0
+production:
0
+ adapter: postgresql
0
+ database: mephisto_dev
0
+ host: localhost
0
+ username: USERNAME
0
+ password: PASSWORD
0
+ min_messages: warning
0
+ akismet_api_key: APIKEY
0
+ akismet_blog: BLOG
0
+</pre>
0
+ <p><label>API Key</label> <%= text_field_tag :api_key, Akismet.api_key %></p>
0
+ <p><label>Blog</label> <%= text_field_tag :blog, Akismet.blog %></p>
0
+ <p><%= submit_tag :Save %> without restarting.</p>
0
+</form>
0
+<% end -%>
0
+ <%= request.referer %>
0
+
0
 <h1>Unapproved Comments for '<%=h @article.title %>'</h1>
0
 
0
 <% @article.unapproved_comments.each do |comment| -%>
...
92
93
94
95
96
 
 
 
 
 
 
...
92
93
94
 
95
96
97
98
99
100
101
0
@@ -92,4 +92,9 @@ ActiveRecord::Base.class_eval do
0
       YAML.dump find(:all).inject({}) { |hsh, record| hsh.merge(record.id => record.attributes) }, out
0
     end
0
   end
0
-end
0
\ No newline at end of file
0
+end
0
+
0
+Akismet.class_eval do
0
+ cattr_accessor :api_key
0
+ cattr_accessor :blog
0
+end

Comments

    No one has commented yet.