}.
@@ -113,9 +138,22 @@ sub err_txt {
}
sub search_nav_top {
- my ($mset, $q) = @_;
+ my ($mset, $q, $ctx) = @_;
+ my $m = $q->qs_html(x => 'm', r => undef);
+ my $rv = qq{};
}
sub search_nav_bot {
@@ -143,6 +183,7 @@ sub search_nav_bot {
my $total = $mset->get_matches_estimated;
my $nr = scalar $mset->items;
my $o = $q->{o};
+ my $l = $q->{l};
my $end = $o + $nr;
my $beg = $o + 1;
my $rv = '
';
@@ -152,15 +193,15 @@ sub search_nav_bot {
} else {
$rv .= "No more results, only $total";
}
- my $n = $o + $LIM;
+ my $n = $o + $l;
if ($n < $total) {
- my $qs = $q->qs_html(o => $n);
+ my $qs = $q->qs_html(o => $n, l => $l);
$rv .= qq{ next}
}
if ($o > 0) {
$rv .= $n < $total ? '/' : ' ';
- my $p = $o - $LIM;
+ my $p = $o - $l;
my $qs = $q->qs_html(o => ($p > 0 ? $p : 0));
$rv .= qq{prev};
}
@@ -179,15 +220,17 @@ sub sort_relevance {
sub mset_thread {
my ($ctx, $mset, $q) = @_;
my %pct;
- my $msgs = $ctx->{srch}->retry_reopen(sub { [ map {
+ my $srch = $ctx->{srch};
+ my $msgs = $srch->retry_reopen(sub { [ map {
my $i = $_;
my $smsg = PublicInbox::SearchMsg->load_doc($i->get_document);
$pct{$smsg->mid} = $i->get_percent;
$smsg;
} ($mset->items) ]});
-
+ my $r = $q->{r};
my $rootset = PublicInbox::SearchThread::thread($msgs,
- $q->{r} ? sort_relevance(\%pct) : *PublicInbox::View::sort_ts);
+ $r ? sort_relevance(\%pct) : *PublicInbox::View::sort_ts,
+ $srch);
my $skel = search_nav_bot($mset, $q). "";
my $inbox = $ctx->{-inbox};
$ctx->{-upfx} = '';
@@ -201,13 +244,16 @@ sub mset_thread {
$ctx->{seen} = {};
$ctx->{s_nr} = scalar(@$msgs).'+ results';
+ # reduce hash lookups in skel_dump
+ $ctx->{-obfuscate} = $ctx->{-inbox}->{obfuscate};
PublicInbox::View::walk_thread($rootset, $ctx,
*PublicInbox::View::pre_thread);
+ @$msgs = reverse @$msgs if $r;
my $mime;
sub {
return unless $msgs;
- while ($mime = shift @$msgs) {
+ while ($mime = pop @$msgs) {
$mime = $inbox->msg_by_smsg($mime) and last;
}
if ($mime) {
@@ -222,7 +268,9 @@ sub mset_thread {
sub ctx_prepare {
my ($q, $ctx) = @_;
- my $qh = ascii_html($q->{'q'});
+ my $qh = $q->{'q'};
+ utf8::decode($qh);
+ $qh = ascii_html($qh);
$ctx->{-q_value_html} = $qh;
$ctx->{-atom} = '?'.$q->qs_html(x => 'A', r => undef);
$ctx->{-title_html} = "$qh - search results";
@@ -254,17 +302,21 @@ sub adump {
package PublicInbox::SearchQuery;
use strict;
use warnings;
+use URI::Escape qw(uri_escape);
use PublicInbox::Hval;
-use PublicInbox::MID qw(mid_escape);
+use PublicInbox::MID qw(MID_ESC);
sub new {
my ($class, $qp) = @_;
my $r = $qp->{r};
+ my ($l) = (($qp->{l} || '') =~ /(\d+)/);
+ $l = $LIM if !$l || $l > $LIM;
bless {
q => $qp->{'q'},
x => $qp->{x} || '',
o => (($qp->{o} || '0') =~ /(\d+)/),
+ l => $l,
r => (defined $r && $r ne '0'),
}, $class;
}
@@ -280,18 +332,21 @@ sub qs_html {
$self = $tmp;
}
- my $q = mid_escape($self->{'q'});
+ 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";
+ }
if (my $r = $self->{r}) {
$qs .= "&r";
}
if (my $x = $self->{x}) {
- $qs .= "&x=$x" if ($x eq 't' || $x eq 'A');
+ $qs .= "&x=$x" if ($x eq 't' || $x eq 'A' || $x eq 'm');
}
$qs;
}