]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Render.pm
* Rebuilding on upgrade to this version is recommended.
[ikiwiki.git] / IkiWiki / Render.pm
index 9feaa6da7636b46940a101f9bbfbaf87aebde496..5bc7f6ebba91c4ebbb68e4a8d9a511082a47c3a8 100644 (file)
@@ -8,8 +8,8 @@ use File::Spec;
 use IkiWiki;
 
 sub linkify ($$) { #{{{
-       my $content=shift;
        my $page=shift;
+       my $content=shift;
 
        $content =~ s{(\\?)$config{wiki_link_regexp}}{
                $2 ? ( $1 ? "[[$2|$3]]" : htmllink($page, titlepage($3), 0, 0, pagetitle($2)))
@@ -152,8 +152,8 @@ sub globlist_merge ($$) { #{{{
 } #}}}
 
 sub genpage ($$$) { #{{{
-       my $content=shift;
        my $page=shift;
+       my $content=shift;
        my $mtime=shift;
 
        my $title=pagetitle(basename($page));
@@ -174,7 +174,15 @@ sub genpage ($$$) { #{{{
                $u=~s/\[\[file\]\]/$pagesources{$page}/g;
                $template->param(historyurl => $u);
        }
-       $template->param(headercontent => $config{headercontent});
+       if ($config{discussion}) {
+               $template->param(discussionlink => htmllink($page, "Discussion", 1, 1));
+       }
+
+       if (exists $hooks{pagetemplate}) {
+               foreach my $id (keys %{$hooks{pagetemplate}}) {
+                       $hooks{pagetemplate}{$id}{call}->($page, $template);
+               }
+       }
 
        $template->param(
                title => $title,
@@ -182,7 +190,6 @@ sub genpage ($$$) { #{{{
                parentlinks => [parentlinks($page)],
                content => $content,
                backlinks => [backlinks($page)],
-               discussionlink => htmllink($page, "Discussion", 1, 1),
                mtime => scalar(gmtime($mtime)),
                styleurl => styleurl($page),
        );
@@ -211,16 +218,21 @@ sub mtime ($) { #{{{
 } #}}}
 
 sub findlinks ($$) { #{{{
-       my $content=shift;
        my $page=shift;
+       my $content=shift;
 
        my @links;
        while ($content =~ /(?<!\\)$config{wiki_link_regexp}/g) {
                push @links, titlepage($2);
        }
-       # Discussion links are a special case since they're not in the text
-       # of the page, but on its template.
-       return @links, "$page/discussion";
+       if ($config{discussion}) {
+               # Discussion links are a special case since they're not in the
+               # text of the page, but on its template.
+               return @links, "$page/discussion";
+       }
+       else {
+               return @links;
+       }
 } #}}}
 
 sub render ($) { #{{{
@@ -242,15 +254,15 @@ sub render ($) { #{{{
                        }
                }
                
-               $links{$page}=[findlinks($content, $page)];
+               $links{$page}=[findlinks($page, $content)];
                
-               $content=linkify($content, $page);
+               $content=linkify($page, $content);
                $content=preprocess($page, $content);
                $content=htmlize($type, $content);
                
                check_overwrite("$config{destdir}/".htmlpage($page), $page);
                writefile(htmlpage($page), $config{destdir},
-                       genpage($content, $page, mtime($srcfile)));
+                       genpage($page, $content, mtime($srcfile)));
                $oldpagemtime{$page}=time;
                $renderedfiles{$page}=htmlpage($page);
        }