From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 07/13] view: show more nearby messages in flat thread view
Date: Thu, 30 Jun 2016 09:21:37 +0000 [thread overview]
Message-ID: <20160630092143.31651-8-e@80x24.org> (raw)
In-Reply-To: <20160630092143.31651-1-e@80x24.org>
Context is important, but so is conserving precious screen
space. Decisions :<
---
lib/PublicInbox/View.pm | 42 ++++++++++++++++++++++++++++++++++++------
1 file changed, 36 insertions(+), 6 deletions(-)
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 9393d44..0b96bda 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -146,6 +146,13 @@ sub index_entry {
$rv .= $more ? "\n\n" : "\n";
}
+sub pad_link ($$;$) {
+ my ($mid, $level, $s) = @_;
+ $s ||= '...';
+ my $id = id_compress($mid, 1);
+ (' 'x19).indent_for($level).th_pfx($level)."<a\nhref=#r$id>($s)<a>\n";
+}
+
sub _th_index_lite {
my ($mid_raw, $irt, $id, $ctx) = @_;
my $rv = '';
@@ -155,16 +162,24 @@ sub _th_index_lite {
my $map = $mapping->{$mid_raw};
my $nr_c = scalar @{$map->[0]};
my $nr_s = 0;
+ my $level = $map->[4];
+ my $idx = $map->[3];
if (defined $irt) {
my $irt_map = $mapping->{$irt};
my $siblings = $irt_map->[0];
$nr_s = scalar(@$siblings) - 1;
- $nr_s = 0 if $nr_s < 0;
$rv .= $pad . $irt_map->[1];
- my $idx = $map->[3];
if ($idx > 0) {
my $prev = $siblings->[$idx - 1];
- $rv .= $pad . $mapping->{$prev->messageid}->[1];
+ my $pmid = $prev->messageid;
+ if ($idx > 2) {
+ my $s = ($idx - 1). ' preceding siblings ...';
+ $rv .= pad_link($pmid, $level, $s);
+ } elsif ($idx == 2) {
+ my $ppmid = $siblings->[0]->messageid;
+ $rv .= $pad . $mapping->{$ppmid}->[1];
+ }
+ $rv .= $pad . $mapping->{$pmid}->[1];
}
}
my $s_s = nr_to_s($nr_s, 'sibling', 'siblings');
@@ -175,10 +190,25 @@ sub _th_index_lite {
$rv .= "<b>@ $this";
my $node = $map->[2];
if (my $child = $node->child) {
- $rv .= $pad . $mapping->{$child->messageid}->[1];
+ my $cmid = $child->messageid;
+ $rv .= $pad . $mapping->{$cmid}->[1];
+ if ($nr_c > 2) {
+ my $s = ($nr_c - 1). ' more replies';
+ $rv .= pad_link($cmid, $level + 1, $s);
+ } elsif (my $cn = $child->next) {
+ $rv .= $pad . $mapping->{$cn->messageid}->[1];
+ }
}
if (my $next = $node->next) {
- $rv .= $pad . $mapping->{$next->messageid}->[1];
+ my $nmid = $next->messageid;
+ $rv .= $pad . $mapping->{$nmid}->[1];
+ my $nnext = $nr_s - $idx;
+ if ($nnext > 2) {
+ my $s = ($nnext - 1).' subsequent siblings';
+ $rv .= pad_link($nmid, $level, $s);
+ } elsif (my $nn = $next->next) {
+ $rv .= $pad . $mapping->{$nn->messageid}->[1];
+ }
}
$rv .= "<a\nhref=#e$id\nid=m$id>_<a> <a\nhref=#r$id\n>$s_s, $s_c</a>\n";
}
@@ -203,7 +233,7 @@ sub pre_thread {
$idx = scalar @$m;
push @$m, $node;
}
- $mapping->{$node->messageid} = [ [], '', $node, $idx ];
+ $mapping->{$node->messageid} = [ [], '', $node, $idx, $level ];
skel_dump($ctx, $level, $node);
}
--
EW
next prev parent reply other threads:[~2016-06-30 9:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-30 9:21 [PATCH 0/13] www: hybrid flat+thread conversation view Eric Wong
2016-06-30 9:21 ` [PATCH 01/13] www: implement " Eric Wong
2016-06-30 9:21 ` [PATCH 02/13] www: use WwwStream for dumping thread and search views Eric Wong
2016-06-30 9:21 ` [PATCH 03/13] view: show thread context in the thread-aware flat view Eric Wong
2016-06-30 9:21 ` [PATCH 04/13] view: merge $state hash with existing $ctx Eric Wong
2016-06-30 9:21 ` [PATCH 05/13] feed: add $INBOX/new.html endpoint Eric Wong
2016-06-30 9:21 ` [PATCH 06/13] view: tweak thread/index header slightly Eric Wong
2016-06-30 9:21 ` Eric Wong [this message]
2016-06-30 9:21 ` [PATCH 08/13] www: reinstate old thread view as an option Eric Wong
2016-06-30 9:21 ` [PATCH 09/13] view: fix up some HTML injection via Message-ID vectors Eric Wong
2016-06-30 19:03 ` [PATCH 14/13] view: fix permalink and raw links at the top Eric Wong
2016-06-30 9:21 ` [PATCH 10/13] view: default to flat/hybrid thread display Eric Wong
2016-06-30 9:21 ` [PATCH 11/13] view: show thread size when linking to summary Eric Wong
2016-06-30 9:21 ` [PATCH 12/13] view: fixup bad reference to new_msgid Eric Wong
2016-06-30 9:21 ` [PATCH 13/13] www_stream: add response wrapper sub Eric Wong
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=20160630092143.31651-8-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).