]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/CGI.pm
add htmlise
[ikiwiki.git] / IkiWiki / CGI.pm
index e02ab62a685da2e97da353d1c8a5b98cdf55ba1c..5e7f771719945155c01dcb1def77651dcb6dd599 100644 (file)
@@ -4,7 +4,8 @@ use warnings;
 use strict;
 use IkiWiki;
 use IkiWiki::UserInfo;
-use encoding 'utf8'; # force use of utf8 for io layer
+use open qw{:utf8 :std};
+use Encode;
 
 package IkiWiki;
 
@@ -33,11 +34,7 @@ sub cgi_recentchanges ($) { #{{{
        
        unlockwiki();
 
-       # Force reading the template as utf-8, necessary if
-       # rcs_recentchanges returns true utf-8 strings.
-       require Encode;
-       my $template=HTML::Template->new(filter => \&Encode::decode_utf8,
-               filename => "$config{templatedir}/recentchanges.tmpl");
+       my $template=template("recentchanges.tmpl"); 
        $template->param(
                title => "RecentChanges",
                indexlink => indexlink(),
@@ -72,7 +69,7 @@ sub cgi_signin ($$) { #{{{
                action => $config{cgiurl},
                header => 0,
                template => (-e "$config{templatedir}/signin.tmpl" ?
-                             "$config{templatedir}/signin.tmpl" : ""),
+                            {template_params("signin.tmpl")} : ""),
                stylesheet => styleurl(),
        );
        
@@ -185,9 +182,7 @@ sub cgi_signin ($$) { #{{{
                }
                elsif ($form->submitted eq 'Mail Password') {
                        my $user_name=$form->field("name");
-                       my $template=HTML::Template->new(
-                               filename => "$config{templatedir}/passwordmail.tmpl"
-                       );
+                       my $template=template("passwordmail.tmpl");
                        $template->param(
                                user_name => $user_name,
                                user_password => userinfo_get($user_name, "password"),
@@ -239,7 +234,7 @@ sub cgi_prefs ($$) { #{{{
                params => $q,
                action => $config{cgiurl},
                template => (-e "$config{templatedir}/prefs.tmpl" ?
-                             "$config{templatedir}/prefs.tmpl" : ""),
+                            {template_params("prefs.tmpl")} : ""),
                stylesheet => styleurl(),
        );
        my @buttons=("Save Preferences", "Logout", "Cancel");
@@ -308,13 +303,14 @@ sub cgi_editpage ($$) { #{{{
                params => $q,
                action => $config{cgiurl},
                table => 0,
-               template => "$config{templatedir}/editpage.tmpl"
+               template => {template_params("editpage.tmpl")},
        );
        my @buttons=("Save Page", "Preview", "Cancel");
        
        # This untaint is safe because titlepage removes any problimatic
        # characters.
-       my ($page)=titlepage(possibly_foolish_untaint(lc($form->param('page'))));
+       my ($page)=Encode::decode_utf8($form->param('page'));
+       $page=titlepage(possibly_foolish_untaint(lc($page)));
        if (! defined $page || ! length $page ||
            $page=~/$config{wiki_file_prune_regexp}/ || $page=~/^\//) {
                error("bad page name");
@@ -357,12 +353,12 @@ sub cgi_editpage ($$) { #{{{
                require IkiWiki::Render;
                # Apparently FormBuilder doesn't not treat input as
                # utf-8, so decode from it.
-               require Encode;
                my $content = Encode::decode_utf8($form->field('editcontent'));
+               my $comments = Encode::decode_utf8($form->field('comments'));
                $form->field(name => "editcontent",
                                value => $content, force => 1);
                $form->field(name => "comments",
-                               value => Encode::decode_utf8($form->field('comments')), force => 1);
+                               value => $comments, force => 1);
                $form->tmpl_param("page_preview",
                        htmlize($config{default_pageext},
                                linkify($page, $page, $content)));
@@ -446,7 +442,6 @@ sub cgi_editpage ($$) { #{{{
                page_locked($page, $session);
                
                # Decode utf-8 since FormBuilder does not
-               require Encode;
                my $content=Encode::decode_utf8($form->field('editcontent'));
 
                $content=~s/\r\n/\n/g;
@@ -463,7 +458,7 @@ sub cgi_editpage ($$) { #{{{
                }
                if (defined $form->field('comments') &&
                    length $form->field('comments')) {
-                       $message.=Encode::decode_utf8(": ".$form->field('comments'));
+                       $message.=": ".Encode::decode_utf8($form->field('comments'));
                }
                
                if ($config{rcs}) {