summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/anonok.pm
blob: e615499863a7c119143f3953775d7103c0dad203 (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. default => "",
  15. example => "*/discussion",
  16. description => "PageSpec to limit which pages anonymouse users can edit",
  17. safe => 1,
  18. rebuild => 0,
  19. },
  20. } #}}}
  21. sub canedit ($$$) { #{{{
  22. my $page=shift;
  23. my $cgi=shift;
  24. my $session=shift;
  25. my $ret;
  26. if (exists $config{anonok_pagespec} && length $config{anonok_pagespec}) {
  27. if (pagespec_match($page, $config{anonok_pagespec},
  28. location => $page)) {
  29. return "";
  30. }
  31. else {
  32. return undef;
  33. }
  34. }
  35. else {
  36. return "";
  37. }
  38. } #}}}
  39. 1