about summary refs log tree commit homepage
path: root/lib/PublicInbox/SearchView.pm
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-18 20:58:35 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-18 20:58:35 +0000
commitcfb8d16578e7f2f2e300f9f436205e4a8fc7f322 (patch)
tree2b102728613d0019102dccb6d281ed9aaec03326 /lib/PublicInbox/SearchView.pm
parent1dc0f0c10fd856166a6726034de8aec53392901a (diff)
parent119463b3b8517e5ec149198bb83588999118ee1d (diff)
downloadpublic-inbox-cfb8d16578e7f2f2e300f9f436205e4a8fc7f322.tar.gz
* origin/master:
  nntp: allow and ignore empty commands
  mbox: do not barf on queries which return no results
  nntp: fix NEWNEWS command
  searchview: fix non-numeric comparison
  Allow specification of the number of search results to return
  githttpbackend: avoid infinite loop on generic PSGI servers
  http: fix modification of read-only value
  extmsg: use news.gmane.org for Message-ID lookups
  extmsg: rework partial MID matching to favor current inbox
  Update the installation instructions with Fedora package names
  nntp: do not drain rbuf if there is a command pending
  nntp: improve fairness during XOVER and similar commands
  searchidx: do not modify Xapian DB while iterating
  Don't use LIMIT in UPDATE statements
Diffstat (limited to 'lib/PublicInbox/SearchView.pm')
-rw-r--r--lib/PublicInbox/SearchView.pm16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm
index d038dfca..5d500c1b 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},
@@ -181,6 +182,7 @@ sub search_nav_bot {
         my ($mset, $q) = @_;
         my $total = $mset->get_matches_estimated;
         my $o = $q->{o};
+        my $l = $q->{l};
         my $end = $o + $mset->size;
         my $beg = $o + 1;
         my $rv = '</pre><hr><pre id=t>';
@@ -190,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{  <a\nhref="?$qs"\nrel=next>next</a>}
         }
         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{<a\nhref="?$qs"\nrel=prev>prev</a>};
         }
@@ -305,10 +307,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;
 }
@@ -331,6 +336,9 @@ sub qs_html {
         if (my $o = $self->{o}) { # ignore o == 0
                 $qs .= "&amp;o=$o";
         }
+        if (my $l = $self->{l}) {
+                $qs .= "&amp;l=$l";
+        }
         if (my $r = $self->{r}) {
                 $qs .= "&amp;r";
         }