X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=vhost%2Fwebpac2.cgi;h=82c52a9dbd5733b9113718eb18f27bafaf287265;hb=921bff74b889275112e0cfa64fcadad3aef46dac;hp=340e0db0311163b00655ea1b6b6e567c13d80067;hpb=8ff851d90183d9a3ca323d2bfd41ef4028bea2e7;p=webpac2 diff --git a/vhost/webpac2.cgi b/vhost/webpac2.cgi index 340e0db..82c52a9 100755 --- a/vhost/webpac2.cgi +++ b/vhost/webpac2.cgi @@ -93,11 +93,16 @@ if ( -e $html_markup ) { undef $html_markup; } -my $estraier = YAML::LoadFile( "$dir/../var/estraier/$database.yaml" ); +my $stats; +{ + my $path = "$dir/../var/swish/$database.yaml"; + $stats = YAML::LoadFile( $path ); + dump_yaml( "stats $path", $stats ); +} my $db = $config->{databases}->{$database}; -my @attr = keys %{ $estraier->{attr} }; # FIXME replace with real gnerated lookup +my @attr = keys %{ $stats->{attr} }; # FIXME replace with real gnerated lookup # XXX pipe delimit list! my $select_attr_operators = << '__ATTR_OPERATORS__'; @@ -116,6 +121,18 @@ foreach ( split(/[\n\r]+/, $select_attr_operators ) ) { warn "## attr_operator = ", dump( $attr_operator ); +my $only_input; + +foreach ( @{ $db->{input} } ) { + my $input = $_->{name} || die "no name in ",dump( $_ ); + if ( ! $only_input->{'-labels'}->{$input} ) { + push @{ $only_input->{'-values'} }, $input; + $only_input->{'-labels'}->{$input} = $_->{description} || $input; + } +} + +warn "## only_input = ", dump( $only_input ); + print start_html( -title => $db->{name}, @@ -139,16 +156,13 @@ print h2( 'Select input' ), checkbox_group( -name => 'only_input', - -values => [ map { $_->{name} } @{ $db->{input} } ], + %$only_input, -linebreak=> 'true', ), qq||, ; -dump_yaml( 'inputs', $db->{input} ); -dump_yaml( 'input names', map { $_->{name} } @{ $db->{input} } ); - print end_form; if ( my $search = param('search') ) { @@ -165,8 +179,7 @@ if ( my $search = param('search') ) { dump_yaml( 'pager', $pager ); - my @search = (); - + my @search = (); if ( $search =~ m{(=|"|AND|OR)} ) { push @search, $search; } elsif ( my $op = param('attr_operator') ) { @@ -189,15 +202,14 @@ if ( my $search = param('search') ) { $v =~ s{(\s*)(\S+)}{rewrite($1,$2)}ge; push @search, $v; + + my @only_input = param('only_input'); + push @search, '(' . join(') OR (', map { "input=$_" } @only_input) . ')' if @only_input; } else { - push @search, "xml=$search"; + push @search, "all=\"$search\""; } - my @only_input = param('only_input'); - - push @search, '(' . join(') or (', @only_input) . ')' if @only_input; - - my $q = '(' . join(') and (', @search) . ')'; + my $q = '(' . join(') AND (', @search) . ')'; $q =~ s{\(\((.+)\)\)}{($1)}; warn "# query: $q\n"; my $swish_results = $swish->query( $q ); @@ -250,7 +262,7 @@ if ( my $search = param('search') ) { } -dump_yaml( 'db', $db ); +dump_yaml( "config databases $database", $db ); dump_yaml( 'html_markup_skip', $html_markup_skip ); print end_html;