summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/testpagespec.pm
blob: 9f9b50f017bb5cb75a5ed1155984531d082d200d (plain)
  1. #!/usr/bin/perl
  2. package IkiWiki::Plugin::testpagespec;
  3. use warnings;
  4. use strict;
  5. use IkiWiki 2.00;
  6. sub import { #{{{
  7. hook(type => "getsetup", id => "testpagespec", call => \&getsetup);
  8. hook(type => "preprocess", id => "testpagespec", call => \&preprocess);
  9. } # }}}
  10. sub getsetup () { #{{{
  11. return
  12. plugin => {
  13. safe => 1,
  14. rebuild => undef,
  15. },
  16. } #}}}
  17. sub preprocess (@) { #{{{
  18. my %params=@_;
  19. foreach my $param (qw{match pagespec}) {
  20. if (! exists $params{$param}) {
  21. error sprintf(gettext("%s parameter is required"), $param);
  22. }
  23. }
  24. add_depends($params{page}, $params{pagespec});
  25. my $ret=pagespec_match($params{match}, $params{pagespec},
  26. location => $params{page});
  27. if ($ret) {
  28. return "match: $ret";
  29. }
  30. else {
  31. return "no match: $ret";
  32. }
  33. } # }}}
  34. 1