summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/anonok.pm
blob: 7b966f845338775cb07cc317af7c1b27ca6e811c (plain)
  1. #!/usr/bin/perl
  2. package IkiWiki::Plugin::anonok;
  3. use warnings;
  4. use strict;
  5. use IkiWiki 2.00;
  6. sub import { #{{{
  7. hook(type => "getsetup", id => "anonok", call => \&getsetup);
  8. hook(type => "canedit", id => "anonok", call => \&canedit);
  9. } # }}}
  10. sub getsetup () { #{{{
  11. return
  12. anonok_pagespec => {
  13. type => "string",
  14. example => "*/discussion",
  15. description => "PageSpec to limit which pages anonymous users can edit",
  16. safe => 1,
  17. rebuild => 0,
  18. },
  19. } #}}}
  20. sub canedit ($$$) { #{{{
  21. my $page=shift;
  22. my $cgi=shift;
  23. my $session=shift;
  24. my $ret;
  25. if (exists $config{anonok_pagespec} && length $config{anonok_pagespec}) {
  26. if (pagespec_match($page, $config{anonok_pagespec},
  27. location => $page)) {
  28. return "";
  29. }
  30. else {
  31. return undef;
  32. }
  33. }
  34. else {
  35. return "";
  36. }
  37. } #}}}
  38. 1