]> Sergey Matveev's repositories - public-inbox.git/commitdiff
www: omit [thread overview] link for unindexed v1
authorEric Wong <e@80x24.org>
Fri, 2 Sep 2022 09:10:54 +0000 (09:10 +0000)
committerEric Wong <e@80x24.org>
Fri, 2 Sep 2022 17:40:05 +0000 (17:40 +0000)
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
t/plack.t

index 11a94ba938636ce28bd8d5373d5e2b3d50c811c6..2b8e220bb2a7f3ca4628a261c49f0efce04b4250 100644 (file)
@@ -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);
index 3ba2e6fb866c99c3769832da03b73e1287d6092c..1cee286d63a61e157e53dc88c8ba0e9dec9564e4 100644 (file)
--- 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));