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