X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/97aea861624d1a1c6127857adb19dce16eab510e..10b64297d3f754f8de49f02766b434ea8f4ad830:/IkiWiki.pm diff --git a/IkiWiki.pm b/IkiWiki.pm index dfd224062..32ca0449f 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -854,23 +854,35 @@ sub pagespec_translate ($) { #{{{ $code.=" match_$1(\$page, ".safequote($2).")"; } else { - $code.=" match_glob(\$page, ".safequote($word).")"; + $code.=" match_glob(\$page, ".safequote($word).", \$from)"; } } return $code; } #}}} -sub pagespec_match ($$) { #{{{ +sub pagespec_match ($$;$) { #{{{ my $page=shift; my $spec=shift; + my $from=shift; + if (! defined $from){ + $from = ""; + } return eval pagespec_translate($spec); } #}}} -sub match_glob ($$) { #{{{ +sub match_glob ($$$) { #{{{ my $page=shift; my $glob=shift; + my $from=shift; + + # relative matching + if ($glob =~ m!^\./!) { + $from=~s!/?[^/]+$!!; + $glob=~s!^\./!!; + $glob="$from/$glob" if length $from; + } # turn glob into safe regexp $glob=quotemeta($glob);