projects
/
webpac
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added pager for lookup in index
[webpac]
/
WebPac.pm
diff --git
a/WebPac.pm
b/WebPac.pm
index
946fab1
..
5f3cfb5
100644
(file)
--- a/
WebPac.pm
+++ b/
WebPac.pm
@@
-171,28
+171,43
@@
sub show_index {
my $field = $q->param("f$i");
my $limit = $q->param("v$i");
my $field = $q->param("f$i");
my $limit = $q->param("v$i");
-
my $html;
my $index = new index_DBI();
my $html;
my $index = new index_DBI();
- if (! $index->check($field)) {
+ my $total = $index->check($field);
+ if (! $total) {
my $tmpl = $self->load_tmpl('no_index.html');
$tmpl->param('field',$field);
$html = $tmpl->output;
return $html;
}
my $tmpl = $self->load_tmpl('no_index.html');
$tmpl->param('field',$field);
$html = $tmpl->output;
return $html;
}
- my @index_arr = $index->fetch($field,'item',$limit);
+ my $tmpl = $self->load_tmpl('index_res.html');
+ $tmpl->param('field',$field);
+ $tmpl->param('limit',$limit);
+ $tmpl->param('total',$total);
- $html .= "show index of <i>$field</i>";
- $html .= " for <i>$limit</i>" if ($limit);
+ my $pager = HTML::Pager->new(
+ query => $q,
+ get_data_callback => sub {
+ my ($offset, $rows) = @_;
- while (my $row = shift @index_arr) {
- $html .= "<br>".$row->{item}."\n";
- }
+ my @result = $index->fetch($field,'item',$limit, $offset, $rows);
+ return \@result;
+ },
+ rows => $total,
+ page_size => $ON_PAGE,
+ persist_vars => [
+ 'rm',
+ "f$i", "v$i", "f".$i."_index",
+ 'offset',
+ ],
+ debug => 1,
+ template => $tmpl,
+ );
- return $
html
;
+ return $
pager->output
;
}
1;
}
1;