diff options
author | Yorhel <git@yorhel.nl> | 2021-05-14 12:29:49 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2021-05-14 12:34:37 +0200 |
commit | ba6ff4ee302fada4e838d6f3c64a79536e8cfb26 (patch) | |
tree | eec46b25603f0fd24ba0e759f53670c7cbd721a7 /lib/VNWeb/Releases | |
parent | 92ef4761c5212c579c093631576717614af3992b (diff) |
Releases: Add MTL language flag
Fixes https://vndb.org/t7126
And as recently discussed again in https://vndb.org/t15635
Diffstat (limited to 'lib/VNWeb/Releases')
-rw-r--r-- | lib/VNWeb/Releases/Edit.pm | 5 | ||||
-rw-r--r-- | lib/VNWeb/Releases/Lib.pm | 18 | ||||
-rw-r--r-- | lib/VNWeb/Releases/List.pm | 2 | ||||
-rw-r--r-- | lib/VNWeb/Releases/Page.pm | 14 | ||||
-rw-r--r-- | lib/VNWeb/Releases/VNTab.pm | 12 |
5 files changed, 32 insertions, 19 deletions
diff --git a/lib/VNWeb/Releases/Edit.pm b/lib/VNWeb/Releases/Edit.pm index ffc8a3b9..975cd3b2 100644 --- a/lib/VNWeb/Releases/Edit.pm +++ b/lib/VNWeb/Releases/Edit.pm @@ -12,7 +12,10 @@ my $FORM = { patch => { anybool => 1 }, freeware => { anybool => 1 }, doujin => { anybool => 1 }, - lang => { aoh => { lang => { enum => \%LANGUAGE } } }, + lang => { minlength => 1, sort_keys => 'lang', aoh => { + lang => { enum => \%LANGUAGE }, + mtl => { anybool => 1 }, + } }, platforms => { aoh => { platform => { enum => \%PLATFORM } } }, media => { aoh => { medium => { enum => \%MEDIUM }, diff --git a/lib/VNWeb/Releases/Lib.pm b/lib/VNWeb/Releases/Lib.pm index e14933e5..e5e46846 100644 --- a/lib/VNWeb/Releases/Lib.pm +++ b/lib/VNWeb/Releases/Lib.pm @@ -28,8 +28,8 @@ sub enrich_release { my($r) = @_; enrich_merge id => 'SELECT id, title, original, notes, minage, official, freeware, doujin, reso_x, reso_y, voiced, ani_story, ani_ero, uncensored FROM releases WHERE id IN', $r; enrich_merge id => sql('SELECT rid as id, status as rlist_status FROM rlists WHERE uid =', \auth->uid, 'AND rid IN'), $r if auth; - enrich_flatten lang => id => id => sub { sql 'SELECT id, lang FROM releases_lang WHERE id IN', $_, 'ORDER BY id, lang' }, $r; enrich_flatten platforms => id => id => sub { sql 'SELECT id, platform FROM releases_platforms WHERE id IN', $_, 'ORDER BY id, platform' }, $r; + enrich lang => id => id => sub { 'SELECT id, lang, mtl FROM releases_lang WHERE id IN', $_, 'ORDER BY id, mtl, lang' }, $r; enrich media => id => id => sub { 'SELECT id, medium, qty FROM releases_media WHERE id IN', $_, 'ORDER BY id, medium' }, $r; } @@ -70,11 +70,15 @@ sub release_extlinks_ { # Options # id: unique identifier if the same release may be listed on a page twice. -# lang: 0/1 whether to display language icons +# lang: $lang, whether to display language icons and which language to use for the MTL flag. # prod: 0/1 whether to display Pub/Dev indication sub release_row_ { my($r, $opt) = @_; + my $mtl = $opt->{lang} + ? [grep $_->{lang} eq $opt->{lang}, $r->{lang}->@*]->[0]{mtl} + : (grep $_->{mtl}, $r->{lang}->@*) == $r->{lang}->@*; + my sub icon_ { my($img, $label, $class) = @_; $class = $class ? " release_icon_$class" : ''; @@ -102,19 +106,19 @@ sub release_row_ { icon_ 'notes', bb_format $r->{notes}, text => 1 if $r->{notes}; } - tr_ sub { - td_ class => 'tc1', sub { rdate_ $r->{released} }; + tr_ $mtl ? (class => 'mtl') : (), sub { + td_ class => 'tc1', sub { rdate_ [grep $_->{lang} eq $opt->{lang}, $opt->{lang}?$r->{lang}->@*:()]->[0]{released}//$r->{released} }; td_ class => 'tc2', defined $r->{minage} ? minage $r->{minage} : ''; td_ class => 'tc3', sub { platform_ $_ for $r->{platforms}->@*; - if($opt->{lang}) { - abbr_ class => "icons lang $_", title => $LANGUAGE{$_}, '' for $r->{lang}->@*; + if(!$opt->{lang}) { + abbr_ class => "icons lang $_->{lang}".($_->{mtl}?' mtl':''), title => $LANGUAGE{$_->{lang}}, '' for $r->{lang}->@*; } abbr_ class => "icons rt$r->{type}", title => $r->{type}, ''; }; td_ class => 'tc4', sub { a_ href => "/$r->{id}", title => $r->{original}||$r->{title}, $r->{title}; - my $note = join ' ', $r->{official} ? () : 'unofficial', $r->{patch} ? 'patch' : (); + my $note = join ' ', $r->{official} ? () : 'unofficial', $mtl ? 'machine translation' : (), $r->{patch} ? 'patch' : (); b_ class => 'grayedout', " ($note)" if $note; }; td_ class => 'tc_icons', sub { icons_ $r }; diff --git a/lib/VNWeb/Releases/List.pm b/lib/VNWeb/Releases/List.pm index c3f07e78..70deb40a 100644 --- a/lib/VNWeb/Releases/List.pm +++ b/lib/VNWeb/Releases/List.pm @@ -22,7 +22,7 @@ sub listing_ { td_ class => 'tc5', ''; td_ class => 'tc6', ''; } }; - my $ropt = { id => '', lang => 1 }; + my $ropt = { id => '' }; release_row_ $_, $ropt for @$list; } }; diff --git a/lib/VNWeb/Releases/Page.pm b/lib/VNWeb/Releases/Page.pm index 36d2f383..49374167 100644 --- a/lib/VNWeb/Releases/Page.pm +++ b/lib/VNWeb/Releases/Page.pm @@ -9,7 +9,7 @@ sub enrich_item { enrich_merge pid => 'SELECT id AS pid, name, original FROM producers WHERE id IN', $r->{producers}; enrich_merge vid => 'SELECT id AS vid, title, original FROM vn WHERE id IN', $r->{vn}; - $r->{lang} = [ sort map $_->{lang}, $r->{lang}->@* ]; + $r->{lang} = [ sort { ($a->{mtl}?1:0) <=> ($b->{mtl}?1:0) || $a->{lang} cmp $b->{lang} } $r->{lang}->@* ]; $r->{platforms} = [ sort map $_->{platform}, $r->{platforms}->@* ]; $r->{vn} = [ sort { $a->{title} cmp $b->{title} || idcmp($a->{vid}, $b->{vid}) } $r->{vn}->@* ]; $r->{producers} = [ sort { $a->{name} cmp $b->{name} || idcmp($a->{pid}, $b->{pid}) } $r->{producers}->@* ]; @@ -33,7 +33,7 @@ sub _rev_ { [ original => 'Original title' ], [ gtin => 'JAN/EAN/UPC', empty => 0 ], [ catalog => 'Catalog number' ], - [ lang => 'Languages', fmt => \%LANGUAGE ], + [ lang => 'Languages', fmt => sub { txt_ $LANGUAGE{$_->{lang}}; txt_ ' (machine translation)' if $_->{mtl} } ], [ released => 'Release date', fmt => sub { rdate_ $_ } ], [ minage => 'Age rating', fmt => sub { txt_ minage $_ } ], [ notes => 'Notes' ], @@ -91,8 +91,14 @@ sub _infotable_ { td_ 'Language'; td_ sub { join_ \&br_, sub { - abbr_ class => "icons lang $_", title => $LANGUAGE{$_}, ' '; - txt_ ' '.$LANGUAGE{$_}; + abbr_ class => "icons lang $_->{lang}", title => $LANGUAGE{$_->{lang}}, ' '; + txt_ ' '; + if($_->{mtl}) { + b_ class => 'grayedout', $LANGUAGE{$_->{lang}}; + txt_ ' (machine translation)'; + } else { + txt_ $LANGUAGE{$_->{lang}}; + } }, $r->{lang}->@*; } }; diff --git a/lib/VNWeb/Releases/VNTab.pm b/lib/VNWeb/Releases/VNTab.pm index 604f2415..a35f0d6c 100644 --- a/lib/VNWeb/Releases/VNTab.pm +++ b/lib/VNWeb/Releases/VNTab.pm @@ -43,7 +43,7 @@ my @rel_cols = ( button_string => 'Language', default => 1, has_data => sub { !!@{$_[0]{lang}} }, - draw => sub { join_ \&br_, sub { abbr_ class => "icons lang $_", title => $LANGUAGE{$_}, ''; }, $_[0]{lang}->@* }, + draw => sub { join_ \&br_, sub { abbr_ class => "icons lang $_->{lang}", title => $LANGUAGE{$_->{lang}}, ''; }, $_[0]{lang}->@* }, }, { # Publication id => 'pub', sort_field => 'publication', @@ -158,8 +158,8 @@ sub buttons_ { }; my sub pl { - my($row, $option, $txt, $icon) = @_; - my %opts = map +($_,1), map $_->{$row}->@*, @$r; + my($option, $icon, @lst) = @_; + my %opts = map +($_,1), @lst; return if !keys %opts; p_ class => 'browseopts', sub { a_ href => $url->($option, $_), $_ eq $opt->{$option} ? (class => 'optselected') : (), sub { @@ -167,8 +167,8 @@ sub buttons_ { } for ('all', sort keys %opts); } }; - pl 'platforms', 'os', \%PLATFORM, \&platform_ if $opt->{pla}; - pl 'lang', 'lang',\%LANGUAGE, sub { abbr_ class => "icons lang $_[0]", title => $LANGUAGE{$_[0]}, '' } if $opt->{lan}; + pl 'os', \&platform_, map $_->{platforms}->@*, @$r if $opt->{pla}; + pl 'lang', sub { abbr_ class => "icons lang $_[0]", title => $LANGUAGE{$_[0]}, '' }, map $_->{lang}, map $_->{lang}->@*, @$r if $opt->{lan}; } @@ -178,7 +178,7 @@ sub listing_ { # Apply language and platform filters my @r = grep + ($opt->{os} eq 'all' || ($_->{platforms} && grep $_ eq $opt->{os}, $_->{platforms}->@*)) && - ($opt->{lang} eq 'all' || ($_->{lang} && grep $_ eq $opt->{lang}, $_->{lang}->@*)), @$r; + ($opt->{lang} eq 'all' || ($_->{lang} && grep $_ eq $opt->{lang}, map $_->{lang}, $_->{lang}->@*)), @$r; # Figure out which columns to display my @col; |