diff options
author | Joey Hess <joey@kitenet.net> | 2010-10-08 17:54:12 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-10-08 17:54:12 -0400 |
commit | 84111d96c461a5d31a615ebf64cae751e6fd9aef (patch) | |
tree | c816fc340bd318eda018da949317d5e8787f595f | |
parent | 594eb32780466e89390bacc61f8c28b1d4ca9f0b (diff) |
make revert hooks optional
I removed the IkiWiki::rcs_ stubs for the revert hooks. Instead
recentchanges tests to see if the hooks are available and calls
them directly.
-rw-r--r-- | IkiWiki.pm | 8 | ||||
-rw-r--r-- | IkiWiki/Plugin/recentchanges.pm | 9 | ||||
-rw-r--r-- | doc/plugins/write.mdwn | 5 | ||||
-rw-r--r-- | templates/change.tmpl | 2 |
4 files changed, 11 insertions, 13 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm index faf4af5c7..1f6d70ba3 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1941,14 +1941,6 @@ sub rcs_receive () { $hooks{rcs}{rcs_receive}{call}->(); } -sub rcs_preprevert ($) { - $hooks{rcs}{rcs_preprevert}{call}->(@_); -} - -sub rcs_revert ($) { - $hooks{rcs}{rcs_revert}{call}->(@_); -} - sub add_depends ($$;$) { my $page=shift; my $pagespec=shift; diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 44c981548..a6d7f9fce 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -93,7 +93,8 @@ sub sessioncgi ($$) { return unless $do eq 'revert' && $rev; - IkiWiki::rcs_preprevert(cgi => $q, session => $session, rev => $rev); + $IkiWiki::hooks{rcs}{rcs_preprevert}{call}->( + cgi => $q, session => $session, rev => $rev); my ($form, $buttons) = confirmation_form($q, $session); IkiWiki::decode_form_utf8($form); @@ -101,7 +102,7 @@ sub sessioncgi ($$) { if ($form->submitted eq 'Revert' && $form->validate) { IkiWiki::checksessionexpiry($q, $session, $q->param('sid')); IkiWiki::disable_commit_hook(); - my $r = IkiWiki::rcs_revert($rev); + my $r = $IkiWiki::hooks{rcs}{rcs_revert}{call}->($rev); if (! defined $r) { # success rcs_commit_staged( message => sprintf(gettext("This reverts commit %s"), $rev), @@ -186,7 +187,9 @@ sub store ($$$) { ]; push @{$change->{pages}}, { link => '...' } if $is_excess; - if (length $config{cgiurl}) { + if (length $config{cgiurl} && + exists $IkiWiki::hooks{rcs}{rcs_preprevert} && + exists $IkiWiki::hooks{rcs}{rcs_revert}) { $change->{reverturl} = IkiWiki::cgiurl( do => "revert", rev => $change->{rev} diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index dbbe83851..6b751f0cd 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -1154,8 +1154,6 @@ context, and the whole diff in scalar context. This is used to get the page creation time for a file from the RCS, by looking it up in the history. -It's ok if this is not implemented, and throws an error. - If the RCS cannot determine a ctime for the file, return 0. #### `rcs_getmtime($)` @@ -1210,6 +1208,9 @@ It should try to revert the specified rev, and leave the reversion staged so `rcs_commit_staged` will complete it. It should return undef on _success_ and an error message on failure. +This hook and `rcs_preprevert` are optional, if not implemented, no revert +web interface will be available. + ### PageSpec plugins It's also possible to write plugins that add new functions to diff --git a/templates/change.tmpl b/templates/change.tmpl index 4525402a7..60a9d94b5 100644 --- a/templates/change.tmpl +++ b/templates/change.tmpl @@ -28,9 +28,11 @@ <span class="changedate"><TMPL_VAR COMMITDATE></span> <span class="desc"><br /></span> </div> +<TMPL_IF REVERTURL> <span class="revert"> <a href="<TMPL_VAR REVERTURL>" title="revert" rel="nofollow">[[revert|wikiicons/revert.png]]</a> </span> +</TMPL_IF> <div class="changelog"> <TMPL_LOOP MESSAGE> <TMPL_IF LINE> |