]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki.pm
* Response
[ikiwiki.git] / IkiWiki.pm
index d4e19c388fa19c8abfd75b6504b3190910e13536..01e7cc1e4c1febee4d84209c281e84a78deb7198 100644 (file)
@@ -77,7 +77,8 @@ sub defaultconfig () { #{{{
        adminuser => undef,
        adminemail => undef,
        plugin => [qw{mdwn link inline htmlscrubber passwordauth openid
-                       signinedit lockedit conditional recentchanges}],
+                       signinedit lockedit conditional recentchanges
+                       parentlinks}],
        libdir => undef,
        timeformat => '%c',
        locale => undef,
@@ -537,17 +538,18 @@ sub beautify_urlpath ($) { #{{{
 
        # Ensure url is not an empty link, and
        # if it's relative, make that explicit to avoid colon confusion.
-       if ($url !~ /\//) {
+       if ($url !~ /^\//) {
                $url="./$url";
        }
 
        return $url;
 } #}}}
 
-sub urlto ($$) { #{{{
+sub urlto ($$;$) { #{{{
        my $to=shift;
        my $from=shift;
-
+       my $absolute=shift;
+       
        if (! length $to) {
                return beautify_urlpath(baseurl($from)."index.$config{htmlext}");
        }
@@ -556,6 +558,10 @@ sub urlto ($$) { #{{{
                $to=htmlpage($to);
        }
 
+       if ($absolute) {
+               return $config{url}.beautify_urlpath("/".$to);
+       }
+
        my $link = abs2rel($to, dirname(htmlpage($from)));
 
        return beautify_urlpath($link);
@@ -768,21 +774,30 @@ sub preprocess ($$$;$$) { #{{{
                        }
                        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
-                               $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}--;
@@ -816,7 +831,8 @@ sub preprocess ($$$;$$) { #{{{
                        *)?             # 0 or more parameters
                        \]\]            # directive closed
                }sx;
-       } else {
+       }
+       else {
                $regex = qr{
                        (\\?)           # 1: escape?
                        \[\[(!?)        # directive open; 2: optional prefix