#!/usr/bin/perl
-# For subversion support.
use warnings;
use strict;
package IkiWiki;
-my $svn_webcommit=qr/^web commit (by (\w+)|from (\d+\.\d+\.\d+\.\d+)):?(.*)/;
-
# svn needs LC_CTYPE set to a UTF-8 locale, so try to find one. Any will do.
sub find_lc_ctype() {
my $current = setlocale(LC_CTYPE());
return unless -d "$config{srcdir}/.svn";
- eval q{use CGI 'escapeHTML'};
- eval q{use Date::Parse};
- eval q{use Time::Duration};
- eval q{use XML::SAX};
- eval q{use XML::Simple};
+ eval q{
+ use Date::Parse;
+ use Time::Duration;
+ use XML::SAX;
+ use XML::Simple;
+ };
+ error($@) if $@;
# avoid using XML::SAX::PurePerl, it's buggy with UTF-8 data
my @parsers = map { ${$_}{Name} } @{XML::SAX->parsers()};
my $rev = $logentry->{revision};
my $user = $logentry->{author};
- my $date = $logentry->{date};
- $date =~ s/T/ /;
- $date =~ s/\.\d+Z$//;
- my $when=concise(ago(time - str2time($date, 'UTC')));
+ my $when=time - str2time($logentry->{date}, 'UTC');
foreach my $msgline (split(/\n/, $logentry->{msg})) {
- push @message, { line => escapeHTML($msgline) };
+ push @message, { line => $msgline };
}
my $committype="web";
if (defined $message[0] &&
- $message[0]->{line}=~/$svn_webcommit/) {
+ $message[0]->{line}=~/$config{web_commit_regexp}/) {
$user=defined $2 ? "$2" : "$3";
$message[0]->{line}=$4;
}
$diffurl=~s/\[\[r1\]\]/$rev - 1/eg;
$diffurl=~s/\[\[r2\]\]/$rev/g;
push @pages, {
- link => htmllink("", "", pagename($file), 1),
+ page => pagename($file),
diffurl => $diffurl,
} if length $file;
}
push @ret, { rev => $rev,
- user => htmllink("", "", $user, 1),
+ user => $user,
committype => $committype,
when => $when,
message => [@message],
my $user=`svnlook author $config{svnrepo} -r $rev`;
chomp $user;
my $message=`svnlook log $config{svnrepo} -r $rev`;
- if ($message=~/$svn_webcommit/) {
+ if ($message=~/$config{web_commit_regexp}/) {
$user=defined $2 ? "$2" : "$3";
$message=$4;
}
# reassemble into one mail with just the pages subscribed to.
my $diff=`svnlook diff $config{svnrepo} -r $rev --no-diff-deleted`;
- my $subject="$config{wikiname} update of ";
+ my $subject="update of $config{wikiname}'s ";
if (@changed_pages > 2) {
$subject.="$changed_pages[0] $changed_pages[1] etc";
}
);
eval q{use Mail::Sendmail};
+ error($@) if $@;
foreach my $email (@email_recipients) {
sendmail(
To => $email,
sub rcs_getctime ($) { #{{{
my $file=shift;
- eval q{use Date::Parse};
my $svn_log_infoline=qr/^r\d+\s+\|\s+[^\s]+\s+\|\s+(\d+-\d+-\d+\s+\d+:\d+:\d+\s+[-+]?\d+).*/;
return 0;
}
+ eval q{use Date::Parse};
+ error($@) if $@;
$date=str2time($date);
debug("found ctime ".localtime($date)." for $file");
return $date;