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 2/7] view: optional flat view for recent messages
  2015-09-02  6:59  7% [PATCH 0/7] improved thread views and 404 reductions Eric Wong
@ 2015-09-02  6:59  5% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-09-02  6:59 UTC (permalink / raw)
  To: meta

For still-active threads, it will likely be easier to follow
them chronologically, especially if we have links to parent
messages.
---
 lib/PublicInbox/View.pm | 67 ++++++++++++++++++++++++++++++++++---------------
 lib/PublicInbox/WWW.pm  |  3 +++
 2 files changed, 50 insertions(+), 20 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 1eb12a9..a3df319 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -81,7 +81,8 @@ sub index_entry {
 		$anchor = $seen->{$anchor_idx};
 	}
 	if ($srch) {
-		$subj = "<a\nhref=\"${path}$href/t/#u\">$subj</a>";
+		my $t = $ctx->{flat} ? 'T' : 't';
+		$subj = "<a\nhref=\"${path}$href/$t/#u\">$subj</a>";
 	}
 	if ($root_anchor && $root_anchor eq $id) {
 		$subj = "<u\nid=\"u\">$subj</u>";
@@ -103,7 +104,9 @@ sub index_entry {
 
 	my ($fhref, $more_ref);
 	my $mhref = "${path}$href/";
-	if ($level > 0) {
+
+	# show full messages at level == 0 in threaded view
+	if ($level > 0 || ($ctx->{flat} && $root_anchor ne $id)) {
 		$fhref = "${path}$href/f/";
 		$more_ref = \$more;
 	}
@@ -126,6 +129,15 @@ sub index_entry {
 		}
 		$rv .= " <a\nhref=\"$anchor\">parent</a>";
 	}
+	if ($srch) {
+		if ($ctx->{flat}) {
+			$rv .= " [<a\nhref=\"${path}$href/t/#u\">threaded</a>" .
+				"|<b>flat</b>]";
+		} else {
+			$rv .= " [<b>threaded</b>|" .
+				"<a\nhref=\"${path}$href/T/#u\">flat</a>]";
+		}
+	}
 
 	$fh->write($rv .= '</pre></td></tr></table>');
 }
@@ -144,19 +156,24 @@ sub emit_thread_html {
 	my $msgs = load_results($res);
 	my $nr = scalar @$msgs;
 	return missing_thread($cb) if $nr == 0;
+	my $flat = $ctx->{flat};
 	my $orig_cb = $cb;
-	my $th = thread_results($msgs);
 	my $state = {
 		ctx => $ctx,
 		seen => {},
 		root_anchor => anchor_for($mid),
 		anchor_idx => 0,
 	};
-	{
-		require PublicInbox::GitCatFile;
-		my $git = PublicInbox::GitCatFile->new($ctx->{git_dir});
+
+	require PublicInbox::GitCatFile;
+	my $git = PublicInbox::GitCatFile->new($ctx->{git_dir});
+	if ($flat) {
+		__thread_entry(\$cb, $git, $state, $_, 0) for (@$msgs);
+	} else {
+		my $th = thread_results($msgs);
 		thread_entry(\$cb, $git, $state, $_, 0) for $th->rootset;
 	}
+	$git = undef;
 	Email::Address->purge_cache;
 
 	# there could be a race due to a message being deleted in git
@@ -166,10 +183,15 @@ sub emit_thread_html {
 	my $final_anchor = $state->{anchor_idx};
 	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>\n";
-	$next .= "download thread: <a\nhref=\"../t.mbox.gz\">mbox.gz</a>";
-	$next .= " / follow: <a\nhref=\"../t.atom\">Atom feed</a>\n\n";
-	$cb->write("<hr />" . PRE_WRAP . $next . $foot .
+	$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 .
 		   "</pre></body></html>");
 	$cb->close;
 }
@@ -549,20 +571,25 @@ sub thread_html_head {
 	$$cb->write("<html><head><title>$s</title></head><body>");
 }
 
+sub __thread_entry {
+	my ($cb, $git, $state, $mime, $level) = @_;
+
+	# lazy load the full message from mini_mime:
+	my $path = mid2path(mid_clean($mime->header('Message-ID')));
+	$mime = eval { Email::MIME->new($git->cat_file("HEAD:$path")) };
+	if ($mime) {
+		if ($state->{anchor_idx} == 0) {
+			thread_html_head($cb, $mime);
+		}
+		index_entry($$cb, $mime, $level, $state);
+	}
+}
+
 sub thread_entry {
 	my ($cb, $git, $state, $node, $level) = @_;
 	return unless $node;
 	if (my $mime = $node->message) {
-
-		# lazy load the full message from mini_mime:
-		my $path = mid2path(mid_clean($mime->header('Message-ID')));
-		$mime = eval { Email::MIME->new($git->cat_file("HEAD:$path")) };
-		if ($mime) {
-			if ($state->{anchor_idx} == 0) {
-				thread_html_head($cb, $mime);
-			}
-			index_entry($$cb, $mime, $level, $state);
-		}
+		__thread_entry($cb, $git, $state, $mime, $level);
 	}
 	thread_entry($cb, $git, $state, $node->child, $level + 1);
 	thread_entry($cb, $git, $state, $node->next, $level);
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index d666a1b..9ae7f7b 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -46,6 +46,9 @@ sub run {
 		invalid_list_mid(\%ctx, $1, $2) || get_thread_mbox(\%ctx, $sfx);
 	} elsif ($path_info =~ m!$LISTNAME_RE/$MID_RE/t\.atom\z!o) {
 		invalid_list_mid(\%ctx, $1, $2) || get_thread_atom(\%ctx);
+	} elsif ($path_info =~ m!$LISTNAME_RE/$MID_RE/T/\z!o) {
+		$ctx{flat} = 1;
+		invalid_list_mid(\%ctx, $1, $2) || get_thread(\%ctx);
 
 	# single-message pages
 	} elsif ($path_info =~ m!$LISTNAME_RE/$MID_RE/\z!o) {
-- 
EW


^ permalink raw reply related	[relevance 5%]

* [PATCH 0/7] improved thread views and 404 reductions
@ 2015-09-02  6:59  7% Eric Wong
  2015-09-02  6:59  5% ` [PATCH 2/7] view: optional flat view for recent messages 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 7%]

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  7% [PATCH 0/7] improved thread views and 404 reductions Eric Wong
2015-09-02  6:59  5% ` [PATCH 2/7] view: optional flat view for recent messages 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).