X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/ec866f83703e63c0750df0b955a3288434a127b3..50ac3aa79c28b517af71ef876b7b60146365a3d6:/IkiWiki/Render.pm diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 959279fc8..e76dcef3d 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -80,7 +80,7 @@ sub genpage ($$) { #{{{ my $actions=0; if (length $config{cgiurl}) { - $template->param(editurl => cgiurl(do => "edit", page => pagetitle($page, 1))); + $template->param(editurl => cgiurl(do => "edit", page => $page)); $template->param(prefsurl => cgiurl(do => "prefs")); $actions++; } @@ -135,6 +135,10 @@ sub genpage ($$) { #{{{ }); $content=$template->output; + + run_hooks(postscan => sub { + shift->(page => $page, content => $content); + }); run_hooks(format => sub { $content=shift->( @@ -156,10 +160,6 @@ sub scan ($) { #{{{ my $page=pagename($file); will_render($page, htmlpage($page), 1); - # Always needs to be done, since filters might add links - # to the content. - $content=filter($page, $page, $content); - if ($config{discussion}) { # Discussion links are a special case since they're # not in the text of the page, but on its template. @@ -184,6 +184,30 @@ sub scan ($) { #{{{ } } #}}} +sub fast_file_copy (@) { #{{{ + my $srcfile=shift; + my $destfile=shift; + my $srcfd=shift; + my $destfd=shift; + my $cleanup=shift; + + my $blksize = 16384; + my ($len, $buf, $written); + while ($len = sysread $srcfd, $buf, $blksize) { + if (! defined $len) { + next if $! =~ /^Interrupted/; + error("failed to read $srcfile: $!", $cleanup); + } + my $offset = 0; + while ($len) { + defined($written = syswrite $destfd, $buf, $len, $offset) + or error("failed to write $destfile: $!", $cleanup); + $len -= $written; + $offset += $written; + } + } +} + sub render ($) { #{{{ my $file=shift; @@ -195,7 +219,7 @@ sub render ($) { #{{{ will_render($page, htmlpage($page), 1); return if $type=~/^_/; - my $content=htmlize($page, $type, + my $content=htmlize($page, $page, $type, linkify($page, $page, preprocess($page, $page, filter($page, $page, @@ -214,29 +238,12 @@ sub render ($) { #{{{ if (link($srcfile, $config{destdir}."/".$file)) { return; } - # if hardlink fails, fall back top copying + # if hardlink fails, fall back to copying } my $srcfd=readfile($srcfile, 1, 1); writefile($file, $config{destdir}, undef, 1, sub { - my $destfd=shift; - my $cleanup=shift; - - my $blksize = 16384; - my ($len, $buf, $written); - while ($len = sysread $srcfd, $buf, $blksize) { - if (! defined $len) { - next if $! =~ /^Interrupted/; - error("failed to read $srcfile: $!", $cleanup); - } - my $offset = 0; - while ($len) { - defined($written = syswrite $destfd, $buf, $len, $offset) - or error("failed to write $file: $!", $cleanup); - $len -= $written; - $offset += $written; - } - } + fast_file_copy($srcfile, $file, $srcfd, @_); }); } } #}}} @@ -508,8 +515,6 @@ sub refresh () { #{{{ } #}}} sub commandline_render () { #{{{ - loadplugins(); - checkconfig(); lockwiki(); loadindex(); unlockwiki(); @@ -526,7 +531,7 @@ sub commandline_render () { #{{{ $content=filter($page, $page, $content); $content=preprocess($page, $page, $content); $content=linkify($page, $page, $content); - $content=htmlize($page, $type, $content); + $content=htmlize($page, $page, $type, $content); $pagemtime{$page}=(stat($srcfile))[9]; print genpage($page, $content);