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 4/7] view: simplify parent anchoring code
Date: Wed,  2 Sep 2015 06:59:36 +0000	[thread overview]
Message-ID: <1441177179-16628-5-git-send-email-e@80x24.org> (raw)
In-Reply-To: <1441177179-16628-1-git-send-email-e@80x24.org>

This will make things easier for the next commit to pre-populate
the `$seen' hash for linking within the flat view of a thread.
---
 lib/PublicInbox/View.pm | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index d213124..0331b62 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -74,7 +74,7 @@ sub index_entry {
 	my $mid_raw = $header_obj->header('Message-ID');
 	my $id = anchor_for($mid_raw);
 	my $seen = $state->{seen};
-	$seen->{$id} = "#$id"; # save the anchor for later
+	$seen->{$id} = "#$id"; # save the anchor for children, later
 
 	my $mid = PublicInbox::Hval->new_msgid($mid_raw);
 	my $from = PublicInbox::Hval->new_oneline($mime->header('From'))->raw;
@@ -88,12 +88,8 @@ sub index_entry {
 	my $path = $root_anchor ? '../../' : '';
 	my $href = $mid->as_href;
 	my $irt = in_reply_to($header_obj);
+	my $parent_anchor = $seen->{anchor_for($irt)} if defined $irt;
 
-	my ($anchor_idx, $anchor);
-	if (defined $irt) {
-		$anchor_idx = anchor_for($irt);
-		$anchor = $seen->{$anchor_idx};
-	}
 	if ($srch) {
 		my $t = $ctx->{flat} ? 'T' : 't';
 		$subj = "<a\nhref=\"${path}$href/$t/#u\">$subj</a>";
@@ -135,13 +131,12 @@ sub index_entry {
 	$rv .= html_footer($mime, 0, undef, $ctx);
 
 	if (defined $irt) {
-		unless (defined $anchor) {
+		unless (defined $parent_anchor) {
 			my $v = PublicInbox::Hval->new_msgid($irt);
 			$v = $v->as_href;
-			$anchor = "${path}$v/";
-			$seen->{$anchor_idx} = $anchor;
+			$parent_anchor = "${path}$v/";
 		}
-		$rv .= " <a\nhref=\"$anchor\">parent</a>";
+		$rv .= " <a\nhref=\"$parent_anchor\">parent</a>";
 	}
 	if ($srch) {
 		if ($ctx->{flat}) {
-- 
EW


  parent reply	other threads:[~2015-09-02  6:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-02  6:59 [PATCH 0/7] improved thread views and 404 reductions Eric Wong
2015-09-02  6:59 ` [PATCH 1/7] view: close possible race condition in thread view Eric Wong
2015-09-02  6:59 ` [PATCH 2/7] view: optional flat view for recent messages Eric Wong
2015-09-02  6:59 ` [PATCH 3/7] view: account for missing In-Reply-To header Eric Wong
2015-09-02  6:59 ` Eric Wong [this message]
2015-09-02  6:59 ` [PATCH 5/7] view: pre-anchor entries for flat view Eric Wong
2015-09-02  6:59 ` [PATCH 6/7] view: avoid links to unknown compressed Message-IDs Eric Wong
2015-09-02  6:59 ` [PATCH 7/7] implement external Message-ID finder 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=1441177179-16628-5-git-send-email-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).