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);
+ my ($rev, $user, $when, @pages, @message);
foreach (`LANG=C svn log -v '$svn_url'`) {
chomp;
if ($state eq 'start' && /$div/) {
}
elsif ($state eq 'body' && /$div/) {
push @ret, { rev => $rev, user => $user,
- when => $when, message => $message,
+ when => $when, message => [@message],
pages => [@pages] } if @pages;
return @ret if @ret >= $num;
$state='header';
- $message=$rev=$user=$when=undef;
- @pages=();
+ $rev=$user=$when=undef;
+ @pages=@message=();
}
elsif ($state eq 'body') {
- $message.="$_<br>\n";
+ push @message, {line => $_},
}
}
}
exit 0;
} #}}}
-sub html_recentchanges ($q) { #{{{
+sub cgi_recentchanges ($) { #{{{
my $q=shift;
my $template=HTML::Template->new(
javascript => 0,
params => $q,
action => $q->request_uri,
+ template => (-e "$templatedir/signin.tmpl" ? "$templatedir/signin.tmpl" : "")
);
$form->sessionid($session->id);
if ($form->submitted && $form->validate) {
if ($form->submitted eq 'Login') {
$session->param("name", $form->field("name"));
- if (defined $form->field("do")) {
- $q->redirect(
+ if (defined $form->field("do") &&
+ $form->field("do") ne 'signin') {
+ print $q->redirect(
"$cgiurl?do=".$form->field("do").
"&page=".$form->field("page"));
}
else {
- $q->redirect($url);
+ print $q->redirect($url);
}
}
elsif ($form->submitted eq 'Register') {
eval q{use CGI::Session};
my $q=CGI->new;
- # session id has to be _sessionid for CGI::FormBuilder to work.
- # TODO: stop having the formbuilder emit cookies and change session
- # id to something else.
- CGI::Session->name("_sessionid");
- my $session = CGI::Session->new(undef, $q,
- { Directory=> "$srcdir/.ikiwiki/sessions" });
my $do=$q->param('do');
if (! defined $do || ! length $do) {
error("\"do\" parameter missing");
}
+ # This does not need a session.
if ($do eq 'recentchanges') {
cgi_recentchanges($q);
return;
}
+ # session id has to be _sessionid for CGI::FormBuilder to work.
+ # TODO: stop having the formbuilder emit cookies and change session
+ # id to something else.
+ CGI::Session->name("_sessionid");
+ my $session = CGI::Session->new(undef, $q,
+ { Directory=> "$srcdir/.ikiwiki/sessions" });
+
+ # Everything below this point needs the user to be signed in.
if ((! $anonok && ! defined $session->param("name")) || $do eq 'signin') {
cgi_signin($q, $session);
return;