11 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
12 |
use SWISH::API; |
use SWISH::API; |
13 |
use JSON; |
use JSON; |
14 |
|
use Text::Unaccent::PurePerl qw/unac_string/; |
15 |
|
|
16 |
my $range_around = 5; |
my $range_around = 5; |
17 |
my $entries_per_page = 30; |
my @entries_per_page = ( 30, 50, 100, 500 ); |
18 |
my $debug = param('debug'); |
my $debug = param('debug'); |
19 |
|
|
20 |
print header( |
print header( |
137 |
|
|
138 |
foreach ( @{ $db->{input} } ) { |
foreach ( @{ $db->{input} } ) { |
139 |
my $input = $_->{name} || die "no name in ",dump( $_ ); |
my $input = $_->{name} || die "no name in ",dump( $_ ); |
140 |
|
next unless defined $stats->{input}->{$input}; # skip inputs without data |
141 |
if ( ! $only_input->{'-labels'}->{$input} ) { |
if ( ! $only_input->{'-labels'}->{$input} ) { |
142 |
push @{ $only_input->{'-values'} }, $input; |
push @{ $only_input->{'-values'} }, $input; |
143 |
$only_input->{'-labels'}->{$input} = $_->{description} || $input; |
$only_input->{'-labels'}->{$input} = $_->{description} || $input; |
161 |
), |
), |
162 |
textfield( -name => 'search' ), |
textfield( -name => 'search' ), |
163 |
$attr_operators ? popup_menu( -name => 'attr_operator', %$attr_operators ) : '', |
$attr_operators ? popup_menu( -name => 'attr_operator', %$attr_operators ) : '', |
164 |
submit, |
submit( -value => 'Search' ), |
165 |
hidden( -name => 'entries_per_page', -default => $entries_per_page ), |
# hidden( -name => 'entries_per_page', -default => $entries_per_page ), |
166 |
|
popup_menu( -name => 'entries_per_page', -values => [ @entries_per_page ], -title => 'entries per page' ), |
167 |
# we need current_page fixed at 1 so that every submit through form will reset it |
# we need current_page fixed at 1 so that every submit through form will reset it |
168 |
qq|<input type=hidden name=current_page value=1 >|, |
qq|<input type=hidden name=current_page value=1 >|, |
169 |
checkbox( -name => 'debug', -default => 0 ), # FIXME hidden? |
checkbox( -name => 'debug', -default => 0 ), # FIXME hidden? |
192 |
|
|
193 |
if ( my $search = param('search') ) { |
if ( my $search = param('search') ) { |
194 |
|
|
195 |
|
$search = unac_string( $search ); |
196 |
|
|
197 |
print qq| |
print qq| |
198 |
<a href="#form" class="skip" title="skip to search form">#</a> |
<a href="#form" class="skip" title="skip to search form">#</a> |
199 |
<div id="results"> |
<div id="results"> |
285 |
|
|
286 |
while ( my $result = $swish_results->next_result ) { |
while ( my $result = $swish_results->next_result ) { |
287 |
|
|
288 |
my $data = from_json $result->property('data'); |
my $data = $result->property('data'); |
|
|
|
289 |
dump_yaml( 'data', $data ); |
dump_yaml( 'data', $data ); |
290 |
|
# FIXME if we produce valid json we shouldn't need eval here! |
291 |
|
eval { $data = from_json( $data, {utf8 => 1} ); }; |
292 |
|
if ( $@ ) { |
293 |
|
warn "ERROR: $@ from ",dump( $data ); |
294 |
|
next; |
295 |
|
} |
296 |
|
|
297 |
my $li_class = ''; |
my $li_class = ''; |
298 |
$li_class = qq| class="z"| if $nr % 2 == 0; |
$li_class = qq| class="z"| if $nr % 2 == 0; |