says the value isn't
- # very meaningful, anyways.
- my $n = $_[0]->get_percent;
- $n > 99 ? 99 : $n;
-}
-
-sub load_msgs {
- my ($mset) = @_;
- [ map {
- my $mi = $_;
- my $smsg = PublicInbox::Smsg::from_mitem($mi);
- $smsg->{pct} = get_pct($mi);
- $smsg;
- } ($mset->items) ]
+ } @{$_[0]};
}
sub mset_thread {
my ($ctx, $mset, $q) = @_;
- my $ibx = $ctx->{-inbox};
- my $msgs = $ibx->search->retry_reopen(\&load_msgs, $mset);
+ my $ibx = $ctx->{ibx};
+ my @pct = map { get_pct($_) } $mset->items;
+ my $msgs = $ibx->isrch->mset_to_smsg($ibx, $mset);
+ my $i = 0;
+ $_->{pct} = $pct[$i++] for @$msgs;
my $r = $q->{r};
+ if ($r) { # for descriptions in search_nav_bot
+ $q->{-min_pct} = min(@pct);
+ $q->{-max_pct} = max(@pct);
+ }
my $rootset = PublicInbox::SearchThread::thread($msgs,
$r ? \&sort_relevance : \&PublicInbox::View::sort_ds,
$ctx);
- my $skel = search_nav_bot($mset, $q). "";
+ my $skel = search_nav_bot($mset, $q).
+ "-- links below jump to the message on this page --\n";
+
$ctx->{-upfx} = '';
$ctx->{anchor_idx} = 1;
$ctx->{cur_level} = 0;
@@ -285,18 +319,22 @@ sub mset_thread {
PublicInbox::View::walk_thread($rootset, $ctx,
\&PublicInbox::View::pre_thread);
+ # link $INBOX_DIR/description text to "recent" view around
+ # the newest message in this result set:
+ $ctx->{-t_max} = max(map { delete $_->{ts} } @$msgs);
+
@$msgs = reverse @$msgs if $r;
$ctx->{msgs} = $msgs;
- PublicInbox::WwwStream::aresponse($ctx, 200, \&mset_thread_i);
+ PublicInbox::WwwStream::aresponse($ctx, \&mset_thread_i);
}
# callback for PublicInbox::WwwStream::getline
sub mset_thread_i {
my ($ctx, $eml) = @_;
- $ctx->zmore($ctx->html_top) if exists $ctx->{-html_tip};
+ print { $ctx->zfh } $ctx->html_top if exists $ctx->{-html_tip};
$eml and return PublicInbox::View::eml_entry($ctx, $eml);
my $smsg = shift @{$ctx->{msgs}} or
- $ctx->zmore(${delete($ctx->{skel})});
+ print { $ctx->zfh } ${delete($ctx->{skel})};
$smsg;
}
@@ -319,68 +357,18 @@ sub ctx_prepare {
sub adump {
my ($cb, $mset, $q, $ctx) = @_;
- $ctx->{items} = [ $mset->items ];
+ $ctx->{ids} = $ctx->{ibx}->isrch->mset_to_artnums($mset);
$ctx->{search_query} = $q; # used by WwwAtomStream::atom_header
- PublicInbox::WwwAtomStream->response($ctx, 200, \&adump_i);
+ PublicInbox::WwwAtomStream->response($ctx, \&adump_i);
}
# callback for PublicInbox::WwwAtomStream::getline
sub adump_i {
my ($ctx) = @_;
- while (my $mi = shift @{$ctx->{items}}) {
- my $srch = $ctx->{-inbox}->search(undef, $ctx) or return;
- my $smsg = eval {
- PublicInbox::Smsg::from_mitem($mi, $srch);
- } or next;
+ while (my $num = shift @{$ctx->{ids}}) {
+ my $smsg = eval { $ctx->{ibx}->over->get_art($num) } or next;
return $smsg;
}
}
-package PublicInbox::SearchQuery;
-use strict;
-use warnings;
-use URI::Escape qw(uri_escape);
-use PublicInbox::MID qw(MID_ESC);
-
-sub new {
- my ($class, $qp) = @_;
-
- my $r = $qp->{r};
- my ($l) = (($qp->{l} || '') =~ /([0-9]+)/);
- $l = $LIM if !$l || $l > $LIM;
- bless {
- q => $qp->{'q'},
- x => $qp->{x} || '',
- o => (($qp->{o} || '0') =~ /(-?[0-9]+)/),
- l => $l,
- r => (defined $r && $r ne '0'),
- }, $class;
-}
-
-sub qs_html {
- my ($self, %override) = @_;
-
- if (scalar(keys(%override))) {
- $self = bless { (%$self, %override) }, ref($self);
- }
-
- my $q = uri_escape($self->{'q'}, MID_ESC);
- $q =~ s/%20/+/g; # improve URL readability
- my $qs = "q=$q";
-
- if (my $o = $self->{o}) { # ignore o == 0
- $qs .= "&o=$o";
- }
- if (my $l = $self->{l}) {
- $qs .= "&l=$l" unless $l == $LIM;
- }
- if (my $r = $self->{r}) {
- $qs .= "&r";
- }
- if (my $x = $self->{x}) {
- $qs .= "&x=$x" if ($x eq 't' || $x eq 'A' || $x eq 'm');
- }
- $qs;
-}
-
1;