unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH 0/9] another round of updates
@ 2015-09-04  8:58 Eric Wong
  2015-09-04  8:58 ` [PATCH 1/9] view: eliminate redundant [threaded|flat] link Eric Wong
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Eric Wong @ 2015-09-04  8:58 UTC (permalink / raw)
  To: meta

Another round of updates, mostly minor tweaks and visual changes
to hopefully make navigation more sensible.

 lib/PublicInbox/View.pm | 66 +++++++++++++++++++++++++++++--------------------
 lib/PublicInbox/WWW.pm  |  7 ++++++
 2 files changed, 46 insertions(+), 27 deletions(-)


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

* [PATCH 1/9] view: eliminate redundant [threaded|flat] link
  2015-09-04  8:58 [PATCH 0/9] another round of updates Eric Wong
@ 2015-09-04  8:58 ` Eric Wong
  2015-09-04  8:58 ` [PATCH 2/9] view: one line for thread subjects Eric Wong
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Eric Wong @ 2015-09-04  8:58 UTC (permalink / raw)
  To: meta

We do not need to waste space with that link when
we have it conveniently placed where every message
is located.
---
 lib/PublicInbox/View.pm | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index bd174b1..bb3afda 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -196,11 +196,6 @@ sub emit_thread_html {
 	my $next = "<a\nid=\"s$final_anchor\">";
 	$next .= $final_anchor == 1 ? 'only message in' : 'end of';
 	$next .= " thread</a>, back to <a\nhref=\"../../\">index</a>";
-	if ($flat) {
-		$next .= " [<a\nhref=\"../t/#u\">threaded</a>|<b>flat</b>]";
-	} else {
-		$next .= " [<b>threaded</b>|<a\nhref=\"../T/#u\">flat</a>]";
-	}
 	$next .= "\ndownload thread: <a\nhref=\"../t.mbox.gz\">mbox.gz</a>";
 	$next .= " / follow: <a\nhref=\"../t.atom\">Atom feed</a>";
 	$cb->write("<hr />" . PRE_WRAP . $next . "\n\n". $foot .
-- 
EW


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

* [PATCH 2/9] view: one line for thread subjects
  2015-09-04  8:58 [PATCH 0/9] another round of updates Eric Wong
  2015-09-04  8:58 ` [PATCH 1/9] view: eliminate redundant [threaded|flat] link Eric Wong
@ 2015-09-04  8:58 ` Eric Wong
  2015-09-04  8:58 ` [PATCH 3/9] view: adjust spacing and indentation of index threads Eric Wong
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Eric Wong @ 2015-09-04  8:58 UTC (permalink / raw)
  To: meta

