X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FSearchView.pm;h=7ef6b075bf60a5b18080f43dafc6380b407258c9;hb=6e6f7999361925e4c944f308df4bc32a1842cd69;hp=c78979582432d97856a9d5690d7a98c90646732d;hpb=11707dae97d1f4638157cfee298464b2f2deeed4;p=public-inbox.git diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm index c7897958..7ef6b075 100644 --- a/lib/PublicInbox/SearchView.pm +++ b/lib/PublicInbox/SearchView.pm @@ -22,6 +22,7 @@ sub mbox_results { my ($ctx) = @_; my $q = PublicInbox::SearchQuery->new($ctx->{qp}); my $x = $q->{x}; + require PublicInbox::Mbox; return PublicInbox::Mbox::mbox_all($ctx, $q->{'q'}) if $x eq 'm'; sres_top_html($ctx); } @@ -35,7 +36,7 @@ sub sres_top_html { my $code = 200; # double the limit for expanded views: my $opts = { - limit => $LIM, + limit => $q->{l}, offset => $q->{o}, mset => 1, relevance => $q->{r}, @@ -180,9 +181,9 @@ sub search_nav_top { sub search_nav_bot { my ($mset, $q) = @_; my $total = $mset->get_matches_estimated; - my $nr = scalar $mset->items; my $o = $q->{o}; - my $end = $o + $nr; + my $l = $q->{l}; + my $end = $o + $mset->size; my $beg = $o + 1; my $rv = '
'; if ($beg <= $end) { @@ -191,15 +192,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}; } @@ -230,7 +231,7 @@ sub mset_thread { $r ? sort_relevance(\%pct) : *PublicInbox::View::sort_ds, $ctx); my $skel = search_nav_bot($mset, $q). ""; - my $inbox = $ctx->{-inbox}; + my $ibx = $ctx->{-inbox}; $ctx->{-upfx} = ''; $ctx->{anchor_idx} = 1; $ctx->{cur_level} = 0; @@ -239,7 +240,6 @@ sub mset_thread { $ctx->{pct} = \%pct; $ctx->{prev_attr} = ''; $ctx->{prev_level} = 0; - $ctx->{seen} = {}; $ctx->{s_nr} = scalar(@$msgs).'+ results'; # reduce hash lookups in skel_dump @@ -252,7 +252,7 @@ sub mset_thread { return unless $msgs; my $smsg; while (my $m = pop @$msgs) { - $smsg = $inbox->smsg_mime($m) and last; + $smsg = $ibx->smsg_mime($m) and last; } if ($smsg) { return PublicInbox::View::index_entry($smsg, $ctx, @@ -306,10 +306,13 @@ 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; } @@ -332,6 +335,9 @@ sub qs_html { 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"; }