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/5] view: disable subject threading
  2016-05-02 18:01  7% [PATCH 0/5] miscellaneous minor changes Eric Wong
@ 2016-05-02 18:01  6% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2016-05-02 18:01 UTC (permalink / raw)
  To: meta

Broken threads should be exposed to hopefully encourage people to
use proper mail clients which set In-Reply-To headers.
---
 lib/PublicInbox/SearchView.pm | 17 +++++++----------
 lib/PublicInbox/Thread.pm     | 14 ++++++++++++++
 lib/PublicInbox/View.pm       | 16 +++-------------
 3 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm
index 41d3200..c0cd1ff 100644
--- a/lib/PublicInbox/SearchView.pm
+++ b/lib/PublicInbox/SearchView.pm
@@ -11,6 +11,7 @@ use PublicInbox::View;
 use PublicInbox::MID qw(mid2path mid_clean mid_mime);
 use Email::MIME;
 require PublicInbox::Git;
+require PublicInbox::Thread;
 our $LIM = 50;
 
 sub sres_top_html {
@@ -151,23 +152,19 @@ sub tdump {
 	} ($mset->items);
 
 	my @rootset;
-	my $th = PublicInbox::View::thread_results(\@m, 0, $q->{r});
-	if ($q->{r}) {
+	my $th = PublicInbox::Thread->new(@m);
+	$th->thread;
+	if ($q->{r}) { # order by relevance
 		$th->order(sub {
 			sort { (eval { $pct{$b->topmost->messageid} } || 0)
 					<=>
 				(eval { $pct{$a->topmost->messageid} } || 0)
 			} @_;
 		});
-		@rootset = $th->rootset;
-	} else {
-		@rootset = sort {
-			(eval { $b->topmost->message->header('X-PI-TS') } || 0)
-				<=>
-			(eval { $a->topmost->message->header('X-PI-TS') } || 0)
-		} $th->rootset;
+	} else { # order by time (default for threaded view)
+		$th->order(*PublicInbox::View::sort_ts);
 	}
-
+	@rootset = $th->rootset;
 	my $git = $ctx->{git} ||= PublicInbox::Git->new($ctx->{git_dir});
 	my $state = {
 		ctx => $ctx,
diff --git a/lib/PublicInbox/Thread.pm b/lib/PublicInbox/Thread.pm
index 781ffff..44a565a 100644
--- a/lib/PublicInbox/Thread.pm
+++ b/lib/PublicInbox/Thread.pm
@@ -12,6 +12,20 @@ package PublicInbox::Thread;
 use strict;
 use warnings;
 use base qw(Mail::Thread);
+# WARNING! both these Mail::Thread knobs were found by inspecting
+# the Mail::Thread 2.55 source code, and we have some monkey patches
+# in PublicInbox::Thread to fix memory leaks.  Since Mail::Thread
+# appears unmaintained, I suppose it's safe to depend on these
+# variables for now:
+{
+	no warnings 'once';
+	# we want strict threads to expose (and hopefully discourage)
+	# use of broken email clients
+	$Mail::Thread::nosubject = 1;
+	# Keep ghosts with only a single direct child,
+	# don't hide that there may be missing messages.
+	$Mail::Thread::noprune = 1;
+}
 
 if ($Mail::Thread::VERSION <= 2.55) {
 	eval q(sub _container_class { 'PublicInbox::Thread::Container' });
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 63810dc..70eb44e 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -670,21 +670,11 @@ sub msg_timestamp {
 }
 
 sub thread_results {
-	my ($msgs, $nosubject, $nosort) = @_;
+	my ($msgs) = @_;
 	require PublicInbox::Thread;
 	my $th = PublicInbox::Thread->new(@$msgs);
-
-	# WARNING! both these Mail::Thread knobs were found by inspecting
-	# the Mail::Thread 2.55 source code, and we have some monkey patches
-	# in PublicInbox::Thread to fix memory leaks.  Since Mail::Thread
-	# appears unmaintained, I suppose it's safe to depend on these
-	# variables for now:
-	no warnings 'once';
-	$Mail::Thread::nosubject = $nosubject;
-	# Keep ghosts with only a single direct child:
-	$Mail::Thread::noprune = 1;
 	$th->thread;
-	$th->order(*sort_ts) unless $nosort;
+	$th->order(*sort_ts);
 	$th
 }
 
@@ -879,7 +869,7 @@ sub emit_index_topics {
 		my $sres = $state->{srch}->query('', \%opts);
 		my $nr = scalar @{$sres->{msgs}} or last;
 
-		for (thread_results(load_results($sres), 1)->rootset) {
+		for (thread_results(load_results($sres))->rootset) {
 			add_topic($state, $_, 0);
 		}
 		$opts{offset} += $nr;

^ permalink raw reply related	[relevance 6%]

* [PATCH 0/5] miscellaneous minor changes
@ 2016-05-02 18:01  7% Eric Wong
  2016-05-02 18:01  6% ` [PATCH 2/5] view: disable subject threading Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2016-05-02 18:01 UTC (permalink / raw)
  To: meta

Subject threading is now disabled completely to hopefully
expose misuse (or broken) email clients.  NNTP messages
now include HTTP/HTTPS archive headers, and there's some
minor test improvements with more to come.

Eric Wong (5):
      http: remove needless binmode call
      view: disable subject threading
      nntp: append Archived-At and List-Archive headers
      t/nntpd.t: stop hard coding message :bytes into test
      t/*.t: reduce -mda calls

 lib/PublicInbox/HTTP.pm       |  1 -
 lib/PublicInbox/NNTP.pm       | 27 +++++++++++++++++++++++++--
 lib/PublicInbox/NNTPD.pm      |  3 ++-
 lib/PublicInbox/NewsGroup.pm  | 11 ++++++++++-
 lib/PublicInbox/SearchView.pm | 17 +++++++----------
 lib/PublicInbox/Thread.pm     | 14 ++++++++++++++
 lib/PublicInbox/View.pm       | 16 +++-------------
 t/cgi.t                       | 41 +++++++++++++++++------------------------
 t/httpd.t                     | 22 +++++++++-------------
 t/nntp.t                      | 34 ++++++++++++++++++++++++++++++++++
 t/nntpd.t                     | 31 ++++++++++++++-----------------
 t/plack.t                     | 43 +++++++++++++------------------------------
 12 files changed, 148 insertions(+), 112 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 --
2016-05-02 18:01  7% [PATCH 0/5] miscellaneous minor changes Eric Wong
2016-05-02 18:01  6% ` [PATCH 2/5] view: disable subject threading 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).