From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/4] dead code cleanup
Date: Thu, 20 Aug 2015 10:20:26 +0000 [thread overview]
Message-ID: <1440066029-7400-1-git-send-email-e@80x24.org> (raw)
We may not be using subject_path after all.
---
lib/PublicInbox/Thread.pm | 7 -------
lib/PublicInbox/View.pm | 46 +++++++++++++---------------------------------
lib/PublicInbox/WWW.pm | 18 ------------------
3 files changed, 13 insertions(+), 58 deletions(-)
diff --git a/lib/PublicInbox/Thread.pm b/lib/PublicInbox/Thread.pm
index 92404fa..a3dedf5 100644
--- a/lib/PublicInbox/Thread.pm
+++ b/lib/PublicInbox/Thread.pm
@@ -24,13 +24,6 @@ sub sort_ts {
} @_;
}
-sub rsort_ts {
- sort {
- (eval { $b->topmost->message->header('X-PI-TS') } || 0) <=>
- (eval { $a->topmost->message->header('X-PI-TS') } || 0)
- } @_;
-}
-
package PublicInbox::Thread::Container;
use strict;
use warnings;
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 17af21f..e29922e 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -153,10 +153,7 @@ sub thread_html {
my $msgs = load_results($res);
my $nr = scalar @$msgs;
return $rv if $nr == 0;
- require PublicInbox::Thread;
- my $th = PublicInbox::Thread->new(@$msgs);
- $th->thread;
- $th->order(*PublicInbox::Thread::sort_ts);
+ my $th = thread_results($msgs);
my $state = [ $srch, { root_anchor => anchor_for($mid) }, undef, 0 ];
{
require PublicInbox::GitCatFile;
@@ -176,30 +173,6 @@ sub thread_html {
$rv .= "<hr />" . PRE_WRAP . $next . $foot . "</pre>";
}
-sub subject_path_html {
- my (undef, $ctx, $foot, $srch) = @_;
- my $path = $ctx->{subject_path};
- my $res = $srch->get_subject_path($path);
- my $rv = '';
- my $msgs = load_results($res);
- my $nr = scalar @$msgs;
- return $rv if $nr == 0;
- require PublicInbox::Thread;
- my $th = PublicInbox::Thread->new(@$msgs);
- $th->thread;
- $th->order(*PublicInbox::Thread::sort_ts);
- my $state = [ $srch, { root_anchor => 'dummy' }, undef, 0 ];
- {
- require PublicInbox::GitCatFile;
- my $git = PublicInbox::GitCatFile->new($ctx->{git_dir});
- thread_entry(\$rv, $git, $state, $_, 0) for $th->rootset;
- }
- my $final_anchor = $state->[3];
- my $next = "<a\nid=\"s$final_anchor\">end of thread</a>\n";
-
- $rv .= "<hr />" . PRE_WRAP . $next . $foot . "</pre>";
-}
-
# only private functions below.
sub index_walk {
@@ -560,12 +533,10 @@ sub simple_dump {
sub thread_followups {
my ($dst, $root, $res) = @_;
- my $msgs = load_results($res);
- require PublicInbox::Thread;
$root->header_set('X-PI-TS', '0');
- my $th = PublicInbox::Thread->new($root, @$msgs);
- $th->thread;
- $th->order(*PublicInbox::Thread::sort_ts);
+ my $msgs = load_results($res);
+ push @$msgs, $root;
+ my $th = thread_results($msgs);
my $srch = $res->{srch};
my $subj = $srch->subject_path($root->header('Subject'));
my %seen = ($subj => 1);
@@ -618,4 +589,13 @@ sub msg_timestamp {
defined($ts) ? $ts : 0;
}
+sub thread_results {
+ my ($msgs) = @_;
+ require PublicInbox::Thread;
+ my $th = PublicInbox::Thread->new(@$msgs);
+ $th->thread;
+ $th->order(*PublicInbox::Thread::sort_ts);
+ $th
+}
+
1;
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index e7c28d7..b0c1348 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -53,11 +53,6 @@ sub run {
} elsif ($path_info =~ m!$LISTNAME_RE/t/(\S+)\.html\z!o) {
invalid_list_mid(\%ctx, $1, $2) || get_thread(\%ctx, $cgi);
- # subject_path display
- } elsif ($path_info =~ m!$LISTNAME_RE/s/(\S+)\.html\z!o) {
- my $sp = $2;
- invalid_list(\%ctx, $1) || get_subject_path(\%ctx, $cgi, $sp);
-
} elsif ($path_info =~ m!$LISTNAME_RE/f/\S+\.txt\z!o) {
invalid_list_mid(\%ctx, $1, $2) ||
redirect_mid_txt(\%ctx, $cgi);
@@ -202,19 +197,6 @@ sub get_thread {
[ $body ] ];
}
-# /$LISTNAME/s/$SUBJECT_PATH.html
-sub get_subject_path {
- my ($ctx, $cgi, $sp) = @_;
- $ctx->{subject_path} = $sp;
- my $srch = searcher($ctx) or return need_search($ctx);
- require PublicInbox::View;
- my $foot = footer($ctx);
- my $body = PublicInbox::View->subject_path_html($ctx, $foot, $srch) or
- return r404();
- [ 200, [ 'Content-Type' => 'text/html; charset=UTF-8' ],
- [ $body ] ];
-}
-
sub self_url {
my ($cgi) = @_;
ref($cgi) eq 'CGI' ? $cgi->self_url : $cgi->uri->as_string;
--
EW
next reply other threads:[~2015-08-20 10:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-20 10:20 Eric Wong [this message]
2015-08-20 10:20 ` [PATCH 2/4] view: simplify message threading dumpers Eric Wong
2015-08-20 10:20 ` [PATCH 3/4] avoid using header_raw for Message-ID retrieval Eric Wong
2015-08-20 10:20 ` [PATCH 4/4] search: preserve References: order in document data 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=1440066029-7400-1-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.
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).