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 4/4] view: thread skeleton tweaks
Date: Fri, 15 Apr 2016 23:33:28 +0000	[thread overview]
Message-ID: <20160415233328.16081-5-e@80x24.org> (raw)
In-Reply-To: <20160415233328.16081-1-e@80x24.org>

Allow the Subject: <-> skeleton line to point to each other so
the reader can bounce around between them without refocusing
their browser.
---
 lib/PublicInbox/View.pm | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index ac44d44..f07979e 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -379,19 +379,20 @@ sub headers_to_html_header {
 }
 
 sub thread_skel {
-	my ($dst, $ctx, $hdr, $upfx) = @_;
+	my ($dst, $ctx, $hdr, $tpfx) = @_;
 	my $srch = $ctx->{srch};
 	my $mid = mid_clean($hdr->header_raw('Message-ID'));
 	my $sres = $srch->get_thread($mid);
 	my $nr = $sres->{total};
-	my $expand = "<a\nhref=\"${upfx}t/#u\">expand</a> " .
-			"/ <a\nhref=\"${upfx}t.mbox.gz\">mbox.gz</a>";
+	my $expand = qq(<a\nhref="${tpfx}t/#u">expand</a> ) .
+			qq(/ <a\nhref="${tpfx}t.mbox.gz">mbox.gz</a> ) .
+			qq(/ <a\nhref="${tpfx}t.atom">Atom feed</a>);
 
 	my $parent = in_reply_to($hdr);
 	if ($nr <= 1) {
 		if (defined $parent) {
 			$$dst .= "($expand)\n ";
-			$$dst .= ghost_parent("$upfx../", $parent) . "\n";
+			$$dst .= ghost_parent("$tpfx../", $parent) . "\n";
 		} else {
 			$$dst .= "[no followups, yet] ($expand)\n";
 		}
@@ -412,7 +413,7 @@ sub thread_skel {
 		prev_level => 0,
 	};
 	for (thread_results(load_results($sres))->rootset) {
-		skel_dump($dst, $state, $upfx, $_, 0);
+		skel_dump($dst, $state, $tpfx, $_, 0);
 	}
 	$ctx->{next_msg} = $state->{next_msg};
 	$ctx->{parent_msg} = $parent;
@@ -500,11 +501,8 @@ sub html_footer {
 	my $tpfx = '';
 	my $idx = $standalone ? " <a\nhref=\"$upfx\">index</a>" : '';
 	my $irt = '';
-
-	if ($srch && $standalone) {
-		$idx .= qq{ / follow: <a\nhref="${tpfx}t.atom">Atom feed</a>\n};
-	}
 	if ($idx && $srch) {
+		$idx .= "\n";
 		thread_skel(\$idx, $ctx, $hdr, $tpfx);
 		my $p = $ctx->{parent_msg};
 		my $next = $ctx->{next_msg};
@@ -709,7 +707,7 @@ sub _skel_header {
 	my $mid = mid_clean($hdr->header_raw('Message-ID'));
 	my $f = ascii_html($hdr->header('X-PI-From'));
 	my $d = _msg_date($hdr);
-	my $pfx = ' ' . $d . ' ' . indent_for($level);
+	my $pfx = $d . ' ' . indent_for($level);
 	my $attr = $f;
 	$state->{first_level} ||= $level;
 
@@ -723,7 +721,7 @@ sub _skel_header {
 	if ($cur) {
 		if ($cur eq $mid) {
 			delete $state->{cur};
-			$$dst .= "$pfx$dot<b><a\nid=r\nhref=\"#b\">".
+			$$dst .= "$pfx$dot<b><a\nid=r\nhref=\"#t\">".
 				 "$attr [this message]</a></b>\n";
 
 			return;
@@ -746,11 +744,8 @@ sub _skel_header {
 	}
 	my $m = PublicInbox::Hval->new_msgid($mid);
 	$m = $upfx . '../' . $m->as_href . '/';
-	if (defined $s) {
-		$$dst .= "$pfx$dot<a\nhref=\"$m\">$s</a> $attr\n";
-	} else {
-		$$dst .= "$pfx$dot<a\nhref=\"$m\">$f</a>\n";
-	}
+	$$dst .= "$pfx$dot<a\nhref=\"$m\">";
+	$$dst .= defined($s) ? "$s</a> $f\n" : "$f</a>\n";
 }
 
 sub skel_dump {
@@ -765,7 +760,7 @@ sub skel_dump {
 		if ($mid eq 'subject dummy') {
 			$$dst .= "\t[no common parent]\n";
 		} else {
-			$$dst .= '      [not found] ';
+			$$dst .= '     [not found] ';
 			my $dot = $level == 0 ? '' : '` ';
 			$$dst .= indent_for($level) . $dot;
 			$mid = PublicInbox::Hval->new_msgid($mid);
-- 
EW


      parent reply	other threads:[~2016-04-15 23:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-13  3:04 [PATCH] www: stop generating /$MESSAGE_ID/f/ links Eric Wong
2016-04-15 23:33 ` [PATCH 0/4] more quote-folding removal Eric Wong
2016-04-15 23:33   ` [PATCH 1/4] view: drop vestigial elements of quote folding Eric Wong
2016-04-15 23:33   ` [PATCH 2/4] doc: update design notes on WWW development Eric Wong
2016-04-15 23:33   ` [PATCH 3/4] www: redirect /$MESSAGE_ID/f/ endpoints Eric Wong
2016-04-15 23:33   ` Eric Wong [this message]

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=20160415233328.16081-5-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).