user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] view: link restructuring for index view
Date: Tue,  5 Apr 2016 06:26:35 +0000	[thread overview]
Message-ID: <20160405062635.26553-1-e@80x24.org> (raw)

The "next/prev" links seem a bit awkward and I don't use them as
much as I expected to.  However, move the "raw" message link
near the top since it's most useful for checking or reinforcing
the validity of the message via GPG or just reading headers.

Turn the Subject line into a permalink to the message, since
that's probably the common behavior anyways for other messaging
systems.  Make the "[threaded|flat]" view links to always
visible for bookmark-ability despite the lack of a "permalink"
label.
---
 lib/PublicInbox/View.pm | 43 +++++++++++++++----------------------------
 1 file changed, 15 insertions(+), 28 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index a4b580d..f074a24 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -102,7 +102,6 @@ sub index_entry {
 	my $midx = $state->{anchor_idx}++;
 	my $ctx = $state->{ctx};
 	my $srch = $ctx->{srch};
-	my ($prev, $next) = ($midx - 1, $midx + 1);
 	my $part_nr = 0;
 	my $hdr = $mime->header_obj;
 	my $enc = enc_for($hdr->header("Content-Type"));
@@ -126,44 +125,30 @@ sub index_entry {
 
 	$from = ascii_html($from);
 	$subj = ascii_html($subj);
-	if ($srch) {
-		my $t = $ctx->{flat} ? 'T' : 't';
-		$subj = "<a\nhref=\"${path}$href/$t/#u\">$subj</a>";
-	}
-	if ($root_anchor eq $id) {
-		$subj = "<u\nid=u>$subj</u>";
-	}
+	$subj = "<a\nhref=\"${path}$href/\">$subj</a>";
+	$subj = "<u\nid=u>$subj</u>" if $root_anchor eq $id;
 
 	my $ts = _msg_date($hdr);
 	my $rv = "<pre\nid=s$midx>";
 	$rv .= "<b\nid=$id>$subj</b>\n";
-	$rv .= "- $from @ $ts UTC - ";
-	$rv .= "<a\nhref=\"#s$next\">next</a>";
-	if ($prev >= 0) {
-		$rv .= "/<a\nhref=\"#s$prev\">prev</a>";
-	}
+	my $txt = "${path}$href/raw";
 	my $fh = $state->{fh};
-	$fh->write($rv .= "\n\n");
+	$fh->write($rv .= "- $from @ $ts UTC (<a\nhref=\"$txt\">raw</a>)\n\n");
 
-	my ($fhref, $more_ref);
+	my $fhref;
 	my $mhref = "${path}$href/";
-	my $more = 'permalink';
 
 	# show full message if it's our root message
 	my $neq = $root_anchor ne $id;
 	if ($neq || ($neq && $level != 0 && !$ctx->{flat})) {
 		$fhref = "${path}$href/f/";
-		$more_ref = \$more;
 	}
 	# scan through all parts, looking for displayable text
 	$mime->walk_parts(sub {
-		index_walk($fh, $_[0], $enc, \$part_nr, $fhref, $more_ref);
+		index_walk($fh, $_[0], $enc, \$part_nr, $fhref);
 	});
 	$mime->body_set('');
-
-	my $txt = "${path}$href/raw";
-	$rv = "\n<a\nhref=\"$mhref\">$more</a> <a\nhref=\"$txt\">raw</a> ";
-	$rv .= html_footer($hdr, 0, undef, $ctx, $mhref);
+	$rv = "\n" . html_footer($hdr, 0, undef, $ctx, $mhref);
 
 	if (defined $irt) {
 		unless (defined $parent_anchor) {
@@ -176,13 +161,15 @@ sub index_entry {
 	if (my $pct = $state->{pct}) { # used by SearchView.pm
 		$rv .= " [relevance $pct->{$mid_raw}%]";
 	} elsif ($srch) {
+		my $threaded = 'threaded';
+		my $flat = 'flat';
 		if ($ctx->{flat}) {
-			$rv .= " [<a\nhref=\"${path}$href/t/#u\">threaded</a>" .
-				"|<b>flat</b>]";
+			$flat = "<b>$flat</b>";
 		} else {
-			$rv .= " [<b>threaded</b>|" .
-				"<a\nhref=\"${path}$href/T/#u\">flat</a>]";
+			$threaded = "<b>$threaded</b>";
 		}
+		$rv .= " [<a\nhref=\"${path}$href/t/#u\">$threaded</a>";
+		$rv .= "|<a\nhref=\"${path}$href/T/#u\">$flat</a>]";
 	}
 	$fh->write($rv .= '</pre>');
 }
@@ -244,8 +231,8 @@ sub emit_thread_html {
 }
 
 sub index_walk {
-	my ($fh, $part, $enc, $part_nr, $fhref, $more) = @_;
-	my $s = add_text_body($enc, $part, $part_nr, $fhref);
+	my ($fh, $part, $enc, $part_nr, $fhref) = @_;
+	my $s = add_text_body($enc, $part, $part_nr, $fhref, 1);
 
 	return if $s eq '';
 
-- 
EW


                 reply	other threads:[~2016-04-05  6:26 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=20160405062635.26553-1-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).