summaryrefslogtreecommitdiff
path: root/IkiWiki.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2010-04-26 18:47:17 -0400
committerJoey Hess <joey@kitenet.net>2010-04-26 18:47:17 -0400
commit3ac2ae1f14952bd92038183d92b1eb618c9d0f55 (patch)
treec07aa8d1dfde0049f9ae414db8fdab54266328b0 /IkiWiki.pm
parent194824ce293a64f7dce68d568d1f906d675af858 (diff)
Add page() PageSpec, which is like glob() but matches only pages, not other files.
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r--IkiWiki.pm10
1 files changed, 9 insertions, 1 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 944001d9b..623396c9c 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -2299,7 +2299,11 @@ sub match_glob ($$;@) {
my $regexp=IkiWiki::glob2re($glob);
if ($page=~/^$regexp$/i) {
- if (! IkiWiki::isinternal($page) || $params{internal}) {
+ if ($params{onlypage} &&
+ ! defined IkiWiki::pagetype($IkiWiki::pagesources{$page})) {
+ return IkiWiki::FailReason->new("$page is not a page");
+ }
+ elsif (! IkiWiki::isinternal($page) || $params{internal}) {
return IkiWiki::SuccessReason->new("$glob matches $page");
}
else {
@@ -2315,6 +2319,10 @@ sub match_internal ($$;@) {
return match_glob($_[0], $_[1], @_, internal => 1)
}
+sub match_page ($$;@) {
+ return match_glob($_[0], $_[1], @_, onlypage => 1)
+}
+
sub match_link ($$;@) {
my $page=shift;
my $link=lc(shift);