]> scripts.mit.edu Git - www/ikiwiki.git/blobdiff - IkiWiki/Render.pm
* Support pages with utf8 filenames. Patch by Faidon Liambotis.
[www/ikiwiki.git] / IkiWiki / Render.pm
index 22fba3a2fd1fe935e20b0fc2d5fc724d0219a790..e778ff20c93b25a5b28a297e418e71209b1b685a 100644 (file)
@@ -25,15 +25,22 @@ sub htmlize ($$) { #{{{
        my $content=shift;
        
        if (! $INC{"/usr/bin/markdown"}) {
+               # Note: a proper perl module is available in Debian
+               # for markdown, but not upstream yet.
                no warnings 'once';
                $blosxom::version="is a proper perl module too much to ask?";
                use warnings 'all';
                do "/usr/bin/markdown";
-               use Encode;
+               require Encode;
        }
        
        if ($type eq '.mdwn') {
-               $content=Encode::decode_utf8(Markdown::Markdown(Encode::encode_utf8($content)));
+               # Workaround for perl bug (#376329)
+               $content=Encode::encode_utf8($content);
+               $content=Encode::encode_utf8($content);
+               $content=Markdown::Markdown($content);
+               $content=Encode::decode_utf8($content);
+               $content=Encode::decode_utf8($content);
        }
        else {
                error("htmlization of $type not supported");
@@ -166,8 +173,7 @@ sub genpage ($$$) { #{{{
 
        my $title=pagetitle(basename($page));
        
-       my $template=HTML::Template->new(blind_cache => 1,
-               filename => "$config{templatedir}/page.tmpl");
+       my $template=template("page.tmpl", blind_cache => 1);
        my $actions=0;
 
        if (length $config{cgiurl}) {
@@ -230,13 +236,11 @@ sub check_overwrite ($$) { #{{{
 sub displaytime ($) { #{{{
        my $time=shift;
 
-       if ($config{timeformat} eq '%c' && ! exists $ENV{LC_CTIME}) {
-               return scalar(localtime($time)); # optimisation
-       }
-       else {
-               eval q{use POSIX};
-               return POSIX::strftime($config{timeformat}, localtime($time));
-       }
+       eval q{use POSIX};
+       # strftime doesn't know about encodings, so make sure
+       # its output is properly treated as utf8
+       return Encode::decode_utf8(POSIX::strftime(
+                       $config{timeformat}, localtime($time)));
 } #}}}
 
 sub mtime ($) { #{{{
@@ -320,9 +324,11 @@ sub refresh () { #{{{
        my %exists;
        my @files;
        eval q{use File::Find};
+       require Encode;
        find({
                no_chdir => 1,
                wanted => sub {
+                       $_ = Encode::decode_utf8($_);
                        if (/$config{wiki_file_prune_regexp}/) {
                                $File::Find::prune=1;
                        }
@@ -342,6 +348,7 @@ sub refresh () { #{{{
        find({
                no_chdir => 1,
                wanted => sub {
+                       $_ = Encode::decode_utf8($_);
                        if (/$config{wiki_file_prune_regexp}/) {
                                $File::Find::prune=1;
                        }
@@ -401,7 +408,7 @@ sub refresh () { #{{{
                
                if (! exists $oldpagemtime{$page} ||
                    mtime(srcfile($file)) > $oldpagemtime{$page}) {
-                       debug("rendering changed file $file");
+                       debug("rendering $file");
                        render($file);
                        $rendered{$file}=1;
                }