unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/2] www: omit [thread overview] link for unindexed v1
Date: Fri,  2 Sep 2022 09:10:54 +0000	[thread overview]
Message-ID: <20220902091054.1527844-3-e@80x24.org> (raw)
In-Reply-To: <20220902091054.1527844-1-e@80x24.org>

Unindexed v1 inboxes do not have the thread overview skeleton
at the bottom of /$MSGID/ pages, so do not link to it.
And for rare messages without a Date: header (or any headers!),
this also ensures the [thread overview] is shown regardless.
---
 lib/PublicInbox/View.pm | 8 +++++++-
 t/plack.t               | 2 ++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 11a94ba9..2b8e220b 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -717,7 +717,13 @@ sub _msg_page_prepare_obuf {
 	for my $v ($eml->header('Date')) {
 		$v = ascii_html($v);
 		obfuscate_addrs($obfs_ibx, $v) if $obfs_ibx; # possible :P
-		$rv .= qq{Date: $v\t<a\nhref="#r">[thread overview]</a>\n};
+		$rv .= qq{Date: $v\n};
+	}
+	# [thread overview] link is typically added after Date,
+	# but added after Subject, or even nothing.
+	if ($have_over) {
+		chop $rv; # drop "\n", or noop if $rv eq ''
+		$rv .= qq{\t<a\nhref="#r">[thread overview]</a>\n};
 	}
 	if (!$nr) { # first (and only) message, common case
 		$ctx->{-title_html} = join(' - ', @title);
diff --git a/t/plack.t b/t/plack.t
index 3ba2e6fb..1cee286d 100644
--- a/t/plack.t
+++ b/t/plack.t
@@ -158,6 +158,8 @@ my $c1 = sub {
 	like($html, qr!<title>hihi - Me</title>!, 'HTML returned');
 	like($html, qr!<a\nhref=raw!s, 'raw link present');
 	like($html, qr!&gt; quoted text!s, 'quoted text inline');
+	unlike($html, qr!thread overview!,
+		'thread overview not shown w/o ->over');
 
 	$path .= 'f/';
 	$res = $cb->(GET($pfx . $path));

      parent reply	other threads:[~2022-09-02  9:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-02  9:10 [PATCH 0/2] www: unindexed v1 fixes Eric Wong
2022-09-02  9:10 ` [PATCH 1/2] www: fix top nav bar for unindexed v1 inboxes Eric Wong
2022-09-02  9:10 ` 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=20220902091054.1527844-3-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.
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).