]> 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 0ac49ade9a155c9e52e01413517b4c1e34780e47..623396c9c4180929613a3b9ccbcdb139e923ebf6 100644 (file)
@@ -152,7 +152,7 @@ sub getsetup () {
        templatedir => {
                type => "string",
                default => "$installdir/share/ikiwiki/templates",
-               description => "location of template files",
+               description => "additional directory to search for template files",
                advanced => 1,
                safe => 0, # path
                rebuild => 1,
@@ -1531,8 +1531,8 @@ sub loadindex () {
                my $d=$pages->{$src};
                my $page=pagename($src);
                $pagectime{$page}=$d->{ctime};
+               $pagesources{$page}=$src;
                if (! $config{rebuild}) {
-                       $pagesources{$page}=$src;
                        $pagemtime{$page}=$d->{mtime};
                        $renderedfiles{$page}=$d->{dest};
                        if (exists $d->{links} && ref $d->{links}) {
@@ -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);