]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki.pm
template: Fix typo.
[ikiwiki.git] / IkiWiki.pm
index c218ed8ab037bd7f5ca65aad6dc45d70ce19a709..623396c9c4180929613a3b9ccbcdb139e923ebf6 100644 (file)
@@ -13,8 +13,8 @@ use open qw{:utf8 :std};
 
 use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase
        %pagestate %wikistate %renderedfiles %oldrenderedfiles
-       %pagesources %destsources %depends %depends_simple %hooks
-       %forcerebuild %loaded_plugins %typedlinks %oldtypedlinks
+       %pagesources %destsources %depends %depends_simple @mass_depends 
+       %hooks %forcerebuild %loaded_plugins %typedlinks %oldtypedlinks
        %autofiles};
 
 use Exporter q{import};
@@ -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}) {
@@ -1654,7 +1654,7 @@ sub saveindex () {
 sub template_file ($) {
        my $name=shift;
        
-       my $tpage=($name =~ /^\//) ? $name : "templates/$name";
+       my $tpage=($name =~ s/^\///) ? $name : "templates/$name";
        if ($name !~ /\.tmpl$/ && exists $pagesources{$tpage}) {
                $tpage=$pagesources{$tpage};
                $name.=".tmpl";
@@ -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);