[dw-free] Improve comment preview with metadata and post text
[commit: http://hg.dwscoalition.org/dw-free/rev/4240985f1329]
http://bugs.dwscoalition.org/show_bug.cgi?id=2579
Add post text and metadata as context to the bottom of the comment preview
page.
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2579
Add post text and metadata as context to the bottom of the comment preview
page.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/LJ/Talk.pm
- htdocs/talkpost_do.bml.text
-------------------------------------------------------------------------------- diff -r 1d360e93f945 -r 4240985f1329 cgi-bin/LJ/Talk.pm --- a/cgi-bin/LJ/Talk.pm Fri Oct 08 15:18:44 2010 +0800 +++ b/cgi-bin/LJ/Talk.pm Fri Oct 08 16:09:08 2010 +0800 @@ -2386,6 +2386,7 @@ package LJ::Talk::Post; package LJ::Talk::Post; use Text::Wrap; +use LJ::Entry; use LJ::EventLogRecord::NewComment; sub indent { @@ -3751,12 +3752,12 @@ sub make_preview { my ($talkurl, $cookie_auth, $form) = @_; my $ret = ""; + # preview form + + $ret .= "<?h2 $BML::ML{'/talkpost_do.bml.preview.title'} h2?><?p $BML::ML{'/talkpost_do.bml.preview'} p?><?hr?>"; + my $cleansubject = $form->{'subject'}; LJ::CleanHTML::clean_subject(\$cleansubject); - - $ret .= "<?h1 $BML::ML{'/talkpost_do.bml.preview.title'} h1?><?p $BML::ML{'/talkpost_do.bml.preview'} p?><?hr?>"; - $ret .= "<div align=\"center\"><b>(<a href=\"$talkurl\">$BML::ML{'talk.commentsread'}</a>)</b></div>"; - my $event = $form->{'body'}; my $spellcheck_html; # clean first; if the cleaner finds it invalid, don't spellcheck, so that we @@ -3831,6 +3832,52 @@ sub make_preview { $ret .= "de?> </p>"; $ret .= "</form></div>"; + + # entry details + my $entry = LJ::Entry->new_from_url( $talkurl ); + if ( $entry && $entry->visible_to( $remote ) ) { + $ret .= "<?hr?><?h2 $BML::ML{'/talkpost_do.bml.preview.context'} h2?>"; + + if ( my $ju = $entry->journal ) { + $ret .= "<?p "; + + my $pu = $entry->poster; + if ( $pu && !$pu->equals( $ju ) ) { + $ret .= BML::ml( '/talkpost_do.bml.preview.entry.journal', + { user => $pu->ljuser_display, + journal => $ju->ljuser_display } ); + } else { + $ret .= $ju->ljuser_display; + } + $ret .= " @ " . $entry->eventtime_mysql; + + $ret .= " p?>\n"; + } + + $ret .= "<?p "; + ### security indicator + my $sec = $entry->security; + if ( $sec eq "private" ) { + $ret .= BML::fill_template( "securityprivate" ); + } elsif ( $sec eq "usemask" ) { + $ret .= BML::fill_template( "securityprotected" ); + } + $ret .= " <i><b>" . $entry->subject_html . "</b></i>"; + $ret .= " p?>\n"; + + my $cleanopts = { preformatted => $entry->prop( 'opt_preformatted' ), + cuturl => $talkurl }; + my $truncated; + my $summary = $entry->event_html_summary( 1000, $cleanopts, \$truncated ); + + $ret .= "<?p "; + $ret .= $summary; + $ret .= "..." if $truncated; + $ret .= " p?>\n"; + } + + $ret .= "<div align=\"center\"><b>(<a href=\"$talkurl\">$BML::ML{'talk.commentsread'}</a>)</b></div>"; + return $ret; } diff -r 1d360e93f945 -r 4240985f1329 htdocs/talkpost_do.bml.text --- a/htdocs/talkpost_do.bml.text Fri Oct 08 15:18:44 2010 +0800 +++ b/htdocs/talkpost_do.bml.text Fri Oct 08 16:09:08 2010 +0800 @@ -62,11 +62,15 @@ .preview=This is how your comment will look when posted. Using the form below, you can edit your comment further, or you can submit it as is. +.preview.context=Comment Context + .preview.edit.body=<b>New message: </b> .preview.edit.editreason=<b>Reason for edit: </b> .preview.edit.subject=<b>New subject: </b> + +.preview.entry.journal=[[user]] posting in [[journal]] .preview.subject=<b>Subject: </b> --------------------------------------------------------------------------------