diff options
author | Yorhel <git@yorhel.nl> | 2015-08-08 02:10:40 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2015-08-08 02:10:40 +0200 |
commit | 6c46c3bd553734944847193a3356176efc3416e7 (patch) | |
tree | 235050d0632a687ca6338cf63c4ac16c338f7b08 /lib/VNDB/Handler | |
parent | 7c3c7ed1ae63299925c6fdab306c57e9ee232f26 (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/VNDB/Handler')
-rw-r--r-- | lib/VNDB/Handler/Chars.pm | 37 | ||||
-rw-r--r-- | lib/VNDB/Handler/VNPage.pm | 14 |
2 files changed, 23 insertions, 28 deletions
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; |