user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Cc: Eric Wong <e@80x24.org>
Subject: [PATCH] view: increase context in index views
Date: Wed,  3 Sep 2014 20:46:28 +0000	[thread overview]
Message-ID: <1409777188-28217-1-git-send-email-e@80x24.org> (raw)

It's probably better to show too much than too little, even
if this means extra scrolling :<

Otherwise, we end up punishing messages who quote minimally
and end up loosing context.  Unfortunately, too many people
over-quote nowadays.
---
 lib/PublicInbox/View.pm | 32 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 1fb4006..6195fe6 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -82,13 +82,15 @@ sub index_entry {
 		$anchor_idx = anchor_for($irp);
 		$anchor = $seen->{$anchor_idx};
 	}
-
+	my $href = $mid->as_href;
+	my $mhref = "m/$href.html";
+	my $fhref = "f/$href.html";
 	# scan through all parts, looking for displayable text
 	$mime->walk_parts(sub {
 		my ($part) = @_;
 		return if $part->subparts; # walk_parts already recurses
 		my $enc = enc_for($part->content_type) || $enc_msg || $enc_utf8;
-		my $more = '';
+		my $more;
 
 		if ($part_nr > 0) {
 			my $fn = $part->filename;
@@ -96,22 +98,14 @@ sub index_entry {
 			$rv .= $pfx . add_filename_line($enc->decode($fn));
 		}
 
-		my $s = ascii_html($enc->decode($part->body));
-
-		if (defined $anchor) {
-			# drop quotes, including the "so-and-so wrote:" line
-			$s =~ s/(?:^[^\n]*:\s*\n)?
-			       (?:^&gt;[^\n]*\n)+(?:^\s*\n)?//mgx;
-		}
+		my $s = add_text_body_short($enc, $part, $part_nr, $fhref);
 
-		# Drop signatures
-		$s =~ s/^-- \n.*\z//ms;
+		# keep signatures for now?  They shold usually be short,
+		# and sometimes footnotes/"P.S." appear there.
 
 		# drop the remainder of git patches, they're usually better
 		# to review when the full message is viewed
-		if ($s =~ s/^---\n.*\z//ms) {
-			$more = "$pfx...\n";
-		}
+		$s =~ s!^---\n.*\z!!ms and $more = 1;
 
 		# kill any leading or trailing whitespace
 		$s =~ s/\A\s+//s;
@@ -120,13 +114,14 @@ sub index_entry {
 		# add prefix:
 		$s =~ s/^/$pfx/sgm;
 
-		$rv .= $s . "\n$more";
+		$s .= "\n$pfx<a href=\"$mhref\">(more...)</a>\n" if $more;
+
+		$rv .= $s . "\n";
 		++$part_nr;
 	});
 
-	my $href = 'm/' . $mid->as_href . '.html';
-	$rv .= "$pfx<a\nhref=\"$href\">more</a> ";
-	my $txt = 'm/' . $mid->as_href . '.txt';
+	$rv .= "$pfx<a\nhref=\"$mhref\">link</a> ";
+	my $txt = "m/$href.txt";
 	$rv .= "<a\nhref=\"$txt\">raw</a> ";
 	$rv .= html_footer($mime, 0);
 
@@ -202,7 +197,6 @@ sub add_text_body_short {
 	my ($enc, $part, $part_nr, $full_pfx) = @_;
 	my $n = 0;
 	my $s = ascii_html($enc->decode($part->body));
-	# TODO: fold the "so-and-so wrote:" attribute line here, too:
 	$s =~ s!^((?:(?:&gt;[^\n]*)\n)+)!
 		my $cur = $1;
 		my @lines = split(/\n/, $cur);
-- 
EW


                 reply	other threads:[~2014-09-03 20:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1409777188-28217-1-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).