user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] view: conditionally anchor to thread skeleton
@ 2016-07-10  1:24 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2016-07-10  1:24 UTC (permalink / raw)
  To: meta

We only care about the thread skeleton if we have
multiple messages in a thread, single message threads
can just go to the top of the message.
---
 lib/PublicInbox/View.pm | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 3d6348c..4906864 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -905,11 +905,18 @@ sub dump_topics {
 
 		# $n isn't the total number of posts on the topic,
 		# just the number of posts in the current results window
-		$n = $n == 1 ? '' : " ($n+ messages)";
+		my $anchor;
+		if ($n == 1) {
+			$n = '';
+			$anchor = '#u'; # top of only message
+		} else {
+			$n = " ($n+ messages)";
+			$anchor = '#t'; # thread skeleton
+		}
 
 		my $mbox = qq(<a\nhref="$href/t.mbox.gz">mbox.gz</a>);
 		my $atom = qq(<a\nhref="$href/t.atom">Atom</a>);
-		my $s = "<a\nhref=\"$href/T/#t\"><b>$top</b></a>\n" .
+		my $s = "<a\nhref=\"$href/T/$anchor\"><b>$top</b></a>\n" .
 			" $ts UTC $n - $mbox / $atom\n";
 		for (my $i = 0; $i < scalar(@ex); $i += 2) {
 			my $level = $ex[$i];
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-07-10  1:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-10  1:24 [PATCH] view: conditionally anchor to thread skeleton 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).