user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH] view: fix message truncation logic
@ 2015-12-06  3:17  7% Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2015-12-06  3:17 UTC (permalink / raw)
  To: meta

Avoid truncating messages if we requested the root anchor.
This regression appeared in
commit 62ee3cb36dd08f17e444e96dc80108464ee10cba
("view: do not shorten top-level messages in thread view")

Also, make the "More..." link more prominent, as readers
should be made aware they're not reading the full message.
---
 lib/PublicInbox/View.pm | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 2506c95..3c4e954 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -88,7 +88,6 @@ sub index_entry {
 
 	$from = PublicInbox::Hval->new_oneline($from)->as_html;
 	$subj = PublicInbox::Hval->new_oneline($subj)->as_html;
-	my $more = 'permalink';
 	my $root_anchor = $state->{root_anchor} || '';
 	my $path = $root_anchor ? '../../' : '';
 	my $href = $mid->as_href;
@@ -119,9 +118,11 @@ sub index_entry {
 
 	my ($fhref, $more_ref);
 	my $mhref = "${path}$href/";
+	my $more = 'permalink';
 
 	# show full message if it's our root message
-	if ($root_anchor ne $id || ($level != 0 && !$ctx->{flat})) {
+	my $neq = $root_anchor ne $id;
+	if ($neq || ($neq && $level != 0 && !$ctx->{flat})) {
 		$fhref = "${path}$href/f/";
 		$more_ref = \$more;
 	}
@@ -215,12 +216,14 @@ sub index_walk {
 	my $s = add_text_body($enc, $part, $part_nr, $fhref);
 
 	if ($more) {
+		my $m = 0;
 		# drop the remainder of git patches, they're usually better
 		# to review when the full message is viewed
-		$s =~ s!^---+\n.*\z!!ms and $$more = 'more...';
+		$s =~ s!^---+\n.*\z!!ms and $m = 1;
 
 		# Drop signatures
-		$s =~ s/^-- \n.*\z//ms and $$more = 'more...';
+		$s =~ s/^-- \n.*\z//ms and $m = 1;
+		$$more = "<b>More...</b>\n\n$$more" if $m;
 	}
 
 	# kill any leading or trailing whitespace lines
-- 
EW


^ permalink raw reply related	[relevance 7%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-12-06  3:17  7% [PATCH] view: fix message truncation logic Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).