X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/29507e94a46d0f2006671d31ac6812ebd0715cee..7a1e12675ec5f1ea605d4de06a0b82079073fb20:/IkiWiki/Render.pm diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 08f5e7e95..c5922c933 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -7,13 +7,14 @@ use strict; use File::Spec; use IkiWiki; -sub linkify ($$) { #{{{ +sub linkify ($$$) { #{{{ + my $lpage=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))) - : ( $1 ? "[[$3]]" : htmllink($page, titlepage($3))) + $2 ? ( $1 ? "[[$2|$3]]" : htmllink($lpage, $page, titlepage($3), 0, 0, pagetitle($2))) + : ( $1 ? "[[$3]]" : htmllink($lpage, $page, titlepage($3))) }eg; return $content; @@ -181,7 +182,7 @@ sub genpage ($$$) { #{{{ $actions++; } if ($config{discussion}) { - $template->param(discussionlink => htmllink($page, "Discussion", 1, 1)); + $template->param(discussionlink => htmllink($page, $page, "Discussion", 1, 1)); $actions++; } @@ -201,7 +202,7 @@ sub genpage ($$$) { #{{{ parentlinks => [parentlinks($page)], content => $content, backlinks => [backlinks($page)], - mtime => scalar(gmtime($mtime)), + mtime => displaytime($mtime), styleurl => styleurl($page), ); @@ -222,6 +223,18 @@ sub check_overwrite ($$) { #{{{ } } #}}} +sub displaytime ($) { #{{{ + my $time=shift; + + if ($config{timeformat} eq '%c') { + return scalar(localtime($time)); # optimisation + } + else { + eval q{use POSIX}; + return POSIX::strftime($config{timeformat}, localtime($time)); + } +} #}}} + sub mtime ($) { #{{{ my $file=shift; @@ -267,7 +280,7 @@ sub render ($) { #{{{ $links{$page}=[findlinks($page, $content)]; - $content=linkify($page, $content); + $content=linkify($page, $page, $content); $content=preprocess($page, $content); $content=htmlize($type, $content);