]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki.pm
Add page() PageSpec, which is like glob() but matches only pages, not other files.
[ikiwiki.git] / IkiWiki.pm
index 944001d9b43fd64e436a5e23d6668fa79220f7ec..623396c9c4180929613a3b9ccbcdb139e923ebf6 100644 (file)
@@ -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);