]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki.pm
some design work on rename/delete
[git.ikiwiki.info.git] / IkiWiki.pm
index c1d9119e840662f449d0cd257c0ca1c14df48653..80e31711062694fb9494306e5900df4ca54f8b2f 100644 (file)
@@ -189,11 +189,6 @@ sub loadplugin ($) { #{{{
 sub error ($;$) { #{{{
        my $message=shift;
        my $cleaner=shift;
 sub error ($;$) { #{{{
        my $message=shift;
        my $cleaner=shift;
-       if ($config{cgi}) {
-               print "Content-type: text/html\n\n";
-               print misctemplate(gettext("Error"),
-                       "<p>".gettext("Error").": $message</p>");
-       }
        log_message('err' => $message) if $config{syslog};
        if (defined $cleaner) {
                $cleaner->();
        log_message('err' => $message) if $config{syslog};
        if (defined $cleaner) {
                $cleaner->();
@@ -337,7 +332,7 @@ sub readfile ($;$$) { #{{{
        return $ret;
 } #}}}
 
        return $ret;
 } #}}}
 
-sub prep_writefile ($$) {
+sub prep_writefile ($$) { #{{{
        my $file=shift;
        my $destdir=shift;
        
        my $file=shift;
        my $destdir=shift;
        
@@ -361,7 +356,7 @@ sub prep_writefile ($$) {
        }
 
        return 1;
        }
 
        return 1;
-}
+} #}}}
 
 sub writefile ($$$;$$) { #{{{
        my $file=shift; # can include subdirs
 
 sub writefile ($$$;$$) { #{{{
        my $file=shift; # can include subdirs
@@ -773,21 +768,30 @@ sub preprocess ($$$;$$) { #{{{
                        }
                        my $ret;
                        if (! $scan) {
                        }
                        my $ret;
                        if (! $scan) {
-                               $ret=$hooks{preprocess}{$command}{call}->(
-                                       @params,
-                                       page => $page,
-                                       destpage => $destpage,
-                                       preview => $preprocess_preview,
-                               );
+                               $ret=eval {
+                                       $hooks{preprocess}{$command}{call}->(
+                                               @params,
+                                               page => $page,
+                                               destpage => $destpage,
+                                               preview => $preprocess_preview,
+                                       );
+                               };
+                               if ($@) {
+                                       chomp $@;
+                                       $ret="[[!$command <span class=\"error\">".
+                                               gettext("Error").": $@"."</span>]]";
+                               }
                        }
                        else {
                                # use void context during scan pass
                        }
                        else {
                                # use void context during scan pass
-                               $hooks{preprocess}{$command}{call}->(
-                                       @params,
-                                       page => $page,
-                                       destpage => $destpage,
-                                       preview => $preprocess_preview,
-                               );
+                               eval {
+                                       $hooks{preprocess}{$command}{call}->(
+                                               @params,
+                                               page => $page,
+                                               destpage => $destpage,
+                                               preview => $preprocess_preview,
+                                       );
+                               };
                                $ret="";
                        }
                        $preprocessing{$page}--;
                                $ret="";
                        }
                        $preprocessing{$page}--;
@@ -1202,6 +1206,12 @@ sub gettext { #{{{
        }
 } #}}}
 
        }
 } #}}}
 
+sub yesno ($) { #{{{
+       my $val=shift;
+
+       return (defined $val && lc($val) eq gettext("yes"));
+} #}}}
+
 sub pagespec_merge ($$) { #{{{
        my $a=shift;
        my $b=shift;
 sub pagespec_merge ($$) { #{{{
        my $a=shift;
        my $b=shift;