X-Git-Url: https://scripts.mit.edu/gitweb/www/ikiwiki.git/blobdiff_plain/e41dd1e24e345c974fe4a070088f0d09d1b6ddac..2ac1e80db3dbfa1e651bfeac4c13d0db1c3e12bc:/ikiwiki
diff --git a/ikiwiki b/ikiwiki
index 62a9767b9..f7ccaf743 100755
--- a/ikiwiki
+++ b/ikiwiki
@@ -18,7 +18,7 @@ sub usage () { #{{{
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_.:\/+]+$)/,
@@ -36,11 +36,13 @@ sub getconfig () { #{{{
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,
);
@@ -56,6 +58,7 @@ sub getconfig () { #{{{
"wrappermode=i" => \$config{wrappermode},
"svn!" => \$config{svn},
"anonok!" => \$config{anonok},
+ "hyperestraier" => \$config{hyperestraier},
"rss!" => \$config{rss},
"cgi!" => \$config{cgi},
"url=s" => \$config{url},
@@ -71,6 +74,9 @@ sub getconfig () { #{{{
"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"
},
@@ -98,6 +104,9 @@ sub checkconfig () { #{{{
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};
@@ -176,6 +185,14 @@ sub htmlpage ($) { #{{{
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;
@@ -190,15 +207,20 @@ sub readfile ($) { #{{{
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)) {
@@ -209,7 +231,7 @@ sub writefile ($$) { #{{{
}
}
- open (OUT, ">$file") || error("failed to write $file: $!");
+ open (OUT, ">$destdir/$file") || error("failed to write $destdir/$file: $!");
print OUT $content;
close OUT;
} #}}}
@@ -255,7 +277,7 @@ sub pagetitle ($) { #{{{
sub titlepage ($) { #{{{
my $title=shift;
$title=~y/ /_/;
- $title=~s/([^-A-Za-z0-9_:+\/])/"__".ord($1)."__"/eg;
+ $title=~s/([^-A-Za-z0-9_:+\/.])/"__".ord($1)."__"/eg;
return $title;
} #}}}
@@ -265,6 +287,16 @@ sub cgiurl (@) { #{{{
return $config{cgiurl}."?".join("&", map "$_=$params{$_}", keys %params);
} #}}}
+sub styleurl (;$) { #{{{
+ my $page=shift;
+
+ return "$config{url}/style.css" if ! defined $page;
+
+ $page=~s/[^\/]+$//;
+ $page=~s/[^\/]+\//..\//g;
+ return $page."style.css";
+} #}}}
+
sub htmllink ($$;$$$) { #{{{
my $page=shift;
my $link=shift;
@@ -300,7 +332,7 @@ sub htmllink ($$;$$$) { #{{{
$bestlink=File::Spec->abs2rel($bestlink, dirname($page));
if (! $noimageinline && isinlinableimage($bestlink)) {
- return "
";
+ return "
";
}
return "$linktext";
} #}}}
@@ -395,6 +427,8 @@ sub misctemplate ($$) { #{{{
indexlink => indexlink(),
wikiname => $config{wikiname},
pagebody => $pagebody,
+ styleurl => styleurl(),
+ baseurl => "$config{url}/",
);
return $template->output;
}#}}}