projects
/
webpac2
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ignore and if written any other way than AND
[webpac2]
/
vhost
/
webpac2.cgi
diff --git
a/vhost/webpac2.cgi
b/vhost/webpac2.cgi
index
2abdb4c
..
fd76b65
100755
(executable)
--- a/
vhost/webpac2.cgi
+++ b/
vhost/webpac2.cgi
@@
-13,6
+13,7
@@
use SWISH::API;
use JSON;
use Text::Unaccent::PurePerl qw/unac_string/;
use HTML::FillInForm::Lite;
use JSON;
use Text::Unaccent::PurePerl qw/unac_string/;
use HTML::FillInForm::Lite;
+use Encode;
my $range_around = 5;
my @entries_per_page = ( 30, 50, 100, 500 );
my $range_around = 5;
my @entries_per_page = ( 30, 50, 100, 500 );
@@
-202,7
+203,7
@@
print
if ( my $search = param('search') ) {
if ( my $search = param('search') ) {
- $search = unac_string(
$search
);
+ $search = unac_string(
Encode::decode('utf-8',$search)
);
print qq|
<a href="#form" class="skip" title="skip to search form">#</a>
print qq|
<a href="#form" class="skip" title="skip to search form">#</a>
@@
-216,7
+217,7
@@
if ( my $search = param('search') ) {
my @attrs = param('attr');
my $op = param('attr_operator');
my @attrs = param('attr');
my $op = param('attr_operator');
- if ( $search =~ m{(=|"|
AND|OR
)} ) {
+ if ( $search =~ m{(=|"|
\bAND\b|\bOR\b
)} ) {
push @search, $search;
} elsif ( @attrs ) {
push @search, $search;
} elsif ( @attrs ) {
@@
-233,6
+234,9
@@
if ( my $search = param('search') ) {
$template =~ s{Q}{$v};
$whitespace = " AND " if $whitespace;
$template =~ s{Q}{$v};
$whitespace = " AND " if $whitespace;
+ # don't return -* &* and other non-word characters
+ return '' if $template =~ m/^\W\*$/ || $template =~ m/\band\b/i;
+
return
$whitespace .
$attr . '="' . $template . '"';
return
$whitespace .
$attr . '="' . $template . '"';
@@
-261,7
+265,11
@@
if ( my $search = param('search') ) {
$q .= ' AND ((' . join(') OR (', map { "input=\"$_\"" } @only_input) . '))' if @only_input;
warn "# query: $q\n";
$q .= ' AND ((' . join(') OR (', map { "input=\"$_\"" } @only_input) . '))' if @only_input;
warn "# query: $q\n";
- my $swish_results = $swish->query( $q );
+ my $search_obj = $swish->new_search_object;
+ if ( my $sort = param('sort') ) {
+ $search_obj->set_sort( $sort );
+ }
+ my $swish_results = $search_obj->execute( $q );
dump_yaml( 'swish_results', $swish_results );
dump_yaml( 'swish_results', $swish_results );