182 |
my $swish = SWISH::API->new( "$dir/../var/swish/$database" ); |
my $swish = SWISH::API->new( "$dir/../var/swish/$database" ); |
183 |
$swish->abort_last_error if $swish->Error; |
$swish->abort_last_error if $swish->Error; |
184 |
|
|
|
my $pager = Data::Page->new; |
|
|
$pager->$_( param($_) ) foreach ( qw/entries_per_page current_page/ ); |
|
|
|
|
|
dump_yaml( 'pager', $pager ); |
|
|
|
|
185 |
my @search = (); |
my @search = (); |
186 |
if ( $search =~ m{(=|"|AND|OR)} ) { |
if ( $search =~ m{(=|"|AND|OR)} ) { |
187 |
push @search, $search; |
push @search, $search; |
219 |
|
|
220 |
dump_yaml( 'swish_results', $swish_results ); |
dump_yaml( 'swish_results', $swish_results ); |
221 |
|
|
222 |
|
my $pager = Data::Page->new; |
223 |
|
$pager->$_( param($_) ) foreach ( qw/entries_per_page current_page/ ); |
224 |
$pager->total_entries( $swish_results->hits ); |
$pager->total_entries( $swish_results->hits ); |
225 |
|
|
226 |
$swish_results->seek_result( $pager->first ); |
dump_yaml( 'pager', $pager ); |
227 |
|
|
228 |
|
$swish_results->seek_result( $pager->first - 1 ); |
229 |
|
|
230 |
if ( ! $pager->total_entries ) { |
if ( ! $pager->total_entries ) { |
231 |
my $no_results = 'No results for search <b>%s</b>'; |
my $no_results = 'No results for search <b>%s</b>'; |
240 |
|
|
241 |
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; |
242 |
|
|
243 |
my $start = $pager->first; |
my $nr = $pager->first; |
244 |
print qq|<ol start=$start>\n|; |
print qq|<ol start=$nr>\n|; |
245 |
|
|
246 |
my $limit = $pager->entries_on_this_page; |
my $limit = $pager->entries_on_this_page; |
247 |
|
|
248 |
|
my $nr = 1; |
249 |
|
|
250 |
while ( my $result = $swish_results->next_result ) { |
while ( my $result = $swish_results->next_result ) { |
|
last if $limit-- == 0; |
|
251 |
|
|
252 |
my $data = from_json $result->property('data'); |
my $data = from_json $result->property('data'); |
253 |
|
|
254 |
dump_yaml( 'data', $data ); |
dump_yaml( 'data', $data ); |
255 |
|
|
256 |
print qq|<li>|; |
my $li_class = ''; |
257 |
|
$li_class = qq| class="z"| if $nr++ % 2 == 0; |
258 |
|
print qq|<li$li_class>|; |
259 |
foreach my $attr ( @attr ) { |
foreach my $attr ( @attr ) { |
260 |
next unless defined $data->{$attr}; |
next unless defined $data->{$attr}; |
261 |
my $v = $data->{$attr}; |
my $v = $data->{$attr}; |
270 |
print qq|<div><label>$label</label><span class=$attr>$v</span></div>\n|; |
print qq|<div><label>$label</label><span class=$attr>$v</span></div>\n|; |
271 |
} |
} |
272 |
print qq|</li>\n|; |
print qq|</li>\n|; |
273 |
|
|
274 |
|
last if $nr++ == $pager->last; |
275 |
} |
} |
276 |
print qq|</ol>\n\n|; |
print qq|</ol>\n\n|; |
277 |
|
|