add comment subscription checkbox to editpage

Reworded template, which also called the commit message a "comment".
master
Joey Hess 2012-04-13 14:28:02 -04:00
parent 5c4d059251
commit e81e857ba6
4 changed files with 26 additions and 5 deletions

View File

@ -64,7 +64,8 @@ sub cgi_editpage ($$) {
decode_cgi_utf8($q);
my @fields=qw(do rcsinfo subpage from page type editcontent editmessage);
my @fields=qw(do rcsinfo subpage from page type editcontent
editmessage subscribe);
my @buttons=("Save Page", "Preview", "Cancel");
eval q{use CGI::FormBuilder};
error($@) if $@;
@ -157,6 +158,17 @@ sub cgi_editpage ($$) {
noimageinline => 1,
linktext => "FormattingHelp"));
my $cansubscribe=IkiWiki::Plugin::notifyemail->can("subscribe")
&& IkiWiki::Plugin::comments->can("import")
&& defined $session->param('name');
if ($cansubscribe) {
$form->field(name => "subscribe", type => "checkbox",
options => [gettext("email comments to me")]);
}
else {
$form->field(name => "subscribe", type => 'hidden');
}
my $previewing=0;
if ($form->submitted eq "Cancel") {
if ($form->field("do") eq "create" && defined $from) {
@ -448,6 +460,12 @@ sub cgi_editpage ($$) {
# caches and get the most recent version of the page.
redirect($q, $baseurl."?updated");
}
if ($cansubscribe && length $form->field("subscribe")) {
my $subspec="comment($page)";
IkiWiki::Plugin::notifyemail::subscribe(
$session->param('name'), $subspec);
}
}
exit;

2
debian/changelog vendored
View File

@ -6,7 +6,7 @@ ikiwiki (3.20120204) UNRELEASED; urgency=low
* meta: Export author information in html <meta> tag. Closes: #664779
Thanks, Martin Michlmayr
* notifyemail: New plugin, sends email notifications about new and
changed pages.
changed pages, and allows subscribing to comments.
* Added a "changes" hook. Renamed the "change" hook to "rendered", but
the old hook name is called for now for back-compat.
* meta: Support keywords header. Closes: #664780

View File

@ -10,5 +10,5 @@ matching the PageSpec will send an email that includes the new content of
the page, and a link to the page on the web.
To make it easy to subscribe to comment threads when posting a comment,
there is a check box that can be used to subscribe, without needing to
manually edit the [[ikiwiki/PageSpec]].
or a page, there is a check box that can be used to subscribe, without
needing to manually edit the [[ikiwiki/PageSpec]].

View File

@ -18,13 +18,16 @@
<TMPL_VAR FIELD-EDITCONTENT><br />
</div>
<TMPL_IF NAME="CAN_COMMIT">
<label for="editmessage" class="block">Optional comment about this change:</label>
<label for="editmessage" class="block">Optional description of this change:</label>
<TMPL_VAR FIELD-EDITMESSAGE><br />
</TMPL_IF>
<TMPL_VAR FORM-SUBMIT>
<TMPL_VAR HELPONFORMATTINGLINK>
<TMPL_IF NAME="FIELD-ATTACHMENT">
<a class="toggle" href="#attachments">Attachments</a>
</TMPL_IF>
<TMPL_VAR FIELD-SUBSCRIBE>
<TMPL_IF NAME="FIELD-ATTACHMENT">
<div class="<TMPL_VAR ATTACHMENTS-CLASS>" id="attachments">
<div id="fileupload">
<script>