]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki.pm
move tupyakov's page under users/ (says 'hello' in Russian), remove surplus page
[ikiwiki.git] / IkiWiki.pm
index c428de77f7e055390e66fcdf53301f61ac2d9382..0f28801a60a354cf38b1b8f271133fb22acc60a0 100644 (file)
@@ -12,9 +12,9 @@ use open qw{:utf8 :std};
 
 use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase
        %pagestate %wikistate %renderedfiles %oldrenderedfiles
-       %pagesources %destsources %depends %depends_simple @mass_depends 
-       %hooks %forcerebuild %loaded_plugins %typedlinks %oldtypedlinks
-       %autofiles};
+       %pagesources %delpagesources %destsources %depends %depends_simple
+       @mass_depends %hooks %forcerebuild %loaded_plugins %typedlinks
+       %oldtypedlinks %autofiles};
 
 use Exporter q{import};
 our @EXPORT = qw(hook debug error htmlpage template template_depends
@@ -1004,7 +1004,7 @@ sub displaytime ($;$$) {
        my $time=formattime($_[0], $_[1]);
        if ($config{html5}) {
                return '<time datetime="'.date_3339($_[0]).'"'.
-                       ($_[2] ? ' pubdate' : '').
+                       ($_[2] ? ' pubdate="pubdate"' : '').
                        '>'.$time.'</time>';
        }
        else {
@@ -1401,10 +1401,6 @@ sub filter ($$$) {
        return $content;
 }
 
-sub indexlink () {
-       return "<a href=\"$config{url}\">$config{wikiname}</a>";
-}
-
 sub check_canedit ($$$;$) {
        my $page=shift;
        my $q=shift;
@@ -1742,24 +1738,50 @@ sub template ($;@) {
 
 sub misctemplate ($$;@) {
        my $title=shift;
-       my $pagebody=shift;
+       my $content=shift;
        
-       my $template=template("misc.tmpl");
+       my $template=template("page.tmpl");
+
+       run_hooks(pagetemplate => sub {
+               shift->(page => "", destpage => "", template => $template);
+       });
+       templateactions($template, "");
+
        $template->param(
+               dynamic => 1,
                title => $title,
-               indexlink => indexlink(),
                wikiname => $config{wikiname},
-               pagebody => $pagebody,
+               content => $content,
                baseurl => baseurl(),
                html5 => $config{html5},
                @_,
        );
-       run_hooks(pagetemplate => sub {
-               shift->(page => "", destpage => "", template => $template);
-       });
+       
        return $template->output;
 }
 
+sub templateactions ($$) {
+       my $template=shift;
+       my $page=shift;
+
+       my $have_actions=0;
+       my @actions;
+       run_hooks(pageactions => sub {
+               push @actions, map { { action => $_ } } 
+                       grep { defined } shift->(page => $page);
+       });
+       $template->param(actions => \@actions);
+
+       if ($config{cgiurl} && exists $hooks{auth}) {
+               $template->param(prefsurl => cgiurl(do => "prefs"));
+               $have_actions=1;
+       }
+
+       if ($have_actions || @actions) {
+               $template->param(have_actions => 1);
+       }
+}
+
 sub hook (@) {
        my %param=@_;
        
@@ -2329,11 +2351,7 @@ sub match_glob ($$;@) {
 
        my $regexp=IkiWiki::glob2re($glob);
        if ($page=~/^$regexp$/i) {
-               if ($params{onlypage} &&
-                   ! defined IkiWiki::pagetype($IkiWiki::pagesources{$page})) {
-                       return IkiWiki::FailReason->new("$page is not a page");
-               }
-               elsif (! IkiWiki::isinternal($page) || $params{internal}) {
+               if (! IkiWiki::isinternal($page) || $params{internal}) {
                        return IkiWiki::SuccessReason->new("$glob matches $page");
                }
                else {
@@ -2346,11 +2364,19 @@ sub match_glob ($$;@) {
 }
 
 sub match_internal ($$;@) {
-       return match_glob($_[0], $_[1], @_, internal => 1)
+       return match_glob(shift, shift, @_, internal => 1)
 }
 
 sub match_page ($$;@) {
-       return match_glob($_[0], $_[1], @_, onlypage => 1)
+       my $page=shift;
+       my $match=match_glob($page, shift, @_);
+       if ($match && ! (exists $IkiWiki::pagesources{$page}
+           && defined IkiWiki::pagetype($IkiWiki::pagesources{$page}))) {
+               return IkiWiki::FailReason->new("$page is not a page");
+       }
+       else {
+               return $match;
+       }
 }
 
 sub match_link ($$;@) {