lib/PublicInbox/SearchView.pm | 28 +++++++++++++++++++--------- diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm index 6113bbf19e7cdfef8e28f84f177b9d94889e121a..4d49d250a275cf25c42adc614423300386f63f63 100644 --- a/lib/PublicInbox/SearchView.pm +++ b/lib/PublicInbox/SearchView.pm @@ -7,6 +7,7 @@ use PublicInbox::SearchMsg; use PublicInbox::Hval; use PublicInbox::View; use POSIX qw/strftime/; +our $LIM = 25; sub sres_top_html { my ($ctx, $q) = @_; @@ -15,7 +16,7 @@ # $q ||= $cgi->param('q'); my $o = int($cgi->param('o') || 0); my $r = $cgi->param('r'); $r = (defined $r && $r ne '0'); - my $opts = { offset => $o, mset => 1, relevance => $r }; + my $opts = { limit => $LIM, offset => $o, mset => 1, relevance => $r }; my $mset = $ctx->{srch}->query($q, $opts); my $total = $mset->get_matches_estimated; my $query = PublicInbox::Hval->new_oneline($q); @@ -29,9 +30,9 @@ $res .= qq{} . PublicInbox::View::PRE_WRAP; - my $foot = $ctx->{footer}; + my $foot = $ctx->{footer} || ''; + $foot = qq{Back to index.}; if ($total == 0) { - $foot ||= ''; $res .= "\n\n[No results found]
$foot";
} else {
$q = $query->as_href;
@@ -69,14 +70,23 @@ my $nr = scalar $mset->items;
my $end = $o + $nr;
my $beg = $o + 1;
$res .= "
";
- $res .= "Results $beg-$end of $total.";
- if ($nr < $total) {
- $o = $o + $nr;
- $qp = "q=$q&o=$o";
+ $res .= "Results $beg-$end of $total";
+
+ my $n = $o + $LIM;
+ if ($n < $total) {
+ $qp = "q=$q&o=$n";
$qp .= "&r" if $r;
- $res .= qq{ more}
+ $res .= qq{, next}
}
- $res .= "\n\n".$foot if $foot;
+ if ($o > 0) {
+ $res .= $n < $total ? '/' : ', ';
+ my $p = $o - $LIM;
+ $qp = "q=$q";
+ $qp .= "&o=$p" if $p > 0;
+ $qp .= "&r" if $r;
+ $res .= qq{prev};
+ }
+ $res .= "\n\n".$foot;
}
$res .= "