]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Render.pm
utf-8 support seems to be working now
[ikiwiki.git] / IkiWiki / Render.pm
index b59a721c0408d398e367ca320cb28b5265e9d2f5..08f5e7e951245e7b35b237db99ac76949c3aa2cb 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)))
@@ -28,10 +28,13 @@ sub htmlize ($$) { #{{{
                $blosxom::version="is a proper perl module too much to ask?";
                use warnings 'all';
                do "/usr/bin/markdown";
+               require Encode;
        }
        
        if ($type eq '.mdwn') {
-               $content=Markdown::Markdown($content);
+               # Markdown does character based stuff that does not work
+               # well with utf-8 strings.
+               $content=Encode::decode_utf8(Markdown::Markdown(Encode::encode_utf8($content)));
        }
        else {
                error("htmlization of $type not supported");
@@ -152,30 +155,38 @@ sub globlist_merge ($$) { #{{{
 } #}}}
 
 sub genpage ($$$) { #{{{
-       my $content=shift;
        my $page=shift;
+       my $content=shift;
        my $mtime=shift;
 
        my $title=pagetitle(basename($page));
        
        my $template=HTML::Template->new(blind_cache => 1,
                filename => "$config{templatedir}/page.tmpl");
-       
+       my $actions=0;
+
        if (length $config{cgiurl}) {
                $template->param(editurl => cgiurl(do => "edit", page => $page));
                $template->param(prefsurl => cgiurl(do => "prefs"));
                if ($config{rcs}) {
                        $template->param(recentchangesurl => cgiurl(do => "recentchanges"));
                }
+               $actions++;
        }
 
        if (length $config{historyurl}) {
                my $u=$config{historyurl};
                $u=~s/\[\[file\]\]/$pagesources{$page}/g;
                $template->param(historyurl => $u);
+               $actions++;
        }
        if ($config{discussion}) {
                $template->param(discussionlink => htmllink($page, "Discussion", 1, 1));
+               $actions++;
+       }
+
+       if ($actions) {
+               $template->param(have_actions => 1);
        }
 
        if (exists $hooks{pagetemplate}) {
@@ -218,8 +229,8 @@ sub mtime ($) { #{{{
 } #}}}
 
 sub findlinks ($$) { #{{{
-       my $content=shift;
        my $page=shift;
+       my $content=shift;
 
        my @links;
        while ($content =~ /(?<!\\)$config{wiki_link_regexp}/g) {
@@ -254,15 +265,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);
        }
@@ -347,8 +358,12 @@ sub refresh () { #{{{
                        push @add, $file;
                        $links{$page}=[];
                        $pagesources{$page}=$file;
-                       $pagectime{$page}=mtime(srcfile($file))
-                               unless exists $pagectime{$page};
+                       if ($config{getctime} && -e "$config{srcdir}/$file") {
+                               $pagectime{$page}=rcs_getctime("$config{srcdir}/$file");
+                       }
+                       elsif (! exists $pagectime{$page}) {
+                               $pagectime{$page}=mtime(srcfile($file));
+                       }
                }
        }
        my @del;