ikiwiki/IkiWiki/Plugin/anonok.pm

52 lines
892 B
Perl
Raw Normal View History

#!/usr/bin/perl
package IkiWiki::Plugin::anonok;
use warnings;
use strict;
use IkiWiki 3.00;
sub import {
hook(type => "getsetup", id => "anonok", call => \&getsetup);
hook(type => "canedit", id => "anonok", call => \&canedit);
}
sub getsetup () {
return
plugin => {
2008-08-03 23:03:20 +02:00
safe => 1,
rebuild => 0,
section => "auth",
},
anonok_pagespec => {
2008-08-02 22:40:46 +02:00
type => "pagespec",
example => "*/discussion",
description => "PageSpec to limit which pages anonymous users can edit",
2008-08-03 20:36:17 +02:00
link => "ikiwiki/PageSpec",
safe => 1,
rebuild => 0,
},
}
sub canedit ($$$) {
my $page=shift;
my $cgi=shift;
my $session=shift;
my $ret;
2008-05-02 19:01:51 +02:00
if (exists $config{anonok_pagespec} && length $config{anonok_pagespec}) {
if (pagespec_match($page, $config{anonok_pagespec},
location => $page)) {
return "";
}
else {
return undef;
}
}
else {
return "";
}
}
1