/[webpac2]/trunk/vhost/webpac2.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/vhost/webpac2.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1227 by dpavlin, Thu Jun 11 18:55:53 2009 UTC revision 1241 by dpavlin, Sun Jul 12 17:42:27 2009 UTC
# Line 13  use SWISH::API; Line 13  use SWISH::API;
13  use JSON;  use JSON;
14    
15  my $range_around = 5;  my $range_around = 5;
16  my $entries_per_page = 30;  my @entries_per_page = ( 30, 50, 100, 500 );
17  my $debug = param('debug');  my $debug = param('debug');
18    
19  print header(  print header(
# Line 125  sub read_config_txt { Line 125  sub read_config_txt {
125  my $attr_labels    = read_config_txt 'labels';  my $attr_labels    = read_config_txt 'labels';
126  my $attr_operators = read_config_txt 'operators';  my $attr_operators = read_config_txt 'operators';
127    
128  my @attr = @{ $attr_labels->{'-values'} };  my @attr = @{ $attr_labels->{'-values'} } if $attr_labels;
129  @attr = keys %{ $stats->{attr} } unless @attr;  @attr = keys %{ $stats->{attr} } unless @attr;
130    
131    
132  warn dump( $attr_labels, $attr_operators );  warn dump( $attr_labels, $attr_operators );
133    
134  my $only_input;  my $only_input;
135    my $inputs_available = 0;
136    
137  foreach ( @{ $db->{input} } ) {  foreach ( @{ $db->{input} } ) {
138          my $input = $_->{name} || die "no name in ",dump( $_ );          my $input = $_->{name} || die "no name in ",dump( $_ );
139          if ( ! $only_input->{'-labels'}->{$input} ) {          if ( ! $only_input->{'-labels'}->{$input} ) {
140                  push @{ $only_input->{'-values'} }, $input;                  push @{ $only_input->{'-values'} }, $input;
141                          $only_input->{'-labels'}->{$input} = $_->{description} || $input;                          $only_input->{'-labels'}->{$input} = $_->{description} || $input;
142                    $inputs_available++;
143          }          }
144  }  }
145    
# Line 157  sub search_form { Line 159  sub search_form {
159                  ),                  ),
160                  textfield( -name => 'search' ),                  textfield( -name => 'search' ),
161                  $attr_operators ? popup_menu( -name => 'attr_operator', %$attr_operators ) : '',                  $attr_operators ? popup_menu( -name => 'attr_operator', %$attr_operators ) : '',
162                  submit,                  submit( -value => 'Search' ),
163                  hidden( -name => 'entries_per_page', -default => $entries_per_page ),  #               hidden( -name => 'entries_per_page', -default => $entries_per_page ),
164                    popup_menu( -name => 'entries_per_page', -values => [ @entries_per_page ], -title => 'entries per page' ),
165                  # 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
166                  qq|<input type=hidden name=current_page value=1 >|,                  qq|<input type=hidden name=current_page value=1 >|,
167                  checkbox( -name => 'debug', -default => 0 ), # FIXME hidden?                  checkbox( -name => 'debug', -default => 0 ), # FIXME hidden?
168                  qq|<div id=inputs>|,                  qq|<div id=inputs>|,
169                  h2( 'Select input' ),                  $inputs_available > 1 ?
170                    h2( 'Select input' ) .
171                  checkbox_group(                  checkbox_group(
172                          -name => 'only_input',                          -name => 'only_input',
173                          %$only_input,                          %$only_input,
174                          -linebreak=> 'true',                          -linebreak=> 'true',
175                  ),                  ) : '',
176                  qq|</div>|,                  qq|</div>|,
177                  end_form,                  end_form,
178          ;          ;
# Line 277  if ( my $search = param('search') ) { Line 281  if ( my $search = param('search') ) {
281    
282                  while ( my $result = $swish_results->next_result ) {                  while ( my $result = $swish_results->next_result ) {
283    
284                          my $data = from_json $result->property('data');                          my $data = from_json( $result->property('data'), {utf8 => 1} );
285    
286                          dump_yaml( 'data', $data );                          dump_yaml( 'data', $data );
287    
# Line 288  if ( my $search = param('search') ) { Line 292  if ( my $search = param('search') ) {
292                                  next unless defined $data->{$attr};                                  next unless defined $data->{$attr};
293                                  my $v = $data->{$attr};                                  my $v = $data->{$attr};
294                                  if ( $html_markup && ! $html_markup_skip->{$attr} ) {                                  if ( $html_markup && ! $html_markup_skip->{$attr} ) {
295                                          eval "\$v = $html_markup->$attr( \$v );";                                          eval "\$v = $html_markup->$attr( \$v, \$data );";
296                                          if ( $@ ) {                                          if ( $@ ) {
297                                                  warn "disable html markup for $attr: $@";                                                  warn "disable html markup for $attr: $@";
298                                                  $html_markup_skip->{$attr} = $@;                                                  $html_markup_skip->{$attr} = $@;

Legend:
Removed from v.1227  
changed lines
  Added in v.1241

  ViewVC Help
Powered by ViewVC 1.1.26