public
Fork of halorgium/mephisto
Description: A refactored Mephisto that has multiple spam detection engines.
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/francois/mephisto.git
Admin::ArticlesController#create notifies the spam detection engine about 
new articles.

The different spam engines had to grow #announce_article to implement 
this.
francois (author)
Mon Mar 03 07:42:42 -0800 2008
commit  a80561b04d2f058c3f5bb5d8407454a83fb357d3
tree    f10500aba4e7ff0bc0ce7d61638a48559277b9de
parent  78f9f9372e54ebd656938489c3780315cde0e6be
...
43
44
45
 
46
 
47
48
49
...
43
44
45
46
47
48
49
50
51
0
@@ -43,7 +43,9 @@ class Admin::ArticlesController < Admin::BaseController
0
     @article = current_user.articles.create params[:article].merge(:updater => current_user, :site => site)
0
     
0
     @article.save!
0
+ @article.notify_spam_engine(@article.permalink_url(site, request.host_with_port))
0
     flash[:notice] = "Your article was saved"
0
+
0
     redirect_to :action => 'edit', :id => @article.id
0
   rescue ActiveRecord::RecordInvalid
0
     load_sections
...
96
97
98
 
 
 
 
99
100
101
...
96
97
98
99
100
101
102
103
104
105
0
@@ -96,6 +96,10 @@ class Article < Content
0
     end
0
   end
0
 
0
+ def notify_spam_engine(permalink_url)
0
+ self.site.spam_engine.announce_article(permalink_url, self)
0
+ end
0
+
0
   # AX
0
   def full_permalink
0
     published? && ['', published_at.year, published_at.month, published_at.day, permalink] * '/'
...
31
32
33
 
 
 
 
 
34
35
36
...
31
32
33
34
35
36
37
38
39
40
41
0
@@ -31,6 +31,11 @@ module Mephisto
0
         false
0
       end
0
 
0
+ # Announces a new article was created.
0
+ def announce_article(permalink_url, article)
0
+ raise SubclassResponsibilityError
0
+ end
0
+
0
       # Determines if a single comment is either ham or spam.
0
       def ham?(permalink_url, comment)
0
         raise SubclassResponsibilityError
...
9
10
11
 
 
 
 
12
13
14
...
9
10
11
12
13
14
15
16
17
18
0
@@ -9,6 +9,10 @@ module Mephisto
0
         end
0
       end
0
 
0
+ # Akismet doesn't care about real articles.
0
+ def announce_article(permalink_url, article)
0
+ end
0
+
0
       def ham?(permalink_url, comment)
0
         check_valid!
0
         !akismet.comment_check(comment_spam_options(permalink_url, comment))
...
17
18
19
 
 
 
 
 
 
 
 
 
 
20
21
22
...
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
0
@@ -17,6 +17,16 @@ module Mephisto
0
         self.validate_key.success?
0
       end
0
 
0
+ def announce_article(permalink_url, article)
0
+ response = defensio.announce_article(
0
+ :article_author => article.updater.login,
0
+ :article_author_email => article.updater.email,
0
+ :article_title => article.title,
0
+ :article_content => article.body,
0
+ :permalink => permalink_url
0
+ )
0
+ end
0
+
0
       def ham?(permalink_url, comment)
0
         response = defensio.audit_comment(
0
           # Required parameters
...
13
14
15
 
 
 
16
17
18
...
13
14
15
16
17
18
19
20
21
0
@@ -13,6 +13,9 @@ module Mephisto
0
         true
0
       end
0
 
0
+ def announce_article(permalink_url, article)
0
+ end
0
+
0
       def ham?(permalink_url, comment)
0
         true
0
       end

Comments

    No one has commented yet.