]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/testpagespec.pm
note new bug
[git.ikiwiki.info.git] / IkiWiki / Plugin / testpagespec.pm
index 56dc03cef98ad67c0e979397189185c1c2c8708c..a6e94dbbb5a2e88867a4ac03d49d65b141949446 100644 (file)
@@ -5,19 +5,38 @@ use warnings;
 use strict;
 use IkiWiki 2.00;
 
-sub import { #{{{
+sub import {
+       hook(type => "getsetup", id => "testpagespec", call => \&getsetup);
        hook(type => "preprocess", id => "testpagespec", call => \&preprocess);
-} # }}}
+}
 
-sub preprocess (@) { #{{{
+sub getsetup () {
+       return
+               plugin => {
+                       safe => 1,
+                       rebuild => undef,
+               },
+}
+
+sub preprocess (@) {
        my %params=@_;
        
+       foreach my $param (qw{match pagespec}) {
+               if (! exists $params{$param}) {
+                       error sprintf(gettext("%s parameter is required"), $param);
+               }
+       }
+
        add_depends($params{page}, $params{pagespec});
        
        my $ret=pagespec_match($params{match}, $params{pagespec}, 
                        location => $params{page});
-       return $ret if ! $ret;
-       return "the pagespec matches";
-} # }}}
+       if ($ret) {
+               return "match: $ret";
+       }
+       else {
+               return "no match: $ret";
+       }
+}
 
 1