2007-02-02 03:33:03 +01:00
|
|
|
#!/usr/bin/perl
|
|
|
|
package IkiWiki::Plugin::anonok;
|
|
|
|
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
2008-12-23 22:34:19 +01:00
|
|
|
use IkiWiki 3.00;
|
2007-02-02 03:33:03 +01:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub import {
|
2008-07-26 00:05:55 +02:00
|
|
|
hook(type => "getsetup", id => "anonok", call => \&getsetup);
|
|
|
|
hook(type => "canedit", id => "anonok", call => \&canedit);
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2007-02-02 03:33:03 +01:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub getsetup () {
|
2008-07-26 00:05:55 +02:00
|
|
|
return
|
2008-08-03 22:40:12 +02:00
|
|
|
plugin => {
|
2008-08-03 23:03:20 +02:00
|
|
|
safe => 1,
|
2008-08-03 22:40:12 +02:00
|
|
|
rebuild => 0,
|
|
|
|
},
|
2008-07-26 00:05:55 +02:00
|
|
|
anonok_pagespec => {
|
2008-08-02 22:40:46 +02:00
|
|
|
type => "pagespec",
|
2008-07-26 00:05:55 +02:00
|
|
|
example => "*/discussion",
|
2008-07-27 01:28:15 +02:00
|
|
|
description => "PageSpec to limit which pages anonymous users can edit",
|
2008-08-03 20:36:17 +02:00
|
|
|
link => "ikiwiki/PageSpec",
|
2008-07-26 00:05:55 +02:00
|
|
|
safe => 1,
|
|
|
|
rebuild => 0,
|
|
|
|
},
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2008-07-26 00:05:55 +02:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub canedit ($$$) {
|
2008-05-01 20:58:23 +02:00
|
|
|
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}) {
|
2008-05-01 20:58:23 +02:00
|
|
|
if (pagespec_match($page, $config{anonok_pagespec},
|
|
|
|
location => $page)) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return undef;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return "";
|
|
|
|
}
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2007-02-02 03:33:03 +01:00
|
|
|
|
|
|
|
1
|