Changeset 1037
- Timestamp:
- 05/15/07 22:16:00 (19 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 modified
-
Build.PL (modified) (2 diffs)
-
Changes (modified) (1 diff)
-
INSTALL (modified) (1 diff)
-
MANIFEST (modified) (2 diffs)
-
lib/OpenGuides.pm (modified) (3 diffs)
-
lib/OpenGuides/Config.pm (modified) (4 diffs)
-
t/76_detect_spam.t (added)
-
templates/spam_detected.tt (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Build.PL
r1029 r1037 105 105 licence_name licence_url licence_info_url moderation_requires_password 106 106 enable_node_image enable_common_categories enable_common_locales 107 spam_detector_module 107 108 ) ) { 108 109 my $q_method = $var . "__qu"; … … 370 371 "site_index.tt", 371 372 "search.tt", 373 "spam_detected.tt", 372 374 "userstats.tt", 373 375 "wanted_pages.tt" -
trunk/Changes
r1036 r1037 5 5 6 6 0.61 7 Added experimental support for local spam detection modules; see the 8 commit_node method in "perldoc OpenGuides" for details. 7 9 Added extra "edit this page" link next to the node name; if you don't 8 10 want it, add div#title_edit_link {display:none;} to your stylesheet. -
trunk/INSTALL
r1015 r1037 278 278 policy, but you can leave this blank for now if you don't have one yet. 279 279 280 "What module would you like to use for spam detection? (optional)" 281 282 The module you choose should have a method called "looks_like_spam", which 283 accepts a hash with content and metadata as keys, and returns true or false 284 to the question of whether the edit should be considered to be spam. 285 280 286 "Distance calculation methods available are: 281 287 1) British National Grid -
trunk/MANIFEST
r1031 r1037 74 74 templates/site_index.tt 75 75 templates/search.tt 76 templates/spam_detected.tt 76 77 templates/userstats.tt 77 78 templates/wanted_pages.tt … … 137 138 t/74_ping_plugin.t 138 139 t/75_revert_user.t 140 t/76_detect_spam.t 139 141 t/templates/15_test.tt 140 142 wiki.cgi -
trunk/lib/OpenGuides.pm
r1034 r1037 1241 1241 printing the output to STDOUT. 1242 1242 1243 If you have specified the C<spam_detector_module> option in your 1244 C<wiki.conf>, this method will attempt to call the <looks_like_spam> 1245 method of that module to determine whether the edit is spam. If this 1246 method returns true, then the C<spam_detected.tt> template will be 1247 used to display an error message. 1248 1249 The C<looks_like_spam> method will be passed a datastructure containing 1250 content and metadata. 1251 1243 1252 The geographical data that you should provide in the L<CGI> object 1244 1253 depends on the handler you chose in C<wiki.conf>. … … 1295 1304 $new_metadata{longitude} = delete $new_metadata{longitude_unmunged} 1296 1305 if $new_metadata{longitude_unmunged}; 1306 1307 foreach my $var ( qw( summary username comment edit_type ) ) { 1308 $new_metadata{$var} = $q->param($var) || ""; 1309 } 1310 $new_metadata{host} = $ENV{REMOTE_ADDR}; 1311 1312 # Wiki::Toolkit::Plugin::RSS::ModWiki wants "major_change" to be set. 1313 $new_metadata{major_change} = ( $new_metadata{edit_type} eq "Normal edit" ) 1314 ? 1 1315 : 0; 1316 1317 # If we can, check to see if this edit looks like spam. 1318 my $spam_detector = $config->spam_detector_module; 1319 my $is_spam; 1320 if ( $spam_detector ) { 1321 eval { 1322 eval "require $spam_detector"; 1323 $is_spam = $spam_detector->looks_like_spam( 1324 node => $node, 1325 content => $content, 1326 metadata => \%new_metadata, 1327 ); 1328 }; 1329 } 1330 1331 if ( $is_spam ) { 1332 my $output = OpenGuides::Template->output( 1333 wiki => $self->wiki, 1334 config => $config, 1335 template => "spam_detected.tt", 1336 vars => { 1337 not_editable => 1, 1338 }, 1339 ); 1340 return $output if $return_output; 1341 print $output; 1342 return; 1343 } 1297 1344 1298 1345 # Check to make sure all the indexable nodes are created … … 1306 1353 } 1307 1354 1308 foreach my $var ( qw( summary username comment edit_type ) ) {1309 $new_metadata{$var} = $q->param($var) || "";1310 }1311 $new_metadata{host} = $ENV{REMOTE_ADDR};1312 1313 # Wiki::Toolkit::Plugin::RSS::ModWiki wants "major_change" to be set.1314 $new_metadata{major_change} = ( $new_metadata{edit_type} eq "Normal edit" )1315 ? 11316 : 0;1317 1318 1355 my $written = $wiki->write_node( $node, $content, $checksum, 1319 1356 \%new_metadata ); -
trunk/lib/OpenGuides/Config.pm
r1015 r1037 22 22 licence_name licence_url licence_info_url moderation_requires_password 23 23 enable_node_image enable_common_categories enable_common_locales 24 spam_detector_module 24 25 ); 25 26 my @questions = map { $_ . "__qu" } @variables; … … 106 107 licence_name => "", 107 108 licence_url => "", 108 licence_info_url => "" 109 licence_info_url => "", 110 spam_detector_module => "", 109 111 ); 110 112 … … 186 188 licence_name => "What licence will you use for the guide?", 187 189 licence_url => "What is the URL to your licence?", 188 licence_info_url => "What is the URL to your local page about your licensing policy?" 190 licence_info_url => "What is the URL to your local page about your licensing policy?", 191 spam_detector_module => "What module would you like to use for spam detection? (optional)", 189 192 ); 190 193 … … 311 314 =item * licence_info_url 312 315 316 =item * spam_detector_module 317 313 318 =back 314 319
