summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2015-08-08 02:10:40 +0200
committerYorhel <git@yorhel.nl>2015-08-08 02:10:40 +0200
commit6c46c3bd553734944847193a3356176efc3416e7 (patch)
tree235050d0632a687ca6338cf63c4ac16c338f7b08 /lib
parent7c3c7ed1ae63299925c6fdab306c57e9ee232f26 (diff)
Add sexual trait toggle to character information
It's not a preference yet and the sexual traits are still visible by default. I'll fix that later.
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/DB/Chars.pm2
-rw-r--r--lib/VNDB/Handler/Chars.pm37
-rw-r--r--lib/VNDB/Handler/VNPage.pm14
3 files changed, 24 insertions, 29 deletions
diff --git a/lib/VNDB/DB/Chars.pm b/lib/VNDB/DB/Chars.pm
index 2f7de43f..3db5f869 100644
--- a/lib/VNDB/DB/Chars.pm
+++ b/lib/VNDB/DB/Chars.pm
@@ -87,7 +87,7 @@ sub dbCharGet {
if($o{what} =~ /traits/) {
push @{$r{ delete $_->{cid} }{traits}}, $_ for (@{$self->dbAll(q|
- SELECT ct.cid, ct.tid, ct.spoil, t.name, t."group", tg.name AS groupname
+ SELECT ct.cid, ct.tid, ct.spoil, t.name, t.sexual, t."group", tg.name AS groupname
FROM chars_traits ct
JOIN traits t ON t.id = ct.tid
LEFT JOIN traits tg ON tg.id = t."group"
diff --git a/lib/VNDB/Handler/Chars.pm b/lib/VNDB/Handler/Chars.pm
index c59d44b9..cb5e6638 100644
--- a/lib/VNDB/Handler/Chars.pm
+++ b/lib/VNDB/Handler/Chars.pm
@@ -7,7 +7,7 @@ use TUWF ':html', 'uri_escape';
use Exporter 'import';
use VNDB::Func;
-our @EXPORT = ('charTable', 'charBrowseTable');
+our @EXPORT = ('charOps', 'charTable', 'charBrowseTable');
TUWF::register(
qr{c([1-9]\d*)(?:\.([1-9]\d*))?} => \&page,
@@ -66,10 +66,7 @@ sub page {
div class => 'mainbox';
$self->htmlItemMessage('c', $r);
- my $spoil = $self->authPref('spoilers')||0;
- p id => 'charspoil_sel';
- a href => '#', $spoil == $_ ? (class => 'sel') : (), mt "_spoilset_$_" for (0..2);
- end;
+ $self->charOps(1);
h1 $r->{name};
h2 class => 'alttitle', $r->{original} if $r->{original};
$self->charTable($r);
@@ -94,6 +91,17 @@ sub page {
}
+sub charOps {
+ my($self, $sexual) = @_;
+ my $spoil = $self->authPref('spoilers')||0;
+ p id => 'charops';
+ # Note: Order of these links is hardcoded in JS
+ a href => '#', $spoil == $_ ? (class => 'sel') : (), mt "_spoilset_$_" for (0..2);
+ a href => '#', class => 'sec sel', mt '_charp_sexual' if $sexual;
+ end;
+}
+
+
# Also used from Handler::VNPage
sub charTable {
my($self, $r, $link, $sep, $vn, $spoil) = @_;
@@ -151,8 +159,6 @@ sub charTable {
}
# traits
- # TODO: handle 'sexual' traits
- # TODO: fix striping of the table with hidden trait groups (due to spoilers)
my %groups;
my @groups;
for (@{$r->{traits}}) {
@@ -162,20 +168,19 @@ sub charTable {
}
for my $g (@groups) {
my $minspoil = 5;
- $minspoil = $minspoil > $_->{spoil} ? $_->{spoil} : $minspoil for(@{$groups{$g}});
- Tr class => charspoil($minspoil);
+ my $fullsex = 1;
+ for(@{$groups{$g}}) {
+ $minspoil = $minspoil > $_->{spoil} ? $_->{spoil} : $minspoil;
+ $fullsex = 0 if !$_->{sexual};
+ }
+ Tr class => charspoil($minspoil).($fullsex ? ' sexual' : '');
td class => 'key'; a href => '/i'.($groups{$g}[0]{group}||$groups{$g}[0]{tid}), $groups{$g}[0]{groupname} || $groups{$g}[0]{name}; end;
td;
for (0..$#{$groups{$g}}) {
my $t = $groups{$g}[$_];
- span class => charspoil $t->{spoil};
+ span class => charspoil($t->{spoil}).($t->{sexual} ? ' sexual' : '');
+ span ', ';
a href => "/i$t->{tid}", $t->{name};
- # spoiler setting of the comma = max(current, min(@remaining_spoil))
- # since it is in the current <span>, which has 'current', only the second part is relevant if it is > current
- my $min_remaining = 5;
- $min_remaining = $min_remaining > $groups{$g}[$_]{spoil} ? $groups{$g}[$_]{spoil} : $min_remaining for($_+1..$#{$groups{$g}});
- span class => charspoil($min_remaining), ', ' if $min_remaining != 5 && $min_remaining > $t->{spoil};
- txt ', ' if $min_remaining != 5 && $min_remaining <= $t->{spoil};
end;
}
end;
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index 16904efc..f4b4b6e5 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -898,12 +898,7 @@ sub _chars {
for my $r (@{$self->{char_roles}}) {
next if !@{$rol{$r}};
div class => 'mainbox';
- if(!$first++) {
- my $spoil = $self->authPref('spoilers')||0;
- p id => 'charspoil_sel';
- a href => '#', $spoil == $_ ? (class => 'sel') : (), mt "_spoilset_$_" for (0..2);
- end;
- }
+ $self->charOps(1) if !$first++;
h1 mt "_charrole_$r", scalar @{$rol{$r}};
for my $c (@{$rol{$r}}) {
my $minspoil = 5;
@@ -948,12 +943,7 @@ sub _staff {
my($has_spoilers, $has_notes);
$has_spoilers ||= $_->{spoil}, $has_notes ||= $_->{note} for @{$v->{seiyuu}};
div class => 'mainbox staff cast';
- if($has_spoilers) {
- my $spoil = $self->authPref('spoilers')||0;
- p id => 'charspoil_sel';
- a href => '#', $spoil == $_ ? (class => 'sel') : (), mt "_spoilset_$_" for (0..2);
- end;
- }
+ $self->charOps(0) if $has_spoilers;
h1 mt '_vnpage_cast';
table class => 'stripe';
thead;