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