user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH 0/2] www: unindexed v1 fixes
@ 2022-09-02  9:10 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 ` [PATCH 2/2] www: omit [thread overview] link for unindexed v1 Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2022-09-02  9:10 UTC (permalink / raw)
  To: meta

While it's rare to find someone running unindexed v1 inboxes
nowadays, we can't drop support for them, either.  So do our
best to ensure they still work.

Eric Wong (2):
  www: fix top nav bar for unindexed v1 inboxes
  www: omit [thread overview] link for unindexed v1

 lib/PublicInbox/View.pm | 10 ++++++++--
 t/plack.t               |  5 ++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] www: fix top nav bar for unindexed v1 inboxes
  2022-09-02  9:10 [PATCH 0/2] www: unindexed v1 fixes Eric Wong
@ 2022-09-02  9:10 ` Eric Wong
  2022-09-02  9:10 ` [PATCH 2/2] www: omit [thread overview] link for unindexed v1 Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2022-09-02  9:10 UTC (permalink / raw)
  To: meta

For /$INBOX/$MSGID/ pages, we need to point all nav bar links
../ regardless of whether ->over exists.  I've also verified
this doesn't affect /$INBOX/new.html at all.
---
 lib/PublicInbox/View.pm | 2 +-
 t/plack.t               | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 2e5228e1..11a94ba9 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -678,7 +678,7 @@ sub _msg_page_prepare_obuf {
 		$ctx->{chash} = content_hash($eml) if $ctx->{smsg}; # reused MID
 		$rv .= "<pre\nid=b>"; # anchor for body start
 	}
-	$ctx->{-upfx} = '../' if $have_over;
+	$ctx->{-upfx} = '../';
 	my @title; # (Subject[0], From[0])
 	for my $v ($eml->header('From')) {
 		my @n = PublicInbox::Address::names($v);
diff --git a/t/plack.t b/t/plack.t
index 32209c7d..3ba2e6fb 100644
--- a/t/plack.t
+++ b/t/plack.t
@@ -1,5 +1,5 @@
 #!perl -w
-# Copyright (C) 2014-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use v5.10.1;
@@ -154,6 +154,7 @@ my $c1 = sub {
 	$res = $cb->(GET($pfx . $path));
 	is(200, $res->code, "success for $path");
 	my $html = $res->content;
+	like($html, qr!\bhref="\Q../_/text/help/"!, 'help available');
 	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');

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] www: omit [thread overview] link for unindexed v1
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2022-09-02  9:10 UTC (permalink / raw)
  To: meta

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));

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-02  9:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 2/2] www: omit [thread overview] link for unindexed v1 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).