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 {
my ($ctx) = @_;
- my $q = PublicInbox::SearchQuery->new($ctx->{cgi});
+ my $q = PublicInbox::SearchQuery->new($ctx->{qp});
my $code = 200;
# double the limit for expanded views:
} ($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,
$ctx->{searchview} = 1;
tdump_ent($git, $state, $_, 0) for @rootset;
PublicInbox::View::thread_adj_level($state, 0);
- Email::Address->purge_cache;
$fh->write(search_nav_bot($mset, $q). "\n\n" .
foot($ctx). '</pre></body></html>');
use PublicInbox::Hval;
sub new {
- my ($class, $cgi) = @_;
- my $r = $cgi->param('r');
+ my ($class, $qp) = @_;
+
+ my $r = $qp->{r};
bless {
- q => $cgi->param('q'),
- x => $cgi->param('x') || '',
- o => int($cgi->param('o') || 0) || 0,
+ q => $qp->{'q'},
+ x => $qp->{x} || '',
+ o => (($qp->{o} || '0') =~ /(\d+)/),
r => (defined $r && $r ne '0'),
}, $class;
}