lib/PublicInbox/Thread.pm | 7 ------- lib/PublicInbox/View.pm | 46 +++++++++++++--------------------------------- lib/PublicInbox/WWW.pm | 18 ------------------ diff --git a/lib/PublicInbox/Thread.pm b/lib/PublicInbox/Thread.pm index 92404faa258c593d82720f0904db8d32e1a047cb..a3dedf541cb592a0e23182ac5c7dbd91736d49ca 100644 --- a/lib/PublicInbox/Thread.pm +++ b/lib/PublicInbox/Thread.pm @@ -24,13 +24,6 @@ (eval { $b->topmost->message->header('X-PI-TS') } || 0) } @_; } -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 17af21f741b3bb07d057f1d6fec32369a1cdae72..e29922ef9e37747a9dd4ee8e56f98fab664967ff 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -153,10 +153,7 @@ 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 $th = thread_results($msgs); my $state = [ $srch, { root_anchor => anchor_for($mid) }, undef, 0 ]; { require PublicInbox::GitCatFile; @@ -172,30 +169,6 @@ } else { $next .= 'end of thread'; } $next .= ", back to index\n"; - - $rv .= "
" . PRE_WRAP . $next . $foot . ""; -} - -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 = "end of thread\n"; $rv .= "
" . PRE_WRAP . $next . $foot . ""; } @@ -560,12 +533,10 @@ } 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); @@ -616,6 +587,15 @@ sub msg_timestamp { my ($mime) = @_; my $ts = eval { str2time($mime->header('Date')) }; 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 e7c28d74c66cca3d48ab6b89d824280bc579a28a..b0c1348659b154127d8ea6efc0189f27ffed8ec2 100644 --- a/lib/PublicInbox/WWW.pm +++ b/lib/PublicInbox/WWW.pm @@ -53,11 +53,6 @@ # thread display } 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); @@ -197,19 +192,6 @@ my $srch = searcher($ctx) or return need_search($ctx); require PublicInbox::View; my $foot = footer($ctx); my $body = PublicInbox::View->thread_html($ctx, $foot, $srch) or - return r404(); - [ 200, [ 'Content-Type' => 'text/html; charset=UTF-8' ], - [ $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 ] ];