diff options
author | Yorhel <git@yorhel.nl> | 2009-07-05 18:15:01 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2009-07-05 18:15:01 +0200 |
commit | d59124e057e3a10dac0a3a448f4503679810850c (patch) | |
tree | 970b2cb381656d6d635cbd4046f30ed685413e62 /lib/VNDB/Handler/VNBrowse.pm | |
parent | ba1d4aed3e9b081a55d306c96c134eee5117284b (diff) |
Tag exclude filters on VN search
Diffstat (limited to 'lib/VNDB/Handler/VNBrowse.pm')
-rw-r--r-- | lib/VNDB/Handler/VNBrowse.pm | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/VNDB/Handler/VNBrowse.pm b/lib/VNDB/Handler/VNBrowse.pm index ecb2e235..5a22bccc 100644 --- a/lib/VNDB/Handler/VNBrowse.pm +++ b/lib/VNDB/Handler/VNBrowse.pm @@ -24,6 +24,7 @@ sub list { { name => 'ln', required => 0, multi => 1, enum => [ keys %{$self->{languages}} ], default => '' }, { name => 'pl', required => 0, multi => 1, enum => [ keys %{$self->{platforms}} ], default => '' }, { name => 'ti', required => 0, default => '', maxlength => 200 }, + { name => 'te', required => 0, default => '', maxlength => 200 }, { name => 'sp', required => 0, default => $self->reqCookie('tagspoil') =~ /^([0-2])$/ ? $1 : 1, enum => [0..2] }, ); return 404 if $f->{_err}; @@ -40,12 +41,17 @@ sub list { } my @ignored; - my @ti = map { - my $i = $self->dbTagGet(name => $_)->[0]; - push @ignored, [$_, 0] if !$i; - push @ignored, [$_, 1] if $i && $i->{meta}; - $i && !$i->{meta} ? $i->{id} : (); - } grep $_, split /\s*,\s*/, $f->{ti}; + my $tagfind = sub { + return map { + my $i = $self->dbTagGet(name => $_)->[0]; + push @ignored, [$_, 0] if !$i; + push @ignored, [$_, 1] if $i && $i->{meta}; + $i && !$i->{meta} ? $i->{id} : (); + } grep $_, split /\s*,\s*/, $_[0]; + }; + my @ti = $tagfind->($f->{ti}); + my @te = $tagfind->($f->{te}); + $f->{s} = 'title' if !@ti && $f->{s} eq 'tagscore'; $f->{o} = $f->{s} eq 'tagscore' ? 'd' : 'a' if !$f->{o}; @@ -58,6 +64,7 @@ sub list { $f->{pl}[0] ? ( platform => $f->{pl} ) : (), $f->{ln}[0] ? ( lang => $f->{ln} ) : (), @ti ? (tags_include => [ $f->{sp}, \@ti ]) : (), + @te ? (tags_exclude => \@te) : (), ); $self->resRedirect('/v'.$list->[0]{id}, 'temp') @@ -66,7 +73,7 @@ sub list { $self->htmlHeader(title => 'Browse visual novels', search => $f->{q}, js => 'forms'); _filters($self, $f, $char, \@ignored); - my $url = "/v/$char?q=$f->{q};ti=$f->{ti}"; + my $url = "/v/$char?q=$f->{q};ti=$f->{ti};te=$f->{te}"; $_ and $url .= ";pl=$_" for @{$f->{pl}}; $_ and $url .= ";ln=$_" for @{$f->{ln}}; $self->htmlBrowse( @@ -147,6 +154,7 @@ sub _filters { table class => 'formtable', style => 'margin-left: 0'; $self->htmlFormPart($f, [ input => short => 'ti', name => 'Tags to include', width => 350 ]); $self->htmlFormPart($f, [ radio => short => 'sp', name => '', options => [[0,'Hide spoilers'],[1,'Show minor spoilers'],[2,'Show major spoilers']]]); + $self->htmlFormPart($f, [ input => short => 'te', name => 'Tags to exclude', width => 350 ]); end; h2; |