From: Eric Wong <e@80x24.org>
Date: Thu, 20 Aug 2015 02:51:28 +0000 (+0000)
Subject: view: do not fold top-level messages in thread
X-Git-Tag: v1.0.0~1028
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=506b57e6f76888cbc930cd401af6d9e9ed87eb0f;p=public-inbox.git

view: do not fold top-level messages in thread

This hopefully reduces clicking.  We may drop folding entirely
since we can use Xapian to make searching easier.
---

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 391e3ad7..17af21f7 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -109,11 +109,15 @@ sub index_entry {
 	}
 	$rv .= "\n\n";
 
+	my ($fhref, $more_ref);
 	my $mhref = "${path}m/$href.html";
-	my $fhref = "${path}f/$href.html";
+	if ($level > 0) {
+		$fhref = "${path}f/$href.html";
+		$more_ref = \$more;
+	}
 	# scan through all parts, looking for displayable text
 	$mime->walk_parts(sub {
-		$rv .= index_walk($_[0], $enc_msg, $part_nr, $fhref, \$more);
+		$rv .= index_walk($_[0], $enc_msg, $part_nr, $fhref, $more_ref);
 		$part_nr++;
 	});
 	$mime->body_set('');
@@ -220,12 +224,14 @@ sub index_walk {
 
 	my $s = add_text_body($enc, $part, $part_nr, $fhref);
 
-	# 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...';
+	if ($more) {
+		# 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...';
 
-	# Drop signatures
-	$s =~ s/^-- \n.*\z//ms and $$more = 'more...';
+		# Drop signatures
+		$s =~ s/^-- \n.*\z//ms and $$more = 'more...';
+	}
 
 	# kill any leading or trailing whitespace lines
 	$s =~ s/^\s*$//sgm;