Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 4004 Bytes
1 | class Feedback < Content |
2 | # Empty, for now, ready to hoist up methods from Comment & Trackback |
3 | set_table_name "feedback" |
4 | |
5 | include TypoGuid |
6 | validates_age_of :article_id |
7 | |
8 | before_create :create_guid, :article_allows_this_feedback |
9 | before_save :correct_url |
10 | |
11 | def self.default_order |
12 | 'created_at ASC' |
13 | end |
14 | |
15 | def initialize(*args, &block) |
16 | super(*args, &block) |
17 | self.state = ContentState::Unclassified.instance |
18 | end |
19 | |
20 | def permalink_url(anchor=:ignored, only_path=true) |
21 | article.permalink_url("#{self.class.to_s.downcase}-#{id}",only_path) |
22 | end |
23 | |
24 | def edit_url(anchor=:ignored, only_path=true) |
25 | blog.url_for(:controller => "/admin/#{self.class.to_s.downcase}s", :action =>"edit", :id => id) |
26 | end |
27 | |
28 | def delete_url(anchor=:ignored, only_path=true) |
29 | blog.url_for(:controller => "/admin/#{self.class.to_s.downcase}s", :action =>"destroy", :id => id) |
30 | end |
31 | |
32 | def html_postprocess(field, html) |
33 | helper = ContentTextHelpers.new |
34 | sanitize(helper.auto_link(html),'a href, b, br, i, p, em, strong, pre, code, ol, ul, li, blockquote').nofollowify |
35 | end |
36 | |
37 | def correct_url |
38 | if !url.blank? && url !~ /^http:\/\// |
39 | self.url = 'http://' + url |
40 | end |
41 | end |
42 | |
43 | def article_allows_this_feedback |
44 | article && blog_allows_feedback? && article_allows_feedback? |
45 | end |
46 | |
47 | def blog_allows_feedback? |
48 | true |
49 | end |
50 | |
51 | def akismet_options |
52 | {:user_ip => ip, |
53 | :comment_type => self.class.to_s.downcase, |
54 | :comment_author => originator, |
55 | :comment_author_email => email, |
56 | :comment_author_url => url, |
57 | :comment_content => body}.merge(additional_akismet_options) |
58 | end |
59 | |
60 | def additional_akismet_options |
61 | { } |
62 | end |
63 | |
64 | def spam_fields |
65 | [:title, :body, :ip, :url] |
66 | end |
67 | |
68 | def spam? |
69 | state.is_spam?(self) |
70 | end |
71 | |
72 | def status_confirmed? |
73 | state.status_confirmed?(self) |
74 | end |
75 | |
76 | # is_spam? checks to see if this is spam. |
77 | # |
78 | # options are passed on to Akismet. Recommended options (when available) are: |
79 | # |
80 | # :permalink => the article's URL |
81 | # :user_agent => the poster's UserAgent string |
82 | # :referer => the poster's Referer string |
83 | # |
84 | |
85 | def is_spam?(options={}) |
86 | return false unless blog.sp_global |
87 | sp_is_spam?(options) || akismet_is_spam?(options) |
88 | end |
89 | |
90 | def classify |
91 | return :spam if blog.default_moderate_comments |
92 | return :ham unless blog.sp_global |
93 | test_result = is_spam? |
94 | |
95 | # Yeah, three state logic is evil... |
96 | case is_spam? |
97 | when nil; :spam |
98 | when true; :spam |
99 | when false; :ham |
100 | end |
101 | end |
102 | |
103 | def sp_is_spam?(options={}) |
104 | sp = SpamProtection.new(blog) |
105 | Timeout.timeout(defined?($TESTING) ? 10 : 30) do |
106 | spam_fields.any? do |field| |
107 | sp.is_spam?(self.send(field)) |
108 | end |
109 | end |
110 | rescue Timeout::Error => e |
111 | nil |
112 | end |
113 | |
114 | def akismet |
115 | Akismet.new(blog.sp_akismet_key, blog.base_url) |
116 | end |
117 | |
118 | def akismet_is_spam?(options={}) |
119 | return false if blog.sp_akismet_key.blank? |
120 | begin |
121 | Timeout.timeout(defined?($TESTING) ? 30 : 60) do |
122 | akismet.commentCheck(akismet_options) |
123 | end |
124 | rescue Timeout::Error => e |
125 | nil |
126 | end |
127 | end |
128 | |
129 | def mark_as_ham |
130 | state.mark_as_ham(self) |
131 | end |
132 | |
133 | def mark_as_ham! |
134 | mark_as_ham |
135 | save! |
136 | end |
137 | |
138 | def mark_as_spam |
139 | state.mark_as_spam(self) |
140 | end |
141 | |
142 | def mark_as_spam! |
143 | mark_as_spam |
144 | save |
145 | end |
146 | |
147 | def report_as_spam |
148 | return if blog.sp_akismet_key.blank? |
149 | Timeout.timeout(defined?($TESTING) ? 5 : 3600) { akismet.submitSpam(akismet_options) } |
150 | end |
151 | |
152 | def report_as_ham |
153 | return if blog.sp_akismet_key.blank? |
154 | Timeout.timeout(defined?($TESTING) ? 5 : 3600) { akismet.submitHam(akismet_options) } |
155 | end |
156 | |
157 | def set_spam(is_spam, options ={}) |
158 | return if blog.sp_akismet_key.blank? |
159 | Timeout.timeout(defined?($TESTING) ? 5 : 3600) { is_spam ? report_as_spam : report_as_ham } |
160 | end |
161 | |
162 | def withdraw! |
163 | withdraw |
164 | self.save! |
165 | end |
166 | |
167 | def confirm_classification |
168 | state.confirm_classification(self) |
169 | end |
170 | |
171 | def confirm_classification! |
172 | state.confirm_classification(self) |
173 | self.save |
174 | end |
175 | end |