[dw-free] Option to add a reason when editing comments
[commit: http://hg.dwscoalition.org/dw-free/rev/18f868288928]
http://bugs.dwscoalition.org/show_bug.cgi?id=1879
Add ability to specify reason when editing comments.
Patch by
afuna.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=1879
Add ability to specify reason when editing comments.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- bin/upgrading/en.dat
- bin/upgrading/proplists.dat
- bin/upgrading/s2layers/core1.s2
- bin/upgrading/s2layers/core2.s2
- cgi-bin/LJ/Comment.pm
- cgi-bin/LJ/Event/JournalNewComment.pm
- cgi-bin/LJ/S2/EntryPage.pm
- cgi-bin/LJ/Talk.pm
- htdocs/js/talkpost.js
- htdocs/talkpost.bml.text
- htdocs/talkread.bml
- htdocs/talkread.bml.text
-------------------------------------------------------------------------------- diff -r 77954ca8e61b -r 18f868288928 bin/upgrading/en.dat --- a/bin/upgrading/en.dat Tue Dec 15 02:58:11 2009 +0000 +++ b/bin/upgrading/en.dat Tue Dec 15 03:51:32 2009 +0000 @@ -1451,6 +1451,11 @@ esn.journal_new_comment.anonymous.reply_ esn.journal_new_comment.anonymous.reply_to.your_comment.to_your_post2=Somebody replied to a comment you left in [[openlink]]your [[sitenameshort]] post[[postsubject]][[closelink]]. The comment they replied to was: esn.journal_new_comment.anonymous.reply_to.your_post2=Somebody replied to [[openlink]]your [[sitenameshort]] post[[postsubject]][[closelink]] in which you said: + +esn.journal_new_comment.edit_reason<< +Reason for edit: + [[reason]] +. esn.journal_new_comment.message=Message: diff -r 77954ca8e61b -r 18f868288928 bin/upgrading/proplists.dat --- a/bin/upgrading/proplists.dat Tue Dec 15 02:58:11 2009 +0000 +++ b/bin/upgrading/proplists.dat Tue Dec 15 03:51:32 2009 +0000 @@ -1086,6 +1086,11 @@ userproplist.zip: multihomed: 0 prettyname: ZIP code +talkproplist.edit_reason: + datatype: char + des: Reason for the last edit. + prettyname: Edit Reason + talkproplist.edit_time: datatype: num des: Unix time of the last edit. undef if never edited. diff -r 77954ca8e61b -r 18f868288928 bin/upgrading/s2layers/core1.s2 --- a/bin/upgrading/s2layers/core1.s2 Tue Dec 15 02:58:11 2009 +0000 +++ b/bin/upgrading/s2layers/core1.s2 Tue Dec 15 03:51:32 2009 +0000 @@ -384,6 +384,7 @@ class Comment extends EntryLite var readonly string anchor "Direct link to comment, via HTML name anchors"; var readonly bool comment_posted "True if comment was just posted by the current user."; var readonly bool edited "True if the comment has been edited."; + var readonly string editreason "The reason this comment was last edited"; var readonly DateTime time_remote "The local time the comment appeared, in the remote user's (reader's) timezone. Or undef if no remote user, or remote user hasn't set their timezone."; var readonly DateTime time_poster "The local time the comment appeared, in the commenter's timezone. Or undef if anonymous comment, or commenter's timezone is unknown."; @@ -1524,14 +1525,14 @@ property string text_comment_ipaddr { maxlength = "20"; } property string text_comment_edittime { - des = "Text of the 'Edited at' string at the bottom of edited comments"; - example = "Edited at:"; + des = "Text of the 'Edited' string at the bottom of edited comments"; + example = "Edited"; maxlength = "20"; } set text_comment_from = "From:"; set text_comment_date = "Date:"; set text_comment_ipaddr = "IP Address:"; -set text_comment_edittime = "Edited at"; +set text_comment_edittime = "Edited"; property string text_comment_reply { des = "Text to link to reply for comment"; @@ -2253,7 +2254,8 @@ function RecentPage::print_sticky_entry( function Comment::print_edit_text() { if ($this.edited) { - print "<br /><br /><span class='edittime'><em>$*text_comment_edittime " + $this->edittime_display() + "</em></span>"; + var string editreason = $this.editreason == "" ? "" : "($this.editreason) "; + print "<br /><br /><span class='edittime'><em>$*text_comment_edittime $editreason" + $this->edittime_display() + "</em></span>"; } } diff -r 77954ca8e61b -r 18f868288928 bin/upgrading/s2layers/core2.s2 --- a/bin/upgrading/s2layers/core2.s2 Tue Dec 15 02:58:11 2009 +0000 +++ b/bin/upgrading/s2layers/core2.s2 Tue Dec 15 03:51:32 2009 +0000 @@ -423,6 +423,7 @@ class Comment extends EntryLite var readonly DateTime time_remote "The local time the comment appeared, in the remote user's (reader's) timezone. Or undef if no remote user, or remote user hasn't set their timezone."; var readonly DateTime time_poster "The local time the comment appeared, in the commenter's timezone. Or undef if anonymous comment, or commenter's timezone is unknown."; var readonly int seconds_since_entry "The number of elapsed seconds from the time of the journal entry until the comment was initially posted."; + var readonly string editreason "The reason this comment was last edited"; var readonly DateTime edittime "The GMT time the comment was edited. Or undef if the comment hasn't been edited."; var readonly DateTime edittime_remote "The local time the comment was edited, in the remote user's (reader's) timezone. Or undef if no remote user, or remote user hasn't set their timezone, or the comment hasn't been edited."; @@ -2409,14 +2410,14 @@ property string text_comment_ipaddr { maxlength = "20"; } property string text_comment_edittime { - des = "Text of the 'Edited at' string at the bottom of edited comments"; - example = "Edited at:"; + des = "Text of the 'Edited' string at the bottom of edited comments"; + example = "Edited"; maxlength = "20"; } set text_comment_from = "From:"; set text_comment_date = "Date:"; set text_comment_ipaddr = "IP Address:"; -set text_comment_edittime = "Edited at"; +set text_comment_edittime = "Edited"; property string text_screened { des = "The text used when a comment is screened"; @@ -4059,7 +4060,8 @@ function RecentPage::print_sticky_entry( function Comment::print_edit_text() { if ($this.edited) { - print "<div class='edittime'><em>$*text_comment_edittime "; + var string editreason = $this.editreason == "" ? "" : "($this.editreason) "; + print "<div class='edittime'><em>$*text_comment_edittime $editreason"; $this->print_edittime(); print "</em></div>"; } diff -r 77954ca8e61b -r 18f868288928 cgi-bin/LJ/Comment.pm --- a/cgi-bin/LJ/Comment.pm Tue Dec 15 02:58:11 2009 +0000 +++ b/cgi-bin/LJ/Comment.pm Tue Dec 15 03:51:32 2009 +0000 @@ -1128,6 +1128,7 @@ my @_ml_strings_en = ( 'esn.journal_new_comment.anonymous.reply_to.your_comment.to_your_post2', # 'Somebody replied to another comment you left in [[openlink]]your [[sitenameshort]] post[[postsubject]][[closelink]]. The comment they replied to was:', 'esn.journal_new_comment.anonymous.reply_to.your_post2', # 'Somebody replied to [[openlink]]your [[sitenameshort]] post[[postsubject]][[closelink]] in which you said:', + 'esn.journal_new_comment.edit_reason', 'esn.journal_new_comment.user.comment', # 'Their reply was:', 'esn.journal_new_comment.user.edit_reply_to.anonymous_comment.to_your_post2',# '[[who]] edited a reply to another comment somebody left in [[openlink]]your [[sitenameshort]] post[[postsubject]][[closelink]]. The comment they replied to was:', 'esn.journal_new_comment.user.edit_reply_to.user_comment.to_your_post2', # '[[who]] edited a reply to another comment [[pwho]] left in [[openlink]]your [[sitenameshort]] post[[postsubject]][[closelink]]. The comment they replied to was:', @@ -1411,6 +1412,18 @@ sub _format_mail_both { $body .= $intro . "\n\n" . indent($parent ? $parent->body_raw : $entry->event_raw, ">"); } + # reason for editing, if applicable + if ( $edited ) { + my $reason = $self->edit_reason; + if ( $is_html ) { + $body .= "<br />" . LJ::Lang::get_text( $lang, "esn.journal_new_comment.edit_reason", undef, { reason => LJ::ehtml( $reason ) } ) . "<br />" + if $reason; + } else { + $body .= "\n\n" . LJ::Lang::get_text( $lang, "esn.journal_new_comment.edit_reason", undef, { reason => $reason } ) + if $reason; + } + } + $body .= "\n\n" . LJ::Lang::get_text($lang, $k_reply_edit, undef, $vars) . "\n\n"; if ($is_html) { @@ -1604,6 +1617,10 @@ sub set_poster_ip { return $new_ip; } +sub edit_reason { + return $_[0]->prop( "edit_reason" ); +} + sub edit_time { my $self = shift; diff -r 77954ca8e61b -r 18f868288928 cgi-bin/LJ/Event/JournalNewComment.pm --- a/cgi-bin/LJ/Event/JournalNewComment.pm Tue Dec 15 02:58:11 2009 +0000 +++ b/cgi-bin/LJ/Event/JournalNewComment.pm Tue Dec 15 03:51:32 2009 +0000 @@ -167,6 +167,12 @@ sub content { $comment_body =~ s/\n/<br \/>/g; + if ( $comment->is_edited ) { + my $reason = LJ::ehtml( $comment->edit_reason ); + $comment_body .= "<br /><br /><div class='edittime'>" . LJ::Lang::get_text( $target->prop( "browselang" ), "esn.journal_new_comment.edit_reason", undef, { reason => $reason } ) . "</div>" + if $reason; + } + my $ret = qq { <div id="$htmlid" class="JournalNewComment"> <div class="ManageButtons">$buttons</div> @@ -210,6 +216,13 @@ sub content_summary { my $body_summary = $comment->body_html_summary( 300 ); my $ret = $body_summary; $ret .= "..." if $comment->body_html ne $body_summary; + + if ( $comment->is_edited ) { + my $reason = LJ::ehtml( $comment->edit_reason ); + $ret .= "<br /><br /><div class='edittime'>" . LJ::Lang::get_text( $target->prop( "browselang" ), "esn.journal_new_comment.edit_reason", undef, { reason => $reason } ) . "</div>" + if $reason; + } + $ret .= $self->as_html_actions; return $ret; diff -r 77954ca8e61b -r 18f868288928 cgi-bin/LJ/S2/EntryPage.pm --- a/cgi-bin/LJ/S2/EntryPage.pm Tue Dec 15 02:58:11 2009 +0000 +++ b/cgi-bin/LJ/S2/EntryPage.pm Tue Dec 15 03:51:32 2009 +0000 @@ -143,13 +143,14 @@ sub EntryPage my $threadroot_url; - my ($edited, $edit_url, $edittime, $edittime_remote, $edittime_poster); + my ($edited, $edit_url, $editreason, $edittime, $edittime_remote, $edittime_poster); if ($com->{_loaded}) { my $comment = LJ::Comment->new($u, jtalkid => $com->{talkid}); $edited = $comment->is_edited; $edit_url = LJ::Talk::talkargs($comment->edit_url, $style_arg); if ($edited) { + $editreason = LJ::ehtml( $comment->edit_reason ); $edittime = DateTime_unix($comment->edit_time); $edittime_remote = $tz_remote ? DateTime_tz($comment->edit_time, $tz_remote) : undef; $edittime_poster = DateTime_tz($comment->edit_time, $pu); @@ -233,6 +234,7 @@ sub EntryPage 'time' => $datetime, 'system_time' => $datetime, # same as regular time for comments 'edittime' => $edittime, + 'editreason' => $editreason, 'tags' => [], 'full' => $com->{'_loaded'} ? 1 : 0, 'depth' => $depth, diff -r 77954ca8e61b -r 18f868288928 cgi-bin/LJ/Talk.pm --- a/cgi-bin/LJ/Talk.pm Tue Dec 15 02:58:11 2009 +0000 +++ b/cgi-bin/LJ/Talk.pm Tue Dec 15 03:51:32 2009 +0000 @@ -1787,6 +1787,13 @@ QQ $ret .= LJ::html_hidden(captcha_chal => $captcha_chal); } $ret .= '<br />'; + } + + if ( $editid ) { + my $editreason = LJ::ehtml( $comment->edit_reason ); + $ret .= "<tr valign='top'><td align='right'>$BML::ML{'.opt.editreason'}</td><td><input class='textbox' type='text' size='75' maxlength='255' name='editreason' id='editreason' value=\"$editreason\" onKeyPress='editNoHTML(event);' />\n"; + + $ret .= "<div id='nohtmledit' class='ljdeem'><span style='font-size: 8pt; font-style: italic;'>$BML::ML{'.noedithtml'}</span></div>\n"; } my $submit_btn = $editid ? LJ::Lang::ml('.opt.edit') : LJ::Lang::ml('.opt.submit'); @@ -3230,6 +3237,7 @@ sub init { picture_keyword => $form->{'prop_picture_keyword'}, state => $state, editid => $form->{editid}, + editreason => $form->{editreason}, }; $init->{item} = $item; @@ -3450,6 +3458,7 @@ sub edit_comment { subjecticon => $comment->{subjecticon}, picture_keyword => $comment->{picture_keyword}, opt_preformatted => $comment->{preformat} ? 1 : 0, + edit_reason => $comment->{editreason}, ); # set most of the props together diff -r 77954ca8e61b -r 18f868288928 htdocs/js/talkpost.js --- a/htdocs/js/talkpost.js Tue Dec 15 02:58:11 2009 +0000 +++ b/htdocs/js/talkpost.js Tue Dec 15 03:51:32 2009 +0000 @@ -42,6 +42,9 @@ if (document.getElementById) { var subject_field = document.getElementById("subject"); var subject_nohtml = document.getElementById("ljnohtmlsubj"); hideMe(subject_nohtml); + + var edit_nohtml = document.getElementById("nohtmledit"); + hideMe(edit_nohtml); } var apicurl = ""; @@ -235,6 +238,17 @@ function subjectNoHTML(e) { } } +function editNoHTML(e) { + + var key; + + key = getKey(e); + + if (key == 60) { + showMe(edit_nohtml); + } +} + function getKey(e) { if (window.event) { return window.event.keyCode; @@ -259,9 +273,11 @@ function otherOIDUser() { } function hideMe(e) { - e.className = 'display_none'; + if ( e ) + e.className = 'display_none'; } function showMe(e) { - e.className = ''; + if ( e ) + e.className = ''; } diff -r 77954ca8e61b -r 18f868288928 htdocs/talkpost.bml.text --- a/htdocs/talkpost.bml.text Tue Dec 15 02:58:11 2009 +0000 +++ b/htdocs/talkpost.bml.text Tue Dec 15 03:51:32 2009 +0000 @@ -33,6 +33,8 @@ .noaccount=Don't have an account? <a [[aopts]]>Create one now</a>. +.noedithtml=No HTML allowed in reason for edit + .nosubjecthtml=No HTML allowed in subject .opt.anonymous=Anonymous @@ -42,6 +44,8 @@ .opt.defpic=(default) .opt.edit=Edit Comment + +.opt.editreason=Reason: .opt.friendsonly=- you may post here only if [[username]] has given you access; posting by non-Access List accounts has been disabled. diff -r 77954ca8e61b -r 18f868288928 htdocs/talkread.bml --- a/htdocs/talkread.bml Tue Dec 15 02:58:11 2009 +0000 +++ b/htdocs/talkread.bml Tue Dec 15 03:51:32 2009 +0000 @@ -537,6 +537,7 @@ body<= my $comment = LJ::Comment->new($u, dtalkid => $dtid); my $edittime; + my $editreason = ""; if ($comment->is_edited) { my $s2_datetime_edittime = $tz_remote ? LJ::S2::DateTime_tz($comment->edit_time, $tz_remote) : @@ -545,6 +546,9 @@ body<= $edittime = S2::Builtin::LJ::Date__date_format($s2_ctx, $s2_datetime_edittime, "iso") . " " . S2::Builtin::LJ::DateTime__time_format($s2_ctx, $s2_datetime_edittime, $fmt_time_short) . ($tz_remote ? " (local)" : " UTC"); + + $editreason = LJ::ehtml( $comment->edit_reason ); + $editreason = "($editreason)" if $editreason; } $ret .= "<a name='$htmlid'></a><span id='$htmlid'><table width='100%' class='talk-comment'><tbody><tr>"; @@ -680,7 +684,7 @@ body<= # quote all non-LJ tags $event =~ s{<(?!/?lj)(.*?)>} {<$1>}gi; } - my $edit_html = $edittime ? "<br /><br /><span class='edittime'><em>" . BML::ml('.edittime', { edittime => $edittime }) . "</em></span>" : ""; + my $edit_html = $edittime ? "<br /><br /><span class='edittime'><em>" . BML::ml('.edittime', { editreason => $editreason, edittime => $edittime }) . "</em></span>" : ""; $ret .= "$event$edit_html"; $ret .= "<p style='margin: 0.7em 0 0.2em 0'><font size='-2'>"; diff -r 77954ca8e61b -r 18f868288928 htdocs/talkread.bml.text --- a/htdocs/talkread.bml.text Tue Dec 15 02:58:11 2009 +0000 +++ b/htdocs/talkread.bml.text Tue Dec 15 03:51:32 2009 +0000 @@ -13,7 +13,7 @@ .deleteduser=<i>(Deleted user: [[username]])</i> -.edittime=Edited at [[edittime]] +.edittime=Edited [[editreason]] [[edittime]] .from_external=(from [[site]]) --------------------------------------------------------------------------------
no subject