diff options
author | Yorhel <git@yorhel.nl> | 2011-03-30 14:25:34 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2011-03-30 14:25:34 +0200 |
commit | 7c8306f215050243029cfc2dc22152a02476a285 (patch) | |
tree | 7792d9c3d05ff05573e7ee9fe70a08f674e03b03 /lib | |
parent | a2a389e70da0ec880d9e028f5041060416e7b7d8 (diff) |
chardb: Rushed in some crappy spoiler hiding stuff
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VNDB/Func.pm | 8 | ||||
-rw-r--r-- | lib/VNDB/Handler/Chars.pm | 59 | ||||
-rw-r--r-- | lib/VNDB/Handler/VNPage.pm | 15 |
3 files changed, 58 insertions, 24 deletions
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm index edb6e3aa..64b56625 100644 --- a/lib/VNDB/Func.pm +++ b/lib/VNDB/Func.pm @@ -7,7 +7,7 @@ use TUWF ':html'; use Exporter 'import'; use POSIX 'strftime', 'ceil', 'floor'; use VNDBUtil; -our @EXPORT = (@VNDBUtil::EXPORT, qw| clearfloat cssicon tagscore mt minage fil_parse fil_serialize parenttags childtags |); +our @EXPORT = (@VNDBUtil::EXPORT, qw| clearfloat cssicon tagscore mt minage fil_parse fil_serialize parenttags childtags charspoil |); # three ways to represent the same information @@ -174,5 +174,11 @@ sub childtags { } +# generates the class elements for character spoiler hiding +sub charspoil { + return "charspoil charspoil_$_[0]".($_[0] ? ' hidden' : ''); +} + + 1; diff --git a/lib/VNDB/Handler/Chars.pm b/lib/VNDB/Handler/Chars.pm index 9b0f7f0a..ca9cf105 100644 --- a/lib/VNDB/Handler/Chars.pm +++ b/lib/VNDB/Handler/Chars.pm @@ -67,12 +67,17 @@ sub page { div class => 'mainbox'; $self->htmlItemMessage('c', $r); + p id => 'charspoil_sel'; + a href => '#', class => 'sel', mt '_vnpage_tags_spoil0'; # _vnpage!? + a href => '#', mt '_vnpage_tags_spoil1'; + a href => '#', mt '_vnpage_tags_spoil2'; + end; h1 $r->{name}; h2 class => 'alttitle', $r->{original} if $r->{original}; $self->charTable($r); end; - # TODO: ordering of these instances? + spoiler handling + # TODO: ordering of these instances? my $inst = []; if(!$r->{main}) { $inst = $self->dbCharGet(instance => $r->{id}, what => 'extended traits vns'); @@ -83,7 +88,7 @@ sub page { if(@$inst) { div class => 'mainbox'; h1 mt '_charp_instances'; - $self->charTable($_, 1, $_ != $inst->[0]) for @$inst; + $self->charTable($_, 1, $_ != $inst->[0], 0, !$r->{main} ? $_->{main_spoil} : $_->{main_spoil} > $r->{main_spoil} ? $_->{main_spoil} : $r->{main_spoil}) for @$inst; end; } @@ -93,9 +98,10 @@ sub page { # Also used from Handler::VNPage sub charTable { - my($self, $r, $link, $sep, $vn) = @_; + my($self, $r, $link, $sep, $vn, $spoil) = @_; + $spoil ||= 0; - div class => 'chardetails'.($sep ? ' charsep' : ''); + div class => 'chardetails '.charspoil($spoil).($sep ? ' charsep' : ''); # image div class => 'charimg'; @@ -148,7 +154,7 @@ sub charTable { } # traits - # TODO: handle spoilers and 'sexual' traits + # TODO: handle 'sexual' traits my %groups; my @groups; for (@{$r->{traits}}) { @@ -161,15 +167,16 @@ sub charTable { 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 (@{$groups{$g}}) { - txt ', ' if $_->{tid} != $groups{$g}[0]{tid}; - a href => "/i$_->{tid}", $_->{name}; + span class => charspoil $_->{spoil}; + txt ', ' if $_->{tid} != $groups{$g}[0]{tid}; + a href => "/i$_->{tid}", $_->{name}; + end; } end; end; } # vns - # TODO: handle spoilers! if(@{$r->{vns}} && (!$vn || $vn && (@{$r->{vns}} > 1 || $r->{vns}[0]{rid}))) { my %vns; push @{$vns{$_->{vid}}}, $_ for(sort { !defined($a->{rid})?1:!defined($b->{rid})?-1:$a->{rtitle} cmp $b->{rtitle} } @{$r->{vns}}); @@ -182,23 +189,31 @@ sub charTable { my @r = @{$vns{$g}}; # special case: all releases, no exceptions if(!$vn && @r == 1 && !$r[0]{rid}) { - txt mt("_charrole_$r[0]{role}").' - '; - a href => "/v$r[0]{vid}/chars", $r[0]{vntitle}; + span class => charspoil $r[0]{spoil}; + txt mt("_charrole_$r[0]{role}").' - '; + a href => "/v$r[0]{vid}/chars", $r[0]{vntitle}; + end; next; } # otherwise, print VN title and list releases separately - a href => "/v$r[0]{vid}/chars", $r[0]{vntitle} if !$vn; - for(@r) { - br if !$vn || $_ != $r[0]; - b class => 'grayedout', '> '; - txt mt("_charrole_$_->{role}").' - '; - if($_->{rid}) { - b class => 'grayedout', "r$_->{rid}:"; - a href => "/r$_->{rid}", $_->{rtitle}; - } else { - txt mt '_charp_vns_other'; - } - } + my $minspoil = 5; + $minspoil = $minspoil > $_->{spoil} ? $_->{spoil} : $minspoil for (@r); + span class => charspoil $minspoil; + a href => "/v$r[0]{vid}/chars", $r[0]{vntitle} if !$vn; + for(@r) { + span class => charspoil $_->{spoil}; + br if !$vn || $_ != $r[0]; + b class => 'grayedout', '> '; + txt mt("_charrole_$_->{role}").' - '; + if($_->{rid}) { + b class => 'grayedout', "r$_->{rid}:"; + a href => "/r$_->{rid}", $_->{rtitle}; + } else { + txt mt '_charp_vns_other'; + } + end; + } + end; } end; end; diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm index 5d692974..763fc82d 100644 --- a/lib/VNDB/Handler/VNPage.pm +++ b/lib/VNDB/Handler/VNPage.pm @@ -539,11 +539,24 @@ sub _chars { for my $r (@{$self->{char_roles}}) { $rol{$r} = [ grep grep($_->{role} eq $r, @{$_->{vns}}) && !$done{$_->{id}}++, @$l ]; } + my $first = 0; for my $r (@{$self->{char_roles}}) { next if !@{$rol{$r}}; div class => 'mainbox'; + if(!$first++) { + p id => 'charspoil_sel'; + a href => '#', class => 'sel', mt '_vnpage_tags_spoil0'; # _vnpage!? + a href => '#', mt '_vnpage_tags_spoil1'; + a href => '#', mt '_vnpage_tags_spoil2'; + end; + } h1 mt "_charrole_$r"; - $self->charTable($_, 1, $_ != $rol{$r}[0], 1) for (@{$rol{$r}}); + for my $c (@{$rol{$r}}) { + my $minspoil = 5; + $minspoil = $_->{vid} == $v->{id} && $_->{spoil} < $minspoil ? $_->{spoil} : $minspoil + for(@{$c->{vns}}); + $self->charTable($c, 1, $c != $rol{$r}[0], 1, $minspoil); + } end; } } |