projects
/
webpac2
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
more fixes and cleanups for pager
[webpac2]
/
vhost
/
webpac2.cgi
diff --git
a/vhost/webpac2.cgi
b/vhost/webpac2.cgi
index
a5a5c92
..
8b9d844
100755
(executable)
--- a/
vhost/webpac2.cgi
+++ b/
vhost/webpac2.cgi
@@
-182,11
+182,6
@@
if ( my $search = param('search') ) {
my $swish = SWISH::API->new( "$dir/../var/swish/$database" );
$swish->abort_last_error if $swish->Error;
my $swish = SWISH::API->new( "$dir/../var/swish/$database" );
$swish->abort_last_error if $swish->Error;
- my $pager = Data::Page->new;
- $pager->$_( param($_) ) foreach ( qw/entries_per_page current_page/ );
-
- dump_yaml( 'pager', $pager );
-
my @search = ();
if ( $search =~ m{(=|"|AND|OR)} ) {
push @search, $search;
my @search = ();
if ( $search =~ m{(=|"|AND|OR)} ) {
push @search, $search;
@@
-224,9
+219,13
@@
if ( my $search = param('search') ) {
dump_yaml( 'swish_results', $swish_results );
dump_yaml( 'swish_results', $swish_results );
+ my $pager = Data::Page->new;
+ $pager->$_( param($_) ) foreach ( qw/entries_per_page current_page/ );
$pager->total_entries( $swish_results->hits );
$pager->total_entries( $swish_results->hits );
- $swish_results->seek_result( $pager->first );
+ dump_yaml( 'pager', $pager );
+
+ $swish_results->seek_result( $pager->first - 1 );
if ( ! $pager->total_entries ) {
my $no_results = 'No results for search <b>%s</b>';
if ( ! $pager->total_entries ) {
my $no_results = 'No results for search <b>%s</b>';
@@
-241,13
+240,12
@@
if ( my $search = param('search') ) {
print qq|<ul class="pager">$pager_html</ul>\n\n| if $pager_html;
print qq|<ul class="pager">$pager_html</ul>\n\n| if $pager_html;
- my $
start
= $pager->first;
- print qq|<ol start=$
start
>\n|;
+ my $
nr
= $pager->first;
+ print qq|<ol start=$
nr
>\n|;
my $limit = $pager->entries_on_this_page;
while ( my $result = $swish_results->next_result ) {
my $limit = $pager->entries_on_this_page;
while ( my $result = $swish_results->next_result ) {
- last if $limit-- == 0;
my $data = from_json $result->property('data');
my $data = from_json $result->property('data');
@@
-268,6
+266,8
@@
if ( my $search = param('search') ) {
print qq|<div><label>$label</label><span class=$attr>$v</span></div>\n|;
}
print qq|</li>\n|;
print qq|<div><label>$label</label><span class=$attr>$v</span></div>\n|;
}
print qq|</li>\n|;
+
+ last if $nr++ == $pager->last;
}
print qq|</ol>\n\n|;
}
print qq|</ol>\n\n|;