user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 4/7] view: simplify parent anchoring code
  2015-09-02  6:59  6% [PATCH 0/7] improved thread views and 404 reductions Eric Wong
@ 2015-09-02  6:59  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-09-02  6:59 UTC (permalink / raw)
  To: meta

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


^ permalink raw reply related	[relevance 7%]

* [PATCH 0/7] improved thread views and 404 reductions
@ 2015-09-02  6:59  6% Eric Wong
  2015-09-02  6:59  7% ` [PATCH 4/7] view: simplify parent anchoring code Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2015-09-02  6:59 UTC (permalink / raw)
  To: meta

The thread HTML view may now be flat (chronological, newest
first) to make active threads easier-to-follow.  We also make
unknown Message-IDs more usable by avoiding running SHA-1
on them.

The Message-ID finder is also handy for cross posts
and can probably link to multiple, external sources such as
mid.gmane.org and other places.

Eric Wong (7):
      view: close possible race condition in thread view
      view: optional flat view for recent messages
      view: account for missing In-Reply-To header
      view: simplify parent anchoring code
      view: pre-anchor entries for flat view
      view: avoid links to unknown compressed Message-IDs
      implement external Message-ID finder

 lib/PublicInbox/ExtMsg.pm |  92 ++++++++++++++++++++++++
 lib/PublicInbox/Hval.pm   |   4 +-
 lib/PublicInbox/View.pm   | 180 ++++++++++++++++++++++++++++++----------------
 lib/PublicInbox/WWW.pm    |  18 +++--
 public-inbox.cgi          |   1 +
 5 files changed, 226 insertions(+), 69 deletions(-)


^ permalink raw reply	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-09-02  6:59  6% [PATCH 0/7] improved thread views and 404 reductions Eric Wong
2015-09-02  6:59  7% ` [PATCH 4/7] view: simplify parent anchoring code 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).