our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match
bestlink htmllink readfile writefile pagetype srcfile pagename
displaytime will_render gettext urlto targetpage
+ add_underlay
%config %links %renderedfiles %pagesources %destsources);
our $VERSION = 2.00; # plugin interface version, next is ikiwiki version
our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE
wiki_file_prune_regexps => [qr/\.\./, qr/^\./, qr/\/\./,
qr/\.x?html?$/, qr/\.ikiwiki-new$/,
qr/(^|\/).svn\//, qr/.arch-ids\//, qr/{arch}\//,
+ qr/(^|\/)_MTN\//,
qr/\.dpkg-tmp$/],
wiki_link_regexp => qr{
\[\[ # beginning of link
(?:
- ([^\]\|]+) # 1: link text
+ ([^\]\|\n]+) # 1: link text
\| # followed by '|'
)? # optional
pingurl => [],
templatedir => "$installdir/share/ikiwiki/templates",
underlaydir => "$installdir/share/ikiwiki/basewiki",
+ underlaydirs => [],
setup => undef,
adminuser => undef,
adminemail => undef,
sub loadplugins () { #{{{
if (defined $config{libdir}) {
- unshift @INC, $config{libdir};
+ unshift @INC, possibly_foolish_untaint($config{libdir});
}
loadplugin($_) foreach @{$config{plugin}};
return if grep { $_ eq $plugin} @{$config{disable_plugins}};
- foreach my $dir ($config{libdir}, "$installdir/lib/ikiwiki") {
+ foreach my $dir (defined $config{libdir} ? possibly_foolish_untaint($config{libdir}) : undef,
+ "$installdir/lib/ikiwiki") {
if (defined $dir && -x "$dir/plugins/$plugin") {
require IkiWiki::Plugin::external;
import IkiWiki::Plugin::external "$dir/plugins/$plugin";
my $file=shift;
return "$config{srcdir}/$file" if -e "$config{srcdir}/$file";
- return "$config{underlaydir}/$file" if -e "$config{underlaydir}/$file";
- error("internal error: $file cannot be found in $config{srcdir} or $config{underlaydir}");
+ foreach my $dir (@{$config{underlaydirs}}, $config{underlaydir}) {
+ return "$dir/$file" if -e "$dir/$file";
+ }
+ error("internal error: $file cannot be found in $config{srcdir} or underlay");
return;
} #}}}
+sub add_underlay ($) { #{{{
+ my $dir=shift;
+
+ if ($dir=~/^\//) {
+ unshift @{$config{underlaydirs}}, $dir;
+ }
+ else {
+ unshift @{$config{underlaydirs}}, "$config{underlaydir}/../$dir";
+ }
+
+ return 1;
+} #}}}
+
sub readfile ($;$$) { #{{{
my $file=shift;
my $binary=shift;
} #}}}
sub unlockwiki () { #{{{
- return close($wikilock);
+ return close($wikilock) if $wikilock;
+ return;
} #}}}
my $commitlock;
} #}}}
sub enable_commit_hook () { #{{{
- return close($commitlock);
+ return close($commitlock) if $commitlock;
+ return;
} #}}}
sub loadindex () { #{{{
sub gettext { #{{{
# Only use gettext in the rare cases it's needed.
- if (exists $ENV{LANG} || exists $ENV{LC_ALL} || exists $ENV{LC_MESSAGES}) {
+ if ((exists $ENV{LANG} && length $ENV{LANG}) ||
+ (exists $ENV{LC_ALL} && length $ENV{LC_ALL}) ||
+ (exists $ENV{LC_MESSAGES} && length $ENV{LC_MESSAGES})) {
if (! $gettext_obj) {
$gettext_obj=eval q{
use Locale::gettext q{textdomain};