diff options
author | Yorhel <git@yorhel.nl> | 2015-05-13 13:59:04 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2015-05-13 13:59:04 +0200 |
commit | 3921fe19c6b0bd5125bc488a338a8968dc2f2f81 (patch) | |
tree | e52e50e3aacc0d44ee4fc815ea77c8d15b3581a9 /lib | |
parent | 2a783edbab51aa490884814c9c45f919886d70ef (diff) |
Changed layour of staff pages
Not entirely sure if this is an improvement, but it's slightly more
consistent with other layouts (combination of user page, release page
and character page), and leaves more room for the credit/cast listings.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VNDB/Handler/Staff.pm | 232 | ||||
-rw-r--r-- | lib/VNDB/Util/BrowseHTML.pm | 4 |
2 files changed, 107 insertions, 129 deletions
diff --git a/lib/VNDB/Handler/Staff.pm b/lib/VNDB/Handler/Staff.pm index e17e5319..3c8fd7af 100644 --- a/lib/VNDB/Handler/Staff.pm +++ b/lib/VNDB/Handler/Staff.pm @@ -15,6 +15,7 @@ TUWF::register( qr{xml/staff\.xml} => \&staffxml, ); + sub page { my($self, $id, $rev) = @_; @@ -51,153 +52,130 @@ sub page { div class => 'mainbox staffpage'; $self->htmlItemMessage('s', $s); - div class => 'staffinfo'; - h1 $s->{name}; - h2 class => 'alttitle'; - span style => 'margin-right: 10px', $s->{original} if $s->{original}; - cssicon "gen $s->{gender}", mt "_gender_$s->{gender}" if $s->{gender} ne 'unknown'; - end; - - # info table - table class => 'stripe'; + h1 $s->{name}; + h2 class => 'alttitle', $s->{original} if $s->{original}; + # info table + table class => 'stripe'; + thead; Tr; - td class => 'key', mt '_staff_language'; - td mt "_lang_$s->{lang}"; + td colspan => 2; + b style => 'margin-right: 10px', $s->{name}; + b class => 'grayedout', style => 'margin-right: 10px', $s->{original} if $s->{original}; + cssicon "gen $s->{gender}", mt "_gender_$s->{gender}" if $s->{gender} ne 'unknown'; + end; end; - if (@{$s->{aliases}}) { - Tr; - td class => 'key', mt('_staff_aliases', scalar @{$s->{aliases}}); - td; - table class => 'aliases'; - foreach my $alias (@{$s->{aliases}}) { - Tr class => 'nostripe'; - td $alias->{original} ? () : (colspan => 2), class => 'key'; - txt $alias->{name}; - end; - td $alias->{original} if $alias->{original}; + end; + Tr; + td class => 'key', mt '_staff_language'; + td mt "_lang_$s->{lang}"; + end; + if(@{$s->{aliases}}) { + Tr; + td class => 'key', mt('_staff_aliases', scalar @{$s->{aliases}}); + td; + table class => 'aliases'; + for my $alias (@{$s->{aliases}}) { + Tr class => 'nostripe'; + td $alias->{original} ? () : (colspan => 2), class => 'key'; + txt $alias->{name}; end; - } - end; - end; - end; - } - my @links = ( - $s->{l_site} ? [ 'site', $s->{l_site} ] : (), - $s->{l_wp} ? [ 'wp', "http://en.wikipedia.org/wiki/$s->{l_wp}" ] : (), - $s->{l_twitter} ? [ 'twitter', "https://twitter.com/$s->{l_twitter}" ] : (), - $s->{l_anidb} ? [ 'anidb', "http://anidb.net/cr$s->{l_anidb}" ] : (), - ); - if(@links) { - Tr; - td class => 'key', mt '_staff_links'; - td; - for(@links) { - a href => $_->[1], mt "_staff_l_$_->[0]"; - br if $_ != $links[$#links]; + td $alias->{original} if $alias->{original}; + end; } end; end; - } - end 'table'; - end; - - # description - div class => 'staffdesc'; - if($s->{desc}) { - h2 mt '_staff_bio'; - p; - lit bb2html $s->{desc}, 0, 1; - end; - br; - } - - if (@{$s->{roles}}) { - h2 mt '_staff_credits'; - my $has_notes = first { $_->{note} || $_->{name} ne $s->{name} } @{$s->{roles}}; - table class => 'staffroles'; - thead; - Tr; - td class => 'tc2', mt '_staff_col_title'; - td class => 'tc3', mt '_staff_col_released'; - td class => 'tc1', mt '_staff_col_role'; - td class => 'tc4', mt '_staff_col_note' if $has_notes; - end; - end; - tbody; - my($last_vid, $row_count, $num) = (0) x 3; - for my $i (0..$#{$s->{roles}}) { - my $r = $s->{roles}->[$i]; - if($r->{vid} != $last_vid) { - ++$num; - $row_count = 1; - for my $j (1+$i..$#{$s->{roles}}) { - last if $r->{vid} != $s->{roles}->[$j]->{vid}; - ++$row_count; - } - } - Tr $num&1 ? (class => 'odd') : (); - if($last_vid != $r->{vid}) { - td class => 'tc2', $row_count > 1 ? (rowspan => $row_count) : (); - a href => "/v$r->{vid}", title => $r->{t_original}||$r->{title}, shorten $r->{title}, 60; - end; - td class => 'tc3', $row_count > 1 ? (rowspan => $row_count) : (); - lit $self->{l10n}->datestr($r->{c_released}); - end; - } - td class => 'tc1', mt '_credit_'.$r->{role}; - if($has_notes) { - td class => 'tc4'; - txt '('.mt('_staff_as', $r->{name}).') ' if $r->{name} ne $s->{name}; - txt $r->{note}; - end; - } - end; - $last_vid = $r->{vid}; - } - end; end; - br; } - if (@{$s->{cast}}) { - h2 mt('_staff_voiced', scalar @{$s->{cast}}); - my $has_notes = first { $_->{note} || $_->{name} ne $s->{name} } @{$s->{cast}}; - table class => 'stripe staffroles'; - thead; - Tr; - td class => 'tc2', mt '_staff_col_title'; - td class => 'tc3', mt '_staff_col_released'; - td class => 'tc1', mt '_staff_col_cast'; - td class => 'tc4', mt '_staff_col_note' if $has_notes; - end; - end; - tbody; - foreach my $r (@{$s->{cast}}) { - Tr; - td class => 'tc2'; - a href => "/v$r->{vid}", title => $r->{t_original}||$r->{title}, shorten $r->{title}, 60; - end; - td class => 'tc3'; lit $self->{l10n}->datestr($r->{c_released}); end; - td class => 'tc1'; a href => "/c$r->{cid}", title => $r->{c_original}, $r->{c_name}; end; - if($has_notes) { - td class => 'tc4'; - txt '('.mt('_staff_as', $r->{name}).') ' if $r->{name} ne $s->{name}; - txt $r->{note}; - end; - } - end; + my @links = ( + $s->{l_site} ? [ 'site', $s->{l_site} ] : (), + $s->{l_wp} ? [ 'wp', "http://en.wikipedia.org/wiki/$s->{l_wp}" ] : (), + $s->{l_twitter} ? [ 'twitter', "https://twitter.com/$s->{l_twitter}" ] : (), + $s->{l_anidb} ? [ 'anidb', "http://anidb.net/cr$s->{l_anidb}" ] : (), + ); + if(@links) { + Tr; + td class => 'key', mt '_staff_links'; + td; + for(@links) { + a href => $_->[1], mt "_staff_l_$_->[0]"; + br if $_ != $links[$#links]; } end; end; } + end 'table'; + + # description + p class => 'description'; + lit bb2html $s->{desc}, 0, 1; end; - clearfloat; end; + _roles($self, $s); + _cast($self, $s); $self->htmlFooter; } +sub _roles { + my($self, $s) = @_; + return if !@{$s->{roles}}; + + h1 class => 'boxtitle', mt '_staff_credits'; + $self->htmlBrowse( + items => $s->{roles}, + class => 'staffroles', + header => [ + [ mt '_staff_col_title' ], + [ mt '_staff_col_released' ], + [ mt '_staff_col_role' ], + [ mt '_staff_col_as' ], + [ mt '_staff_col_note' ], + ], + row => sub { + my($r, $n, $l) = @_; + Tr; + td class => 'tc1'; a href => "/v$l->{vid}", title => $l->{t_original}||$l->{title}, shorten $l->{title}, 60; end; + td class => 'tc2'; lit $self->{l10n}->datestr($l->{c_released}); end; + td class => 'tc3', mt '_credit_'.$l->{role}; + td class => 'tc4', title => $l->{original}||$l->{name}, $l->{name}; + td class => 'tc5', $l->{note}; + end; + }, + ); +} + + +sub _cast { + my($self, $s) = @_; + return if !@{$s->{cast}}; + + h1 class => 'boxtitle', mt '_staff_voiced', scalar @{$s->{cast}}; + $self->htmlBrowse( + items => $s->{cast}, + class => 'staffroles', + header => [ + [ mt '_staff_col_title' ], + [ mt '_staff_col_released' ], + [ mt '_staff_col_cast' ], + [ mt '_staff_col_as' ], + [ mt '_staff_col_note' ], + ], + row => sub { + my($r, $n, $l) = @_; + Tr; + td class => 'tc1'; a href => "/v$l->{vid}", title => $l->{t_original}||$l->{title}, shorten $l->{title}, 60; end; + td class => 'tc2'; lit $self->{l10n}->datestr($l->{c_released}); end; + td class => 'tc3'; a href => "/c$l->{cid}", title => $l->{c_original}, $l->{c_name}; end; + td class => 'tc4', title => $l->{original}||$l->{name}, $l->{name}; + td class => 'tc5', $l->{note}; + end; + }, + ); +} + + sub edit { my($self, $sid, $rev) = @_; diff --git a/lib/VNDB/Util/BrowseHTML.pm b/lib/VNDB/Util/BrowseHTML.pm index 40cc3270..aca7b8e6 100644 --- a/lib/VNDB/Util/BrowseHTML.pm +++ b/lib/VNDB/Util/BrowseHTML.pm @@ -35,7 +35,7 @@ sub htmlBrowse { $opt{sorturl} .= $opt{sorturl} =~ /\?/ ? ';' : '?' if $opt{sorturl}; # top navigation - $self->htmlBrowseNavigate($opt{pageurl}, $opt{options}{p}, $opt{nextpage}, 't'); + $self->htmlBrowseNavigate($opt{pageurl}, $opt{options}{p}, $opt{nextpage}, 't') if $opt{pageurl}; div class => 'mainbox browse'.($opt{class} ? ' '.$opt{class} : ''); table class => 'stripe'; @@ -79,7 +79,7 @@ sub htmlBrowse { end 'div'; # bottom navigation - $self->htmlBrowseNavigate($opt{pageurl}, $opt{options}{p}, $opt{nextpage}, 'b'); + $self->htmlBrowseNavigate($opt{pageurl}, $opt{options}{p}, $opt{nextpage}, 'b') if $opt{pageurl}; } |