X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/acecbad0ff4a8c441da520522710dd5357ab31e0..252e3f600670040b2a184e5ca0581db720096a80:/IkiWiki/Plugin/recentchanges.pm diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 2a78566e1..9a62cb243 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -13,6 +13,7 @@ sub import { hook(type => "refresh", id => "recentchanges", call => \&refresh); hook(type => "pagetemplate", id => "recentchanges", call => \&pagetemplate); hook(type => "htmlize", id => "_change", call => \&htmlize); + hook(type => "sessioncgi", id => "recentchanges", call => \&sessioncgi); # Load goto to fix up links from recentchanges IkiWiki::loadplugin("goto"); } @@ -80,7 +81,6 @@ sub confirmation_form { $f->field(name => "sid", type => "hidden", value => $session->id, force => 1); $f->field(name => "do", type => "hidden", value => "revert", force => 1); - $f->field(name => "rev", type => "hidden", value => $rev, force => 1); return $f, ["Revert", "Cancel"]; } @@ -92,8 +92,7 @@ sub sessioncgi ($$) { return unless $do eq 'revert' && $rev; - # FIXME rcs_preprevert ?? - IkiWiki::check_canedit('FIXME', $q, $session); + IkiWiki::rcs_preprevert(cgi => $q, session => $session, rev => $rev); my ($form, $buttons) = confirmation_form($q, $session); IkiWiki::decode_form_utf8($form); @@ -108,16 +107,17 @@ sub sessioncgi ($$) { IkiWiki::enable_commit_hook(); if($r) { - die "FIXME revert '$rev' failed."; + die "Revert '$rev' failed."; } else { + require IkiWiki::Render; IkiWiki::refresh(); IkiWiki::saveindex(); - # FIXME indicate success. } } else { $form->title(sprintf(gettext("confirm reversion of %s"), $rev)); - my $patch_contents = IkiWiki::rcs_showpatch($rev); + my $patch_contents = IkiWiki::rcs_showpatch(rev => $rev); $form->tmpl_param(patch_contents => encode_entities($patch_contents)); + $form->field(name => "rev", type => "hidden", value => $rev, force => 1); IkiWiki::showform($form, $buttons, $session, $q); exit 0; } @@ -180,6 +180,13 @@ sub store ($$$) { ]; push @{$change->{pages}}, { link => '...' } if $is_excess; + if (length $config{cgiurl}) { + $change->{reverturl} = IkiWiki::cgiurl( + do => "revert", + rev => $change->{rev} + ); + } + $change->{author}=$change->{user}; my $oiduser=eval { IkiWiki::openiduser($change->{user}) }; if (defined $oiduser) {