sub getconfig () { #{{{
if (! exists $ENV{WRAPPED_OPTIONS}) {
%config=(
- wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.html?$)},
+ wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.html?$|\.rss$)},
wiki_link_regexp => qr/\[\[(?:([^\s\]\|]+)\|)?([^\s\]]+)\]\]/,
wiki_processor_regexp => qr/\[\[(\w+)\s+([^\]]+)\]\]/,
wiki_file_regexp => qr/(^[-A-Za-z0-9_.:\/+]+$)/,
rebuild => 0,
refresh => 0,
getctime => 0,
+ hyperestraier => 0,
wrapper => undef,
wrappermode => undef,
srcdir => undef,
destdir => undef,
templatedir => "/usr/share/ikiwiki/templates",
+ underlaydir => "/usr/share/ikiwiki/basewiki",
setup => undef,
adminuser => undef,
);
"wrappermode=i" => \$config{wrappermode},
"svn!" => \$config{svn},
"anonok!" => \$config{anonok},
+ "hyperestraier" => \$config{hyperestraier},
"rss!" => \$config{rss},
"cgi!" => \$config{cgi},
"url=s" => \$config{url},
"templatedir=s" => sub {
$config{templatedir}=possibly_foolish_untaint($_[1])
},
+ "underlaydir=s" => sub {
+ $config{underlaydir}=possibly_foolish_untaint($_[1])
+ },
"wrapper:s" => sub {
$config{wrapper}=$_[1] ? $_[1] : "ikiwiki-wrap"
},
if ($config{rss} && ! length $config{url}) {
error("Must specify url to wiki with --url when using --rss\n");
}
+ if ($config{hyperestraier} && ! length $config{url}) {
+ error("Must specify --url when using --hyperestraier\n");
+ }
$config{wikistatedir}="$config{srcdir}/.ikiwiki"
unless exists $config{wikistatedir};
return $page.".html";
} #}}}
+sub srcfile ($) { #{{{
+ 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");
+} #}}}
+
sub readfile ($) { #{{{
my $file=shift;
return $ret;
} #}}}
-sub writefile ($$) { #{{{
- my $file=shift;
+sub writefile ($$$) { #{{{
+ my $file=shift; # can include subdirs
+ my $destdir=shift; # directory to put file in
my $content=shift;
- if (-l $file) {
- error("cannot write to a symlink ($file)");
+ my $test=$file;
+ while (length $test) {
+ if (-l "$destdir/$test") {
+ error("cannot write to a symlink ($test)");
+ }
+ $test=dirname($test);
}
- my $dir=dirname($file);
+ my $dir=dirname("$destdir/$file");
if (! -d $dir) {
my $d="";
foreach my $s (split(m!/+!, $dir)) {
}
}
- open (OUT, ">$file") || error("failed to write $file: $!");
+ open (OUT, ">$destdir/$file") || error("failed to write $destdir/$file: $!");
print OUT $content;
close OUT;
} #}}}
wikiname => $config{wikiname},
pagebody => $pagebody,
styleurl => styleurl(),
+ baseurl => "$config{url}/",
);
return $template->output;
}#}}}