summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-03-29 18:21:01 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-03-29 18:21:01 +0000
commit975ae0944cdd18a510d803da7a499c2247ac855e (patch)
tree64b60d576903f4ebdb694fdf40f84b9a5927dced /IkiWiki
parent20fd32fcf3bfa8653fb876117970ebd07cc1bb35 (diff)
Implemented --underlaydir, and moved files provided by underlay out of doc
so I don't need to maintain two copies anymore. You might also want to remove the files provided in the basewiki underlay from your wiki, if you have not created custom local versions of them, so that these pages will be automatically updated in future ikiwiki upgrades.
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/CGI.pm2
-rw-r--r--IkiWiki/Rcs/SVN.pm1
-rw-r--r--IkiWiki/Render.pm39
3 files changed, 33 insertions, 9 deletions
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index 67bce6795..6fd1f6506 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -403,7 +403,7 @@ sub cgi_editpage ($$) { #{{{
! length $form->field('content')) {
my $content="";
if (exists $pagesources{lc($page)}) {
- $content=readfile("$config{srcdir}/$pagesources{lc($page)}");
+ $content=readfile(srcfile($pagesources{lc($page)}));
$content=~s/\n/\r\n/g;
}
$form->field(name => "content", value => $content,
diff --git a/IkiWiki/Rcs/SVN.pm b/IkiWiki/Rcs/SVN.pm
index 083b869df..02fc3ed31 100644
--- a/IkiWiki/Rcs/SVN.pm
+++ b/IkiWiki/Rcs/SVN.pm
@@ -171,6 +171,7 @@ sub rcs_getctime () { #{{{
eval q{use Date::Parse};
foreach my $page (keys %pagectime) {
my $file="$config{srcdir}/$pagesources{$page}";
+ next unless -e $file;
my $child = open(SVNLOG, "-|");
if (! $child) {
exec("svn", "log", $file) || error("svn log $file failed to run");
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index 7d1e8ee53..3d827d341 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -139,7 +139,7 @@ sub get_inline_content ($$) { #{{{
my $file=$pagesources{$page};
my $type=pagetype($file);
if ($type ne 'unknown') {
- return htmlize($type, linkify(readfile("$config{srcdir}/$file"), $parentpage));
+ return htmlize($type, linkify(readfile(srcfile($file)), $parentpage));
}
else {
return "";
@@ -337,7 +337,8 @@ sub render ($) { #{{{
my $file=shift;
my $type=pagetype($file);
- my $content=readfile("$config{srcdir}/$file");
+ my $srcfile=srcfile($file);
+ my $content=readfile($srcfile);
if ($type ne 'unknown') {
my $page=pagename($file);
@@ -349,7 +350,7 @@ sub render ($) { #{{{
check_overwrite("$config{destdir}/".htmlpage($page), $page);
writefile("$config{destdir}/".htmlpage($page),
- genpage($content, $page, mtime("$config{srcdir}/$file")));
+ genpage($content, $page, mtime($srcfile)));
$oldpagemtime{$page}=time;
$renderedfiles{$page}=htmlpage($page);
@@ -358,7 +359,7 @@ sub render ($) { #{{{
# only supports listing one file per page.
if ($config{rss} && exists $inlinepages{$page}) {
writefile("$config{destdir}/".rsspage($page),
- genrss($content, $page, mtime("$config{srcdir}/$file")));
+ genrss($content, $page, mtime($srcfile)));
}
}
else {
@@ -389,9 +390,7 @@ sub refresh () { #{{{
no_chdir => 1,
wanted => sub {
if (/$config{wiki_file_prune_regexp}/) {
- no warnings 'once';
$File::Find::prune=1;
- use warnings "all";
}
elsif (! -d $_ && ! -l $_) {
my ($f)=/$config{wiki_file_regexp}/; # untaint
@@ -406,6 +405,30 @@ sub refresh () { #{{{
}
},
}, $config{srcdir});
+ find({
+ no_chdir => 1,
+ wanted => sub {
+ if (/$config{wiki_file_prune_regexp}/) {
+ $File::Find::prune=1;
+ }
+ elsif (! -d $_ && ! -l $_) {
+ my ($f)=/$config{wiki_file_regexp}/; # untaint
+ if (! defined $f) {
+ warn("skipping bad filename $_\n");
+ }
+ else {
+ # Don't add files that are in the
+ # srcdir.
+ $f=~s/^\Q$config{underlaydir}\E\/?//;
+ if (! -e "$config{srcdir}/$f" &&
+ ! -l "$config{srcdir}/$f") {
+ push @files, $f;
+ $exists{pagename($f)}=1;
+ }
+ }
+ }
+ },
+ }, $config{underlaydir});
my %rendered;
@@ -418,7 +441,7 @@ sub refresh () { #{{{
push @add, $file;
$links{$page}=[];
$pagesources{$page}=$file;
- $pagectime{$page}=mtime("$config{srcdir}/$file")
+ $pagectime{$page}=mtime(srcfile($file))
unless exists $pagectime{$page};
}
}
@@ -439,7 +462,7 @@ sub refresh () { #{{{
my $page=pagename($file);
if (! exists $oldpagemtime{$page} ||
- mtime("$config{srcdir}/$file") > $oldpagemtime{$page}) {
+ mtime(srcfile($file)) > $oldpagemtime{$page}) {
debug("rendering changed file $file");
render($file);
$rendered{$file}=1;