summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1e7fe3d)
Aallow navigating backwards and forwards, as some pages will be
bookmarked or some browsers may not have history. Also add a
link back to the index where they presumably came from.
While we're at it, limit the number of results we have to 25
for now to avoid making the page too big and wasting clients
memory for irrelevant results.
use PublicInbox::Hval;
use PublicInbox::View;
use POSIX qw/strftime/;
use PublicInbox::Hval;
use PublicInbox::View;
use POSIX qw/strftime/;
sub sres_top_html {
my ($ctx, $q) = @_;
sub sres_top_html {
my ($ctx, $q) = @_;
my $o = int($cgi->param('o') || 0);
my $r = $cgi->param('r');
$r = (defined $r && $r ne '0');
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);
my $mset = $ctx->{srch}->query($q, $opts);
my $total = $mset->get_matches_estimated;
my $query = PublicInbox::Hval->new_oneline($q);
$res .= qq{<input\ntype=submit\nvalue=search /></form>} .
PublicInbox::View::PRE_WRAP;
$res .= qq{<input\ntype=submit\nvalue=search /></form>} .
PublicInbox::View::PRE_WRAP;
- my $foot = $ctx->{footer};
+ my $foot = $ctx->{footer} || '';
+ $foot = qq{Back to <a\nhref=".">index</a>.};
$res .= "\n\n[No results found]</pre><hr /><pre>$foot";
} else {
$q = $query->as_href;
$res .= "\n\n[No results found]</pre><hr /><pre>$foot";
} else {
$q = $query->as_href;
my $end = $o + $nr;
my $beg = $o + 1;
$res .= "<hr /><pre>";
my $end = $o + $nr;
my $beg = $o + 1;
$res .= "<hr /><pre>";
- $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{, <a\nhref="?$qp">next</a>}
+ }
+ if ($o > 0) {
+ $res .= $n < $total ? '/' : ', ';
+ my $p = $o - $LIM;
+ $qp = "q=$q";
+ $qp .= "&o=$p" if $p > 0;
- $res .= qq{ <a\nhref="?$qp">more</a>}
+ $res .= qq{<a\nhref="?$qp">prev</a>};
- $res .= "\n\n".$foot if $foot;
}
$res .= "</pre></body></html>";
}
$res .= "</pre></body></html>";