2007-04-27 09:55:40 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
package IkiWiki::Plugin::testpagespec;
|
|
|
|
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
2008-12-23 22:34:19 +01:00
|
|
|
use IkiWiki 3.00;
|
2007-04-27 09:55:40 +02:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub import {
|
2008-08-04 01:35:35 +02:00
|
|
|
hook(type => "getsetup", id => "testpagespec", call => \&getsetup);
|
2007-04-27 09:55:40 +02:00
|
|
|
hook(type => "preprocess", id => "testpagespec", call => \&preprocess);
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2007-04-27 09:55:40 +02:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub getsetup () {
|
2008-08-04 01:35:35 +02:00
|
|
|
return
|
|
|
|
plugin => {
|
|
|
|
safe => 1,
|
|
|
|
rebuild => undef,
|
|
|
|
},
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2008-08-04 01:35:35 +02:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub preprocess (@) {
|
2007-04-27 09:55:40 +02:00
|
|
|
my %params=@_;
|
|
|
|
|
2007-05-08 23:22:14 +02:00
|
|
|
foreach my $param (qw{match pagespec}) {
|
|
|
|
if (! exists $params{$param}) {
|
2008-07-13 21:05:34 +02:00
|
|
|
error sprintf(gettext("%s parameter is required"), $param);
|
2007-05-08 23:22:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-27 09:55:40 +02:00
|
|
|
add_depends($params{page}, $params{pagespec});
|
|
|
|
|
|
|
|
my $ret=pagespec_match($params{match}, $params{pagespec},
|
|
|
|
location => $params{page});
|
2007-04-27 10:34:09 +02:00
|
|
|
if ($ret) {
|
|
|
|
return "match: $ret";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return "no match: $ret";
|
|
|
|
}
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2007-04-27 09:55:40 +02:00
|
|
|
|
|
|
|
1
|