";
} else {
return adump($_[0], $mset, $q, $ctx) if $x eq 'A';
$ctx->{-html_tip} = search_nav_top($mset, $q, $ctx);
- if ($x eq 't') {
- $cb = mset_thread($ctx, $mset, $q);
- } else {
- $cb = mset_summary($ctx, $mset, $q);
- }
+ return mset_thread($ctx, $mset, $q) if $x eq 't';
+ mset_summary($ctx, $mset, $q); # appends to {-html_tip}
+ $html = '';
}
- PublicInbox::WwwStream->response($ctx, $code, $cb);
+ html_oneshot($ctx, $code, $html);
}
# display non-nested search results similar to what users expect from
@@ -94,35 +94,48 @@ sub mset_summary {
my $pad = length("$total");
my $pfx = ' ' x $pad;
my $res = \($ctx->{-html_tip});
- my $ibx = $ctx->{-inbox};
- my $srch = $ibx->search;
+ my $ibx = $ctx->{ibx};
my $obfs_ibx = $ibx->{obfuscate} ? $ibx : undef;
+ my @nums = @{$ibx->isrch->mset_to_artnums($mset)};
+ my %num2msg = map { $_->{num} => $_ } @{$ibx->over->get_all(@nums)};
+ my ($min, $max, %seen);
+
foreach my $m ($mset->items) {
+ my $num = shift @nums;
+ my $smsg = delete($num2msg{$num}) // do {
+ warn "$m $num expired\n";
+ next;
+ };
+ my $mid = $smsg->{mid};
+ next if $seen{$mid}++;
+ $mid = mid_href($mid);
+ $ctx->{-t_max} //= $smsg->{ts};
my $rank = sprintf("%${pad}d", $m->get_rank + 1);
my $pct = get_pct($m);
- my $smsg = PublicInbox::SearchMsg::from_mitem($m, $srch);
- unless ($smsg) {
- eval {
- $m = "$m ".$m->get_docid . " expired\n";
- $ctx->{env}->{'psgi.errors'}->print($m);
- };
- next;
- }
- my $s = ascii_html($smsg->subject);
- my $f = ascii_html($smsg->from_name);
+
+ # only when sorting by relevance, ->items is always
+ # ordered descending:
+ $max //= $pct;
+ $min = $pct;
+
+ my $s = ascii_html($smsg->{subject});
+ my $f = ascii_html(delete $smsg->{from_name});
if ($obfs_ibx) {
obfuscate_addrs($obfs_ibx, $s);
obfuscate_addrs($obfs_ibx, $f);
}
- my $date = PublicInbox::View::fmt_ts($smsg->ds);
- my $mid = PublicInbox::Hval->new_msgid($smsg->mid)->{href};
+ my $date = fmt_ts($smsg->{ds});
$s = '(no subject)' if $s eq '';
$$res .= qq{$rank. }.
$s . "\n";
$$res .= "$pfx - by $f @ $date UTC [$pct%]\n\n";
}
- $$res .= search_nav_bot($mset, $q);
- *noop;
+ if ($q->{r}) { # for descriptions in search_nav_bot
+ $q->{-min_pct} = $min;
+ $q->{-max_pct} = $max;
+ }
+ $$res .= search_nav_bot($ctx, $mset, $q);
+ undef;
}
# shorten "/full/path/to/Foo/Bar.pm" to "Foo/Bar.pm" so error
@@ -143,7 +156,7 @@ sub path2inc ($) {
sub err_txt {
my ($ctx, $err) = @_;
- my $u = $ctx->{-inbox}->base_url($ctx->{env}) . '_/text/help/';
+ my $u = $ctx->{ibx}->base_url($ctx->{env}) . '_/text/help/';
$err =~ s/^\s*Exception:\s*//; # bad word to show users :P
$err =~ s!(\S+)!path2inc($1)!sge;
$err = ascii_html($err);
@@ -153,8 +166,8 @@ sub err_txt {
sub search_nav_top {
my ($mset, $q, $ctx) = @_;
- my $m = $q->qs_html(x => 'm', r => undef);
- my $rv = qq{
};
+ $rv .= qq{|Atom feed]\n};
+ $rv .= <{t};
+*** "t=1" collapses threads in summary, "full threads" requires mbox.gz ***
+EOM
+ $rv .= <{ibx}->isrch->has_threadid) {
+ $rv .= qq{${pfx}download mbox.gz: } .
+ # we set name=z w/o using it since it seems required for
+ # lynx (but works fine for w3m).
+ qq{} .
+ qq{|};
+ } else { # BOFH needs to --reindex
+ $rv .= qq{${pfx}download: } .
+ qq{}
+ }
+ $rv .= qq{
};
}
-sub search_nav_bot {
- my ($mset, $q) = @_;
+sub search_nav_bot { # also used by WwwListing for searching extindex miscidx
+ my ($ctx, $mset, $q) = @_;
my $total = $mset->get_matches_estimated;
my $l = $q->{l};
my $rv = '