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