-#!/usr/bin/perl -T
+#!/usr/bin/perl
# For subversion support.
use warnings;
use strict;
package IkiWiki;
+
+my $svn_log_infoline=qr/^r(\d+)\s+\|\s+([^\s]+)\s+\|\s+(\d+-\d+-\d+\s+\d+:\d+:\d+\s+[-+]?\d+).*/;
sub svn_info ($$) { #{{{
my $field=shift;
my ($svn_base)=$svn_url=~m!(/trunk(?:/.*)?)$!;
my $div=qr/^--------------------+$/;
- my $infoline=qr/^r(\d+)\s+\|\s+([^\s]+)\s+\|\s+(\d+-\d+-\d+\s+\d+:\d+:\d+\s+[-+]?\d+).*/;
my $state='start';
my ($rev, $user, $when, @pages, @message);
foreach (`LANG=C svn log --limit $num -v '$svn_url'`) {
if ($state eq 'start' && /$div/) {
$state='header';
}
- elsif ($state eq 'header' && /$infoline/) {
+ elsif ($state eq 'header' && /$svn_log_infoline/) {
$rev=$1;
$user=$2;
$when=concise(ago(time - str2time($3)));
return @ret;
} #}}}
+sub rcs_getctime () { #{{{
+ eval q{use Date::Parse};
+ foreach my $page (keys %pagectime) {
+ my $file="$config{srcdir}/$pagesources{$page}";
+ my $child = open(SVNLOG, "-|");
+ if (! $child) {
+ exec("svn", "log", $file) || error("svn log $file failed to run");
+ }
+
+ my $date;
+ while (<SVNLOG>) {
+ if (/$svn_log_infoline/) {
+ $date=$3;
+ }
+ }
+ close SVNLOG || warn "svn log $file exited $?";
+
+ if (! defined $date) {
+ warn "failed to parse svn log for $file\n";
+ next;
+ }
+
+ $pagectime{$page}=$date=str2time($date);
+ debug("found ctime ".localtime($date)." for $page");
+ }
+} #}}}
+
1
-#!/usr/bin/perl -T
+#!/usr/bin/perl
# Stubs for no revision control.
use warnings;
sub rcs_recentchanges ($) {
}
+sub rcs_getctime () {
+ error "getctime not implemented";
+}
+
1
$configstring=~s/\\/\\\\/g;
$configstring=~s/"/\\"/g;
- open(OUT, ">ikiwiki-wrap.c") || error("failed to write ikiwiki-wrap.c: $!");;
+ open(OUT, ">$wrapper.c") || error("failed to write $wrapper.c: $!");;
print OUT <<"EOF";
/* A wrapper for ikiwiki, can be safely made suid. */
#define _GNU_SOURCE
}
EOF
close OUT;
- if (system("gcc", "ikiwiki-wrap.c", "-o", $wrapper) != 0) {
- error("failed to compile ikiwiki-wrap.c");
+ if (system("gcc", "$wrapper.c", "-o", $wrapper) != 0) {
+ error("failed to compile $wrapper.c");
}
- unlink("ikiwiki-wrap.c");
+ unlink("$wrapper.c");
if (defined $config{wrappermode} &&
! chmod(oct($config{wrappermode}), $wrapper)) {
error("chmod $wrapper: $!");
Anyone with svn commit access can forge "web commit from foo" and make it appear on [[RecentChanges]] like foo committed. One way to avoid this would be to limit web commits to those done by a certian user.
-It's actually possible to force a whole series of svn commits to appear to have come just before yours, by forging svn log output. This could be guarded against somewhat by revision number scanning, since the forged revisions would duplicate the numbers of unforged ones. Or subversion could fix svn log to indent commit messages, which would make such forgery impossible..
+It's actually possible to force a whole series of svn commits to appear to
+have come just before yours, by forging svn log output. This could be
+guarded against by using svn log --xml.
ikiwiki escapes any html in svn commit logs to prevent other mischief.
- The [[TODO]] page would work better if the first N were shown in full,
and then all open items were shown in summary. Maybe add this mode.
- Add Discussion and Edit links at the bottom of each inlined post.
-- Still not completly comfortable with ikiwiki only knowing when a page was
- posted based on the on-disk mtime the first time it sees the page. svn doesn't
- preserve mtimes and also if the index gets broken it will see new mtimes for any
- pages that were actually modified in the interim. I suppose that info could
- be pulled out of svn log by a utility that was run if the index or mtimes
- got screwed up.
-- It would be possible to support rss enclosures for eg, podcasts, pretty easily.
\ No newline at end of file
+- It would be possible to support rss enclosures for eg, podcasts, pretty easily.
Force a rebuild of all pages.
+* --fixctime
+
+ Pull last changed time for all pages out of the revision control system.
+ This rarely used option provides a way to get the real creation times of
+ items in weblogs, for example when building a wiki from a new subversion
+ checkout. It is unoptimised and quite slow.
+
* --templatedir
Specify the directory that the page [[templates]] are stored in.
anonok => 0,
rss => 0,
rebuild => 0,
+ getctime => 0,
wrapper => undef,
wrappermode => undef,
srcdir => undef,
"wikiname=s" => \$config{wikiname},
"verbose|v!" => \$config{verbose},
"rebuild!" => \$config{rebuild},
+ "getctime" => \$config{getctime},
"wrappermode=i" => \$config{wrappermode},
"svn!" => \$config{svn},
"anonok!" => \$config{anonok},
loadindex();
require IkiWiki::Render;
rcs_update();
+ rcs_getctime() if $config{getctime};
refresh();
saveindex();
}