summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-07-05 15:48:38 +0200
committerYorhel <git@yorhel.nl>2009-07-05 15:52:47 +0200
commitba1d4aed3e9b081a55d306c96c134eee5117284b (patch)
treeba33209f9e0762b3783e6e73e4750936c8ce1534 /lib
parent58e7d6f87e7533e03606b06c1be80c59bcba92bc (diff)
Added spoiler options for tag filters on VN search
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/DB/VN.pm8
-rw-r--r--lib/VNDB/Handler/VNBrowse.pm4
-rw-r--r--lib/VNDB/Util/FormHTML.pm12
3 files changed, 18 insertions, 6 deletions
diff --git a/lib/VNDB/DB/VN.pm b/lib/VNDB/DB/VN.pm
index 5058c367..5228a371 100644
--- a/lib/VNDB/DB/VN.pm
+++ b/lib/VNDB/DB/VN.pm
@@ -32,7 +32,9 @@ sub dbVNGet {
$o{platform} && @{$o{platform}} ? (
'('.join(' OR ', map "v.c_platforms ILIKE '%%$_%%'", @{$o{platform}}).')' => 1 ) : (),
$o{tags_include} && @{$o{tags_include}} ? (
- 'v.id IN(SELECT vid FROM tags_vn_bayesian WHERE tag IN(!l) GROUP BY vid HAVING COUNT(tag) = ?)' => [ $o{tags_include}, $#{$o{tags_include}}+1 ]) : (),
+ 'v.id IN(SELECT vid FROM tags_vn_bayesian WHERE tag IN(!l) AND spoiler <= ? GROUP BY vid HAVING COUNT(tag) = ?)',
+ [ $o{tags_include}[1], $o{tags_include}[0], $#{$o{tags_include}[1]}+1 ]
+ ) : (),
# don't fetch hidden items unless we ask for an ID
!$o{id} && !$o{rev} ? (
'v.hidden = FALSE' => 0 ) : (),
@@ -75,7 +77,7 @@ sub dbVNGet {
'JOIN relgraph rg ON rg.id = v.rgraph' : (),
);
- my $tag_ids = $o{tags_include} && join ',', @{$o{tags_include}};
+ my $tag_ids = $o{tags_include} && join ',', @{$o{tags_include}[1]};
my @select = (
qw|v.id v.locked v.hidden v.c_released v.c_languages v.c_platforms vr.title vr.original v.rgraph v.c_popularity|, 'vr.id AS cid',
$o{what} =~ /extended/ ? (
@@ -85,7 +87,7 @@ sub dbVNGet {
$o{what} =~ /relgraph/ ? 'rg.cmap' : (),
$o{what} =~ /ranking/ ? '(SELECT COUNT(*)+1 FROM vn iv WHERE iv.hidden = false AND iv.c_popularity > v.c_popularity) AS ranking' : (),
$tag_ids ?
- qq|(SELECT AVG(tvb.rating) FROM tags_vn_bayesian tvb WHERE tvb.tag IN($tag_ids) AND tvb.vid = v.id GROUP BY tvb.vid) AS tagscore| : (),
+ qq|(SELECT AVG(tvb.rating) FROM tags_vn_bayesian tvb WHERE tvb.tag IN($tag_ids) AND tvb.vid = v.id AND spoiler <= $o{tags_include}[0] GROUP BY tvb.vid) AS tagscore| : (),
);
my($r, $np) = $self->dbPage(\%o, q|
diff --git a/lib/VNDB/Handler/VNBrowse.pm b/lib/VNDB/Handler/VNBrowse.pm
index 3ced3002..ecb2e235 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 => 'sp', required => 0, default => $self->reqCookie('tagspoil') =~ /^([0-2])$/ ? $1 : 1, enum => [0..2] },
);
return 404 if $f->{_err};
$f->{q} ||= $f->{sq};
@@ -56,7 +57,7 @@ sub list {
order => ($f->{s} eq 'rel' ? 'c_released' : $f->{s} eq 'pop' ? 'c_popularity' : $f->{s}).($f->{o} eq 'a' ? ' ASC' : ' DESC'),
$f->{pl}[0] ? ( platform => $f->{pl} ) : (),
$f->{ln}[0] ? ( lang => $f->{ln} ) : (),
- tags_include => \@ti,
+ @ti ? (tags_include => [ $f->{sp}, \@ti ]) : (),
);
$self->resRedirect('/v'.$list->[0]{id}, 'temp')
@@ -145,6 +146,7 @@ sub _filters {
end;
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']]]);
end;
h2;
diff --git a/lib/VNDB/Util/FormHTML.pm b/lib/VNDB/Util/FormHTML.pm
index b37d6ba8..dfb9a91f 100644
--- a/lib/VNDB/Util/FormHTML.pm
+++ b/lib/VNDB/Util/FormHTML.pm
@@ -116,7 +116,8 @@ sub htmlFormError {
# passwd short, name
# static content, (label, nolabel)
# check name, short, (value)
-# select name, short, options, (width)
+# select name, short, options, (width, multi, size)
+# radio name, short, options
# text name, short, (rows, cols)
# date name, short
# part title
@@ -148,7 +149,7 @@ sub htmlFormPart {
lit '&nbsp;';
end;
td class => 'field';
- input type => 'checkbox', class => 'checkbox', name => $o{short}, id => $o{short},
+ input type => 'checkbox', name => $o{short}, id => $o{short},
value => $o{value}||'true', $frm->{$o{short}} ? ( checked => 'checked' ) : ();
label for => $o{short};
lit $o{name};
@@ -201,6 +202,13 @@ sub htmlFormPart {
end if $l;
end;
}
+ if(/radio/) {
+ for my $p (@{$o{options}}) {
+ input type => 'radio', id => "$o{short}_$p->[0]", name => $o{short}, value => $p->[0],
+ defined $frm->{$o{short}} && $frm->{$o{short}} eq $p->[0] ? (checked => 'checked') : ();
+ label for => "$o{short}_$p->[0]", $p->[1];
+ }
+ }
if(/date/) {
input type => 'hidden', id => $o{short}, name => $o{short}, value => $frm->{$o{short}}||'', class => 'dateinput';
}