We truncate subjects in the Xapian document anyways,
so lines should not be too long and it hopefully won't
throw off the vertical display.
---
 lib/PublicInbox/View.pm | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index bb3afda..5c53622 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -722,8 +722,7 @@ sub _inline_header {
 	my $m = PublicInbox::Hval->new_msgid($mid);
 	$m = $upfx . '../' . $m->as_href . '/';
 	if (defined $s) {
-		$$dst .= "$pfx` <a\nhref=\"$m\">$s</a>\n" .
-		         "$pfx  $f @ $d\n";
+		$$dst .= "$pfx` <a\nhref=\"$m\">$s</a> by $f @ $d\n";
 	} else {
 		$$dst .= "$pfx` <a\nhref=\"$m\">$f @ $d</a>\n";
 	}
-- 
EW


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

* [PATCH 3/9] view: adjust spacing and indentation of index threads
  2015-09-04  8:58 [PATCH 0/9] another round of updates Eric Wong
  2015-09-04  8:58 ` [PATCH 1/9] view: eliminate redundant [threaded|flat] link Eric Wong
  2015-09-04  8:58 ` [PATCH 2/9] view: one line for thread subjects Eric Wong
@ 2015-09-04  8:58 ` Eric Wong
  2015-09-04  8:58 ` [PATCH 4/9] view: add missing newline to inline dump Eric Wong
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Eric Wong @ 2015-09-04  8:58 UTC (permalink / raw)
  To: meta

Avoid wasting precious horizontal space by indenting children
excessively relative to the top-level parent.
---
 lib/PublicInbox/View.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 5c53622..c53e2e1 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -809,9 +809,9 @@ sub dump_topics {
 		$mid = PublicInbox::Hval->new($mid)->as_href;
 		$subj = PublicInbox::Hval->new($subj)->as_html;
 		$u = PublicInbox::Hval->new($u)->as_html;
-		$pfx = INDENT x $level;
+		$pfx = INDENT x ($level - 1);
 		my $nl = $level == $prev ? "\n" : '';
-		my $dot = $level == 0 ? '' : '`';
+		my $dot = $level == 0 ? '' : '` ';
 		$dst .= "$nl$pfx$dot<a\nhref=\"$mid/t/#u\"><b>$subj</b></a>\n";
 
 		my $attr;
-- 
EW


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

* [PATCH 4/9] view: add missing newline to inline dump
  2015-09-04  8:58 [PATCH 0/9] another round of updates Eric Wong
                   ` (2 preceding siblings ...)
  2015-09-04  8:58 ` [PATCH 3/9] view: adjust spacing and indentation of index threads Eric Wong
@ 2015-09-04  8:58 ` Eric Wong
  2015-09-04  8:58 ` [PATCH 5/9] view: reduce redundant attributions in permalink refs Eric Wong
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Eric Wong @ 2015-09-04  8:58 UTC (permalink / raw)
  To: meta

This fixes a regression introduced in
commit 16ca6b7a57266fcb466ffff005bc1d644bad14c1
(view: avoid attempting to find "subject dummy")
---
 lib/PublicInbox/View.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index c53e2e1..6b71703 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -738,8 +738,8 @@ sub inline_dump {
 		}
 		_inline_header($dst, $state, $upfx, $mime, $level);
 	} else {
-		my $pfx = INDENT x $level;
-		$$dst .= $pfx . '` ' . ghost_parent($upfx, $node->messageid);
+		my $pfx = (INDENT x $level) . '` ';
+		$$dst .= $pfx . ghost_parent($upfx, $node->messageid) . "\n";
 	}
 	inline_dump($dst, $state, $upfx, $node->child, $level+1);
 	inline_dump($dst, $state, $upfx, $node->next, $level);
-- 
EW


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

* [PATCH 5/9] view: reduce redundant attributions in permalink refs
  2015-09-04  8:58 [PATCH 0/9] another round of updates Eric Wong
                   ` (3 preceding siblings ...)
  2015-09-04  8:58 ` [PATCH 4/9] view: add missing newline to inline dump Eric Wong
@ 2015-09-04  8:58 ` Eric Wong
  2015-09-04  8:58 ` [PATCH 6/9] view: indentation adjustments for collapsed headers Eric Wong
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Eric Wong @ 2015-09-04  8:58 UTC (permalink / raw)
  To: meta

No point in repeating authorship when PATCH messages are
threaded and it's obvious from the top message who the author
is of the series:

 [this message] - John Smith @ 2015-09-04 00:04:20 UTC
  ` [PATCH 1/4] view: eliminate redundant [threaded|flat] link
  ` [PATCH 2/4] view: one line for thread subjects
  ` [PATCH 3/4] view: adjust spacing and indentation of index threads
  ` [PATCH 4/4] view: add missing newline to inline dump
---
 lib/PublicInbox/View.pm | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 6b71703..d025c99 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -465,6 +465,8 @@ sub thread_inline {
 		cur => $mid,
 		parent_cmp => defined $parent ? $parent : '',
 		parent => $parent,
+		prev_attr => '',
+		prev_level => 0,
 	};
 	for (thread_results(load_results($res))->rootset) {
 		inline_dump($dst, $state, $upfx, $_, 0);
@@ -691,15 +693,24 @@ sub _inline_header {
 	my $mid = mid_clean($mime->header('Message-ID'));
 	my $f = $mime->header('X-PI-From');
 	my $d = _msg_date($mime);
-	$f = PublicInbox::Hval->new($f);
-	$d = PublicInbox::Hval->new($d);
-	$f = $f->as_html;
-	$d = $d->as_html . ' UTC';
+	$f = PublicInbox::Hval->new($f)->as_html;
+	$d = PublicInbox::Hval->new($d)->as_html;
+	my $attr = "$f @ $d";
+	$state->{first_level} ||= $level;
+	if ($attr ne $state->{prev_attr} || $state->{prev_level} > $level) {
+		$state->{prev_attr} = $attr;
+		$attr = ' - ' . $attr;
+		$attr .= ' UTC' if $level >= $state->{first_level};
+	} else {
+		$attr = '';
+	}
+	$state->{prev_level} = $level;
+
 	if ($cur) {
 		if ($cur eq $mid) {
 			delete $state->{cur};
 			$$dst .= "$pfx` <b><a\nid=\"r\"\nhref=\"#t\">".
-				 "[this message]</a></b> by $f @ $d\n";
+				 "[this message]</a></b>$attr\n";
 
 			return;
 		}
@@ -722,7 +733,7 @@ sub _inline_header {
 	my $m = PublicInbox::Hval->new_msgid($mid);
 	$m = $upfx . '../' . $m->as_href . '/';
 	if (defined $s) {
-		$$dst .= "$pfx` <a\nhref=\"$m\">$s</a> by $f @ $d\n";
+		$$dst .= "$pfx` <a\nhref=\"$m\">$s</a>$attr\n";
 	} else {
 		$$dst .= "$pfx` <a\nhref=\"$m\">$f @ $d</a>\n";
 	}
-- 
EW


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

* [PATCH 6/9] view: indentation adjustments for collapsed headers
  2015-09-04  8:58 [PATCH 0/9] another round of updates Eric Wong
                   ` (4 preceding siblings ...)
  2015-09-04  8:58 ` [PATCH 5/9] view: reduce redundant attributions in permalink refs Eric Wong
@ 2015-09-04  8:58 ` Eric Wong
  2015-09-04  8:58 ` [PATCH 7/9] view: thread view expands focused message Eric Wong
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Eric Wong @ 2015-09-04  8:58 UTC (permalink / raw)
  To: meta

This makes the layout between the permalink threads and
index threads more consistent; hopefully.
---
 lib/PublicInbox/View.pm | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index d025c99..4e800c6 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -687,7 +687,8 @@ sub _msg_date {
 
 sub _inline_header {
 	my ($dst, $state, $upfx, $mime, $level) = @_;
-	my $pfx = INDENT x $level;
+	my $pfx = INDENT x ($level - 1);
+	my $dot = $level == 0 ? '' : '` ';
 
 	my $cur = $state->{cur};
 	my $mid = mid_clean($mime->header('Message-ID'));
@@ -709,7 +710,7 @@ sub _inline_header {
 	if ($cur) {
 		if ($cur eq $mid) {
 			delete $state->{cur};
-			$$dst .= "$pfx` <b><a\nid=\"r\"\nhref=\"#t\">".
+			$$dst .= "$pfx$dot<b><a\nid=\"r\"\nhref=\"#t\">".
 				 "[this message]</a></b>$attr\n";
 
 			return;
@@ -733,9 +734,9 @@ sub _inline_header {
 	my $m = PublicInbox::Hval->new_msgid($mid);
 	$m = $upfx . '../' . $m->as_href . '/';
 	if (defined $s) {
-		$$dst .= "$pfx` <a\nhref=\"$m\">$s</a>$attr\n";
+		$$dst .= "$pfx$dot<a\nhref=\"$m\">$s</a>$attr\n";
 	} else {
-		$$dst .= "$pfx` <a\nhref=\"$m\">$f @ $d</a>\n";
+		$$dst .= "$pfx$dot<a\nhref=\"$m\">$f @ $d</a>\n";
 	}
 }
 
@@ -749,7 +750,8 @@ sub inline_dump {
 		}
 		_inline_header($dst, $state, $upfx, $mime, $level);
 	} else {
-		my $pfx = (INDENT x $level) . '` ';
+		my $dot = $level == 0 ? '' : '` ';
+		my $pfx = (INDENT x $level) . $dot;
 		$$dst .= $pfx . ghost_parent($upfx, $node->messageid) . "\n";
 	}
 	inline_dump($dst, $state, $upfx, $node->child, $level+1);
@@ -775,6 +777,7 @@ sub rsort_ts {
 sub add_topic {
 	my ($state, $node, $level) = @_;
 	return unless $node;
+	my $child_adjust = 1;
 
 	if (my $x = $node->message) {
 		$x = $x->header_obj;
@@ -797,9 +800,12 @@ sub add_topic {
 		my $u = $x->header('X-PI-From');
 		my $ts = $x->header('X-PI-TS');
 		$state->{latest}->{$topic} = [ $mid, $u, $ts ];
-	} # else { } # ghost ignored...
+	} else {
+		# ghost message, do not bump level
+		$child_adjust = 0;
+	}
 
-	add_topic($state, $node->child, $level + 1);
+	add_topic($state, $node->child, $level + $child_adjust);
 	add_topic($state, $node->next, $level);
 }
 
@@ -838,7 +844,8 @@ sub dump_topics {
 			$n = " ($n)\n";
 		}
 		if ($level == 0 || $attr ne $prev_attr) {
-			$dst .= "$pfx - ". $attr . $n;
+			$pfx .= INDENT if $level > 0;
+			$dst .= "$pfx- ". $attr . $n;
 			$prev_attr = $attr;
 		}
 	}
-- 
EW


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

* [PATCH 7/9] view: thread view expands focused message
  2015-09-04  8:58 [PATCH 0/9] another round of updates Eric Wong
                   ` (5 preceding siblings ...)
  2015-09-04  8:58 ` [PATCH 6/9] view: indentation adjustments for collapsed headers Eric Wong
@ 2015-09-04  8:58 ` Eric Wong
  2015-09-04  8:58 ` [PATCH 8/9] www: extra redirects for the '/'-challenged Eric Wong
  2015-09-04  8:58 ` [PATCH 9/9] view: fix broken link to ghost fallback Eric Wong
  8 siblings, 0 replies; 10+ messages in thread
From: Eric Wong @ 2015-09-04  8:58 UTC (permalink / raw)
  To: meta

Non-top-level messages still deserve to be shown in full
if they're the message in the URL.
---
 lib/PublicInbox/View.pm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 4e800c6..ea31364 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -85,7 +85,7 @@ sub index_entry {
 	$from = PublicInbox::Hval->new_oneline($from)->as_html;
 	$subj = PublicInbox::Hval->new_oneline($subj)->as_html;
 	my $more = 'permalink';
-	my $root_anchor = $state->{root_anchor};
+	my $root_anchor = $state->{root_anchor} || '';
 	my $path = $root_anchor ? '../../' : '';
 	my $href = $mid->as_href;
 	my $irt = in_reply_to($header_obj);
@@ -95,7 +95,7 @@ sub index_entry {
 		my $t = $ctx->{flat} ? 'T' : 't';
 		$subj = "<a\nhref=\"${path}$href/$t/#u\">$subj</a>";
 	}
-	if ($root_anchor && $root_anchor eq $id) {
+	if ($root_anchor eq $id) {
 		$subj = "<u\nid=\"u\">$subj</u>";
 	}
 
@@ -116,8 +116,8 @@ sub index_entry {
 	my ($fhref, $more_ref);
 	my $mhref = "${path}$href/";
 
-	# show full messages at level == 0 in threaded view
-	if ($level > 0 || ($ctx->{flat} && $root_anchor ne $id)) {
+	# show full message if it's our root message
+	if ($root_anchor ne $id) {
 		$fhref = "${path}$href/f/";
 		$more_ref = \$more;
 	}
-- 
EW


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

* [PATCH 8/9] www: extra redirects for the '/'-challenged
  2015-09-04  8:58 [PATCH 0/9] another round of updates Eric Wong
                   ` (6 preceding siblings ...)
  2015-09-04  8:58 ` [PATCH 7/9] view: thread view expands focused message Eric Wong
@ 2015-09-04  8:58 ` Eric Wong
  2015-09-04  8:58 ` [PATCH 9/9] view: fix broken link to ghost fallback Eric Wong
  8 siblings, 0 replies; 10+ messages in thread
From: Eric Wong @ 2015-09-04  8:58 UTC (permalink / raw)
  To: meta

Omitting a slash should not be fatal if unambiguous.  Add
fallbacks so users who expect a directory structure-like
experience can have it at the cost of one extra HTTP
request/response pair.

This matches behavior of static sites.
---
 lib/PublicInbox/WWW.pm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index e8b35cb..5584e49 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -42,6 +42,10 @@ sub run {
 	} elsif ($path_info =~ m!$LISTNAME_RE/$MID_RE/$END_RE\z!o) {
 		msg_page($ctx, $1, $2, $3);
 
+	# in case people leave off the trailing slash:
+	} elsif ($path_info =~ m!$LISTNAME_RE/$MID_RE/(f|T|t)\z!o) {
+		r301($ctx, $1, $2, $3 eq 't' ? 't/#u' : $3);
+
 	# convenience redirects order matters
 	} elsif ($path_info =~ m!$LISTNAME_RE/([^/]{2,})\z!o) {
 		r301($ctx, $1, $2);
@@ -354,6 +358,9 @@ sub legacy_redirects {
 	} elsif ($path_info =~ m!$LISTNAME_RE/(\S+/\S+)/$END_RE\z!o) {
 		msg_page($ctx, $1, $2, $3);
 
+	# in case people leave off the trailing slash:
+	} elsif ($path_info =~ m!$LISTNAME_RE/(\S+/\S+)/(f|T|t)\z!o) {
+		r301($ctx, $1, $2, $3 eq 't' ? 't/#u' : $3);
 	} else {
 		r404();
 	}
-- 
EW


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

* [PATCH 9/9] view: fix broken link to ghost fallback
  2015-09-04  8:58 [PATCH 0/9] another round of updates Eric Wong
                   ` (7 preceding siblings ...)
  2015-09-04  8:58 ` [PATCH 8/9] www: extra redirects for the '/'-challenged Eric Wong
@ 2015-09-04  8:58 ` Eric Wong
  8 siblings, 0 replies; 10+ messages in thread
From: Eric Wong @ 2015-09-04  8:58 UTC (permalink / raw)
  To: meta

Once again, the regression was introduced in
commit 16ca6b7a57266fcb466ffff005bc1d644bad14c1
(view: avoid attempting to find "subject dummy")
---
 lib/PublicInbox/View.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index ea31364..df2de40 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -620,7 +620,7 @@ sub __thread_entry {
 		foreach my $g (@$ghost) {
 			$$cb->write("<table\nsummary=ghost><tr><td>" .
 				(INDENT x $g->[1]) . "</td><td>" .
-				PRE_WRAP . ghost_parent('', $g->[0]) .
+				PRE_WRAP . ghost_parent('../', $g->[0]) .
 				'</pre></td></table>');
 		}
 	}
-- 
EW


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

end of thread, other threads:[~2015-09-04  8:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-04  8:58 [PATCH 0/9] another round of updates Eric Wong
2015-09-04  8:58 ` [PATCH 1/9] view: eliminate redundant [threaded|flat] link Eric Wong
2015-09-04  8:58 ` [PATCH 2/9] view: one line for thread subjects Eric Wong
2015-09-04  8:58 ` [PATCH 3/9] view: adjust spacing and indentation of index threads Eric Wong
2015-09-04  8:58 ` [PATCH 4/9] view: add missing newline to inline dump Eric Wong
2015-09-04  8:58 ` [PATCH 5/9] view: reduce redundant attributions in permalink refs Eric Wong
2015-09-04  8:58 ` [PATCH 6/9] view: indentation adjustments for collapsed headers Eric Wong
2015-09-04  8:58 ` [PATCH 7/9] view: thread view expands focused message Eric Wong
2015-09-04  8:58 ` [PATCH 8/9] www: extra redirects for the '/'-challenged Eric Wong
2015-09-04  8:58 ` [PATCH 9/9] view: fix broken link to ghost fallback Eric Wong

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