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
Search Repo:
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
Replaced the Akismet and Defensio plugins with Viking.
francois (author)
Mon Mar 10 21:11:16 -0700 2008
commit  0b691e1b7ec087a49e4a1083ae318d7dc83d62c9
tree    42601966532f24d265228330a675cdbfe53d631c
parent  86c8abf9e9f207e6dcf84df6544968eafbf2b566
...
50
51
52
53
 
54
55
56
...
50
51
52
 
53
54
55
56
0
@@ -50,7 +50,7 @@
0
 
0
       protected
0
       def akismet
0
- @akismet ||= ::Akismet.new(options[:akismet_key], options[:akismet_url])
0
+ @akismet ||= Viking.connect("akismet", :api_key => options[:akismet_key], :blog => options[:akismet_url])
0
       end
0
 
0
       def comment_spam_options(permalink_url, comment)
...
14
15
16
17
 
18
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
21
 
 
22
23
24
25
26
 
27
28
29
...
55
56
57
58
 
59
60
61
62
63
...
72
73
74
75
76
 
 
77
78
79
80
81
 
82
83
84
85
86
 
87
88
89
90
91
...
96
97
98
99
100
 
101
102
103
104
105
106
107
108
109
110
111
112
113
 
114
115
116
117
 
118
119
120
...
14
15
16
 
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 
47
48
49
50
51
52
 
53
54
55
56
...
82
83
84
 
85
86
87
88
89
90
...
99
100
101
 
 
102
103
104
105
106
107
 
108
109
110
111
112
 
113
114
115
116
117
118
...
123
124
125
 
 
126
127
128
129
130
131
132
 
 
 
 
 
 
 
133
134
135
136
 
137
138
139
140
0
@@ -14,16 +14,43 @@
0
       end
0
 
0
       def valid_key?
0
- self.validate_key.success?
0
+ self.validate_key
0
       end
0
 
0
+ class Stats
0
+ def initialize(response)
0
+ @response = response
0
+ end
0
+
0
+ def spam
0
+ @response[:spam]
0
+ end
0
+
0
+ def ham
0
+ @response[:ham]
0
+ end
0
+
0
+ def accuracy
0
+ @response[:accuracy]
0
+ end
0
+
0
+ def false_negatives
0
+ @response[:"false-negatives"]
0
+ end
0
+
0
+ def false_positives
0
+ @response[:"false-positives"]
0
+ end
0
+ end
0
+
0
       def statistics_template
0
- return self.class.load_template(File.join(File.dirname(__FILE__), "defensio_statistics.html.erb")).render(:site => site, :options => site.spam_engine_options, :statistics => defensio.get_stats) if valid_key?
0
+ stats = Stats.new(defensio.stats)
0
+ return self.class.load_template(File.join(File.dirname(__FILE__), "defensio_statistics.html.erb")).render(:site => site, :options => site.spam_engine_options, :statistics => stats) if valid_key?
0
         return ""
0
       end
0
 
0
       def announce_article(permalink_url, article)
0
- response = defensio.announce_article(
0
+ response = defensio.check_article(
0
           :article_author => article.updater.login,
0
           :article_author_email => article.updater.email,
0
           :article_title => article.title,
0
@@ -55,7 +82,7 @@
0
       end
0
 
0
       def ham?(permalink_url, comment, options={})
0
- response = defensio.audit_comment(
0
+ response = defensio.check_comment(
0
           # Required parameters
0
           :user_ip => comment.author_ip,
0
           :article_date => comment.article.published_at.strftime("%Y/%m/%d"),
0
0
0
@@ -72,18 +99,18 @@
0
           :trusted_user => options[:authenticated]
0
         )
0
 
0
- comment.update_attribute(:spam_engine_data, {:signature => response.signature, :spaminess => response.spaminess.to_f})
0
- !response.spam
0
+ comment.update_attribute(:spam_engine_data, {:signature => response["signature"], :spaminess => response["spaminess"].to_f})
0
+ !response["spam"]
0
       end
0
 
0
       def mark_as_ham(permalink_url, comment)
0
         return if comment.spam_engine_data.blank? || comment.spam_engine_data[:signature].blank?
0
- defensio.report_false_positives(:signatures => [comment.spam_engine_data[:signature]])
0
+ defensio.mark_as_ham(:signatures => [comment.spam_engine_data[:signature]])
0
       end
0
 
0
       def mark_as_spam(permalink_url, comment)
0
         return if comment.spam_engine_data.blank? || comment.spam_engine_data[:signature].blank?
0
- defensio.report_false_negatives(:signatures => [comment.spam_engine_data[:signature]])
0
+ defensio.mark_as_spam(:signatures => [comment.spam_engine_data[:signature]])
0
       end
0
 
0
       def sort_block
0
0
0
@@ -96,25 +123,18 @@
0
           es << "The Defensio url is missing" if options[:defensio_url].blank?
0
 
0
           unless self.valid_key?
0
- message = self.validate_key.message
0
- es << "The Defensio API says your key is invalid#{%Q(: #{message}) unless message.blank?}"
0
+ es << "The Defensio API says your key is invalid"
0
           end
0
         end
0
       end
0
 
0
       protected
0
       def defensio
0
- begin
0
- @defensio ||= Defensio::Client.new(:owner_url => options[:defensio_url], :api_key => options[:defensio_key])
0
- rescue Defensio::InvalidAPIKey
0
- logger.warn { $! }
0
- logger.warn { $!.backtrace.join("\n") }
0
- raise Mephisto::SpamDetectionEngine::NotConfigured
0
- end
0
+ @defensio ||= Viking.connect("defensio", :api_key => options[:defensio_key], :blog => options[:defensio_url])
0
       end
0
 
0
       def validate_key
0
- @response ||= defensio.validate_key
0
+ @verified ||= defensio.verified?
0
       end
0
     end
0
   end

Comments

    No one has commented yet.