From: Jonathan Corbet <corbet@lwn.net>
To: meta@public-inbox.org
Subject: [PATCH] Allow specification of the number of search results to return
Date: Mon, 26 Mar 2018 16:34:31 -0600 [thread overview]
Message-ID: <20180326163431.03fe26bc@lwn.net> (raw)
Add an "l=" parameter to the search query syntax to specify how many
results should be returned. The default remains 200.
---
200 is a lot of results for one page, so allow it to be tweaked. I've not
added anything to the query form to access this (don't need it) but could.
lib/PublicInbox/SearchView.pm | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm
index 53b88c3..1ac72b2 100644
--- a/lib/PublicInbox/SearchView.pm
+++ b/lib/PublicInbox/SearchView.pm
@@ -35,7 +35,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},
@@ -182,6 +182,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 = '</pre><hr><pre id=t>';
@@ -191,7 +192,7 @@ 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);
@@ -199,7 +200,7 @@ sub search_nav_bot {
}
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>};
}
@@ -312,6 +313,7 @@ sub new {
q => $qp->{'q'},
x => $qp->{x} || '',
o => (($qp->{o} || '0') =~ /(\d+)/),
+ l => (($qp->{l} || '200') =~ /(\d+)/),
r => (defined $r && $r ne '0'),
}, $class;
}
@@ -334,6 +336,9 @@ sub qs_html {
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";
}
--
2.14.3
next reply other threads:[~2018-03-26 22:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-26 22:34 Jonathan Corbet [this message]
2018-03-27 10:44 ` [PATCH] Allow specification of the number of search results to return Eric Wong
2018-03-28 21:00 ` Jonathan Corbet
2018-03-28 21:40 ` Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180326163431.03fe26bc@lwn.net \
--to=corbet@lwn.net \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).