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,
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->();
return $ret;
} #}}}
-sub prep_writefile ($$) {
+sub prep_writefile ($$) { #{{{
my $file=shift;
my $destdir=shift;
}
return 1;
-}
+} #}}}
sub writefile ($$$;$$) { #{{{
my $file=shift; # can include subdirs
return decode_utf8(POSIX::strftime($format, localtime($time)));
} #}}}
-sub beautify_url ($) { #{{{
+sub beautify_urlpath ($) { #{{{
my $url=shift;
if ($config{usedirs}) {
# 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";
}
my $from=shift;
if (! length $to) {
- return beautify_url(baseurl($from)."index.$config{htmlext}");
+ return beautify_urlpath(baseurl($from)."index.$config{htmlext}");
}
if (! $destsources{$to}) {
my $link = abs2rel($to, dirname(htmlpage($from)));
- return beautify_url($link);
+ return beautify_urlpath($link);
} #}}}
sub htmllink ($$$;@) { #{{{
}
$bestlink=abs2rel($bestlink, dirname(htmlpage($page)));
- $bestlink=beautify_url($bestlink);
+ $bestlink=beautify_urlpath($bestlink);
if (! $opts{noimageinline} && isinlinableimage($bestlink)) {
return "<img src=\"$bestlink\" alt=\"$linktext\" />";
}
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}--;
*)? # 0 or more parameters
\]\] # directive closed
}sx;
- } else {
+ }
+ else {
$regex = qr{
(\\?) # 1: escape?
\[\[(!?) # directive open; 2: optional prefix
}
} #}}}
+sub yesno ($) { #{{{
+ my $val=shift;
+
+ return (defined $val && lc($val) eq gettext("yes"));
+} #}}}
+
sub pagespec_merge ($$) { #{{{
my $a=shift;
my $b=shift;