On Thu 27 Sep 2007, Markus Linke <markus.linke(a)linke.de> wrote:
Is there any way to protect the openguide wiki from
spam? The New
York pages get messed up all the time :o(
Yep! As of version 0.61, OpenGuides lets you define a spamchecker
module that will be invoked every time someone tries to save an edit.
If the module decides that the edit is spam, it refuses the edit and
informs the user.
From the docs for OpenGuides->commit_node:
If you have specified the "spam_detector_module" option in your
wiki.conf, this method will attempt to call the "looks_like_spam"
method of that module to determine whether the edit is spam. If this
method returns true, then the spam_detected.tt template will be used
to display an error message.
The looks_like_spam method will be passed a datastructure containing
content and metadata.
Here's an example:
[in wiki.conf]
spam_detector_module = OpenGuides::Local::OGLSpamDetector
[in OGLSpamDetector.pm]
package OpenGuides::Local::OGLSpamDetector;
use strict;
sub looks_like_spam {
my ( $class, %args ) = @_;
if ( $args{metadata}{comment} =~ /some grammatical corrections/i ) {
return 1;
}
my @cats = @{ $args{metadata}{category} };
foreach my $cat ( @cats ) {
if ( $cat =~ m'http://'i ) {
return 1;
}
}
my @locs = @{ $args{metadata}{locale} };
foreach my $loc ( @locs ) {
if ( $loc =~ m'http://'i ) {
return 1;
}
}
}