X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/e1d456a86ff808f1bc8e73c7c5d882017bd48d89..76c7664c5085db8f8d97f2f6c68a0909f18a1ddc:/IkiWiki.pm diff --git a/IkiWiki.pm b/IkiWiki.pm index 68047b9b9..7d5668d74 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -103,6 +103,12 @@ sub checkconfig () { #{{{ } } + if (ref $config{ENV} eq 'HASH') { + foreach my $val (keys %{$config{ENV}}) { + $ENV{$val}=$config{ENV}{$val}; + } + } + if ($config{w3mmode}) { eval q{use Cwd q{abs_path}}; error($@) if $@; @@ -282,17 +288,22 @@ sub htmlpage ($) { #{{{ return targetpage($page, $config{htmlext}); } #}}} -sub srcfile ($) { #{{{ +sub srcfile_stat { #{{{ my $file=shift; + my $nothrow=shift; - return "$config{srcdir}/$file" if -e "$config{srcdir}/$file"; + return "$config{srcdir}/$file", stat(_) if -e "$config{srcdir}/$file"; foreach my $dir (@{$config{underlaydirs}}, $config{underlaydir}) { - return "$dir/$file" if -e "$dir/$file"; + return "$dir/$file", stat(_) if -e "$dir/$file"; } - error("internal error: $file cannot be found in $config{srcdir} or underlay"); + error("internal error: $file cannot be found in $config{srcdir} or underlay") unless $nothrow; return; } #}}} +sub srcfile ($;$) { #{{{ + return (srcfile_stat(@_))[0]; +} #}}} + sub add_underlay ($) { #{{{ my $dir=shift; @@ -536,7 +547,7 @@ sub urlto ($$) { #{{{ my $from=shift; if (! length $to) { - return beautify_url(baseurl($from)); + return beautify_url(baseurl($from)."index.$config{htmlext}"); } if (! $destsources{$to}) { @@ -587,7 +598,7 @@ sub htmllink ($$$;@) { #{{{ page => pagetitle(lc($link), 1), from => $lpage ). - "\">?$linktext" + "\" rel=\"nofollow\">?$linktext" } } @@ -630,8 +641,9 @@ sub userlink ($) { #{{{ } } #}}} -sub htmlize ($$$) { #{{{ +sub htmlize ($$$$) { #{{{ my $page=shift; + my $destpage=shift; my $type=shift; my $content=shift; @@ -650,6 +662,7 @@ sub htmlize ($$$) { #{{{ run_hooks(sanitize => sub { $content=shift->( page => $page, + destpage => $destpage, content => $content, ); }); @@ -681,7 +694,7 @@ sub linkify ($$$) { #{{{ return $content; } #}}} -my %preprocessing; +our %preprocessing; our $preprocess_preview=0; sub preprocess ($$$;$$) { #{{{ my $page=shift; # the page the data comes from @@ -1247,6 +1260,11 @@ sub pagespec_translate ($) { #{{{ } } + if (! length $code) { + $code=0; + } + + no warnings; return eval 'sub { my $page=shift; '.$code.' }'; } #}}} @@ -1261,7 +1279,7 @@ sub pagespec_match ($$;@) { #{{{ } my $sub=pagespec_translate($spec); - return IkiWiki::FailReason->new('syntax error') if $@; + return IkiWiki::FailReason->new("syntax error in pagespec \"$spec\"") if $@; return $sub->($page, @params); } #}}} @@ -1282,7 +1300,9 @@ use overload ( #{{{ ); #}}} sub new { #{{{ - return bless \$_[1], $_[0]; + my $class = shift; + my $value = shift; + return bless \$value, $class; } #}}} package IkiWiki::SuccessReason; @@ -1295,7 +1315,9 @@ use overload ( #{{{ ); #}}} sub new { #{{{ - return bless \$_[1], $_[0]; + my $class = shift; + my $value = shift; + return bless \$value, $class; }; #}}} package IkiWiki::PageSpec;