]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/anonok.pm
fix preview of shortcuts
[git.ikiwiki.info.git] / IkiWiki / Plugin / anonok.pm
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::anonok;
4 use warnings;
5 use strict;
6 use IkiWiki 2.00;
8 sub import { #{{{
9         hook(type => "getsetup", id => "anonok", call => \&getsetup);
10         hook(type => "canedit", id => "anonok", call => \&canedit);
11 } # }}}
13 sub getsetup () { #{{{
14         return
15                 plugin => {
16                         safe => 1,
17                         rebuild => 0,
18                 },
19                 anonok_pagespec => {
20                         type => "pagespec",
21                         example => "*/discussion",
22                         description => "PageSpec to limit which pages anonymous users can edit",
23                         link => "ikiwiki/PageSpec",
24                         safe => 1,
25                         rebuild => 0,
26                 },
27 } #}}}
29 sub canedit ($$$) { #{{{
30         my $page=shift;
31         my $cgi=shift;
32         my $session=shift;
34         my $ret;
36         if (exists $config{anonok_pagespec} && length $config{anonok_pagespec}) {
37                 if (pagespec_match($page, $config{anonok_pagespec},
38                                    location => $page)) {
39                         return "";
40                 }
41                 else {
42                         return undef;
43                 }
44         }
45         else {
46                 return "";
47         }
48 } #}}}
50 1