summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/global.pl23
-rw-r--r--lib/Multi/Anime.pm14
-rw-r--r--lib/VNDB/Func.pm9
-rw-r--r--lib/VNDB/Handler/Tags.pm11
-rw-r--r--lib/VNDB/Handler/Users.pm3
-rw-r--r--lib/VNDB/Handler/VNEdit.pm4
-rw-r--r--lib/VNDB/Handler/VNPage.pm6
-rw-r--r--lib/VNDB/Types.pm29
-rwxr-xr-xutil/jsgen.pl2
9 files changed, 50 insertions, 51 deletions
diff --git a/data/global.pl b/data/global.pl
index 252cc9bb..2e99d049 100644
--- a/data/global.pl
+++ b/data/global.pl
@@ -65,24 +65,6 @@ our %S;
p => 'Producers',
u => 'Users',
),
- vn_lengths => [
- # name time examples
- [ 'Unknown', '', '' ],
- [ 'Very short', '< 2 hours', 'OMGWTFOTL, Jouka no Monshou, The world to reverse' ],
- [ 'Short', '2 - 10 hours', 'Narcissu, Saya no Uta, Planetarian' ],
- [ 'Medium', '10 - 30 hours', 'Yume Miru Kusuri, Cross†Channel, Crescendo' ],
- [ 'Long', '30 - 50 hours', 'Tsukihime, Ever17, Demonbane' ],
- [ 'Very long', '> 50 hours', 'Clannad, Umineko, Fate/Stay Night' ],
- ],
- anime_types => {
- tv => 'TV Series',
- ova => 'OVA',
- mov => 'Movie',
- oth => 'Other',
- web => 'Web',
- spe => 'TV Special',
- mv => 'Music Video',
- },
board_edit_time => 7*24*3600,
age_ratings => [-1, 0, 6..18],
release_types => [qw|complete partial trial|],
@@ -120,11 +102,6 @@ our %S;
'1600x900' => [ '1600x900', 'widescreen' ],
'1920x1080' => [ '1920x1080', 'widescreen' ],
),
- tag_categories => ordhash(
- cont => 'Content',
- ero => 'Sexual content',
- tech => 'Technical',
- ),
animated => [ 'Unknown', 'No animations', 'Simple animations', 'Some fully animated scenes', 'All scenes fully animated' ],
icons_story_animated => [ 'unknown', 'story_not_animated', 'story_simple_animated', 'story_some_fully_animated', 'story_all_fully_animated' ],
icons_ero_animated => [ 'unknown', 'ero_not_animated', 'ero_simple_animated', 'ero_some_fully_animated', 'ero_all_fully_animated' ],
diff --git a/lib/Multi/Anime.pm b/lib/Multi/Anime.pm
index f189286e..d286a657 100644
--- a/lib/Multi/Anime.pm
+++ b/lib/Multi/Anime.pm
@@ -11,6 +11,7 @@ use Multi::Core;
use AnyEvent::Socket;
use AnyEvent::Util;
use Encode 'decode_utf8', 'encode_utf8';
+use VNDB::Types;
sub LOGIN_ACCEPTED () { 200 }
@@ -57,17 +58,6 @@ my %C = (
lm => 0, # timestamp of last outgoing message
aid => 0, # anime ID of the last sent ANIME command
tag => int(rand()*50000),
- # anime types as returned by AniDB (lowercased)
- anime_types => {
- 'unknown' => undef, # NULL
- 'tv series' => 'tv',
- 'ova' => 'ova',
- 'movie' => 'mov',
- 'other' => 'oth',
- 'web' => 'web',
- 'tv special' => 'spe',
- 'music video' => 'mv',
- },
);
@@ -245,7 +235,7 @@ sub update_anime {
$col[1] = undef if !$col[1];
$col[2] = undef if !$col[2] || $col[2] =~ /^0,/;
$col[3] = $col[3] =~ /^([0-9]+)/ ? $1 : undef;
- $col[4] = $O{anime_types}{ lc($col[4]) };
+ ($col[4]) = grep lc($col[4]) eq lc($ANIME_TYPE{$_}{anidb}), keys %ANIME_TYPE;
$col[5] = undef if !$col[5];
$col[6] = undef if !$col[6];
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm
index fc52ef08..fbdf01d2 100644
--- a/lib/VNDB/Func.pm
+++ b/lib/VNDB/Func.pm
@@ -8,6 +8,7 @@ use Exporter 'import';
use POSIX 'strftime', 'ceil', 'floor';
use JSON::XS;
use VNDBUtil;
+use VNDB::Types;
use VNDB::BBCode;
our @EXPORT = (@VNDBUtil::EXPORT, 'bb2html', 'bb2text', qw|
clearfloat cssicon tagscore mt minage fil_parse fil_serialize parenttags
@@ -219,10 +220,10 @@ sub fmtmedia {
# Formats a VN length (xtra = 1 for time indication, 2 for examples)
sub fmtvnlen {
my($len, $xtra) = @_;
- $len = $TUWF::OBJ->{vn_lengths}[$len];
- $len->[0].
- ($xtra && $xtra == 1 && $len->[1] ? " ($len->[1])" : '').
- ($xtra && $xtra == 2 && $len->[2] ? " ($len->[2])" : '');
+ $len = $VN_LENGTH{$len};
+ $len->{txt}.
+ ($xtra && $xtra == 1 && $len->{time} ? " ($len->{time})" : '').
+ ($xtra && $xtra == 2 && $len->{example} ? " ($len->{example})" : '');
}
# Formats a UNIX timestamp as a '<number> <unit> ago' string
diff --git a/lib/VNDB/Handler/Tags.pm b/lib/VNDB/Handler/Tags.pm
index 69fc005b..51cddfef 100644
--- a/lib/VNDB/Handler/Tags.pm
+++ b/lib/VNDB/Handler/Tags.pm
@@ -6,6 +6,7 @@ use strict;
use warnings;
use TUWF ':html', ':xml', 'xml_escape';
use VNDB::Func;
+use VNDB::Types;
TUWF::register(
@@ -99,7 +100,7 @@ sub tagpage {
p class => 'center';
b 'Category';
br;
- txt $self->{tag_categories}{$t->{cat}};
+ txt $TAG_CATEGORY{$t->{cat}};
end;
if(@{$t->{aliases}}) {
p class => 'center';
@@ -167,7 +168,7 @@ sub tagedit {
$frm = $self->formValidate(
{ post => 'name', required => 1, maxlength => 250, regex => [ qr/^[^,]+$/, 'A comma is not allowed in tag names' ] },
{ post => 'state', required => 0, default => 0, enum => [ 0..2 ] },
- { post => 'cat', required => 1, enum => [ keys %{$self->{tag_categories}} ] },
+ { post => 'cat', required => 1, enum => [ keys %TAG_CATEGORY ] },
{ post => 'catrec', required => 0 },
{ post => 'searchable', required => 0, default => 0 },
{ post => 'applicable', required => 0, default => 0 },
@@ -259,7 +260,7 @@ sub tagedit {
[ checkbox => short => 'applicable', name => 'Applicable (people can apply this tag to VNs)' ],
) : (),
[ select => short => 'cat', name => 'Category', options => [
- map [$_, $self->{tag_categories}{$_}], keys %{$self->{tag_categories}} ] ],
+ map [$_, $TAG_CATEGORY{$_}], keys %TAG_CATEGORY ] ],
$self->authCan('tagmod') && $tag ? (
[ checkbox => short => 'catrec', name => 'Also edit all child tags to have this category' ],
[ static => content => 'WARNING: This will overwrite the category field for all child tags, this action can not be reverted!' ],
@@ -622,11 +623,11 @@ sub _tagmod_list {
my %my = map +($_->{tag} => $_), @$my;
- for my $cat (keys %{$self->{tag_categories}}) {
+ for my $cat (keys %TAG_CATEGORY) {
my @tags = grep $_->{cat} eq $cat, @$tags;
next if !@tags;
Tr class => 'tagmod_cat';
- td colspan => 7, $self->{tag_categories}{$cat};
+ td colspan => 7, $TAG_CATEGORY{$cat};
end;
for my $t (@tags) {
my $m = $my{$t->{id}};
diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm
index 00f0d841..09f148d5 100644
--- a/lib/VNDB/Handler/Users.pm
+++ b/lib/VNDB/Handler/Users.pm
@@ -5,6 +5,7 @@ use strict;
use warnings;
use TUWF ':html', 'xml_escape';
use VNDB::Func;
+use VNDB::Types;
use POSIX 'floor';
use PWLookup;
@@ -530,7 +531,7 @@ sub edit {
[ check => short => 'traits_sexual', name => 'Show sexual traits by default on character pages.' ],
[ check => short => 'tags_all', name => 'Show all tags by default on visual novel pages.' ],
[ select => short => 'tags_cat', name => 'Tag categories', multi => 1, size => 3,
- options => [ map [ $_, $self->{tag_categories}{$_} ], keys %{$self->{tag_categories}} ] ],
+ options => [ map [ $_, $TAG_CATEGORY{$_} ], keys %TAG_CATEGORY ] ],
[ select => short => 'spoilers', name => 'Spoiler level', options => [
[0, 'Hide spoilers'], [1, 'Show only minor spoilers'], [2, 'Show all spoilers'] ]],
[ select => short => 'skin', name => 'Preferred skin', width => 300, options => [
diff --git a/lib/VNDB/Handler/VNEdit.pm b/lib/VNDB/Handler/VNEdit.pm
index bbf1f545..98b4221e 100644
--- a/lib/VNDB/Handler/VNEdit.pm
+++ b/lib/VNDB/Handler/VNEdit.pm
@@ -120,7 +120,7 @@ sub edit {
{ post => 'original', required => 0, maxlength => 250, default => '' },
{ post => 'alias', required => 0, maxlength => 500, default => '' },
{ post => 'desc', required => 0, default => '', maxlength => 10240 },
- { post => 'length', required => 0, default => 0, enum => [ 0..$#{$self->{vn_lengths}} ] },
+ { post => 'length', required => 0, default => 0, enum => [ keys %VN_LENGTH ] },
{ post => 'l_renai', required => 0, default => '', maxlength => 100 },
{ post => 'l_wikidata', required => 0, template => 'wikidata' },
{ post => 'anime', required => 0, default => '' },
@@ -270,7 +270,7 @@ sub _form {
'Short description of the main story. Please do not include spoilers, and don\'t forget to list'
.' the source in case you didn\'t write the description yourself. Formatting codes are allowed.' ],
[ select => short => 'length', name => 'Length', width => 450, options =>
- [ map [ $_ => fmtvnlen $_, 2 ], 0..$#{$self->{vn_lengths}} ] ],
+ [ map [ $_ => fmtvnlen $_, 2 ], keys %VN_LENGTH ] ],
[ input => short => 'l_wikidata',name => 'Wikidata ID',
pre => 'https://www.wikidata.org/wiki/',
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index 614ae166..a7988df8 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -457,9 +457,9 @@ sub page {
if(@$t) {
div id => 'tagops';
my $tags_cat = $self->authPref('tags_cat') || $self->{default_tags_cat};
- for (keys %{$self->{tag_categories}}) {
+ for (keys %TAG_CATEGORY) {
input id => "cat_$_", type => 'checkbox', class => 'visuallyhidden', $tags_cat =~ /\Q$_/ ? (checked => 'checked') : ();
- label for => "cat_$_", lc $self->{tag_categories}{$_};
+ label for => "cat_$_", lc $TAG_CATEGORY{$_};
}
my $spoiler = $self->authPref('spoilers') || 0;
input id => 'tag_spoil_none', type => 'radio', class => 'visuallyhidden', name => 'tag_spoiler', $spoiler == 0 ? (checked => 'checked') : ();
@@ -694,7 +694,7 @@ sub _anime {
txt '] ';
end;
abbr title => $_->{title_kanji}||$_->{title_romaji}, shorten $_->{title_romaji}, 50;
- b ' ('.(defined $_->{type} ? $self->{anime_types}{$_->{type}}.', ' : '').$_->{year}.')';
+ b ' ('.(defined $_->{type} ? $ANIME_TYPE{$_->{type}}.', ' : '').$_->{year}.')';
br;
}
}
diff --git a/lib/VNDB/Types.pm b/lib/VNDB/Types.pm
index aa642762..21ef2425 100644
--- a/lib/VNDB/Types.pm
+++ b/lib/VNDB/Types.pm
@@ -150,6 +150,35 @@ hash CREDIT_TYPE =>
+hash VN_LENGTH =>
+ 0 => { txt => 'Unknown', time => '', example => '' },
+ 1 => { txt => 'Very short', time => '< 2 hours', example => 'OMGWTFOTL, Jouka no Monshou, The world to reverse' },
+ 2 => { txt => 'Short', time => '2 - 10 hours', example => 'Narcissu, Saya no Uta, Planetarian' },
+ 3 => { txt => 'Medium', time => '10 - 30 hours', example => 'Yume Miru Kusuri, Cross†Channel, Crescendo' },
+ 4 => { txt => 'Long', time => '30 - 50 hours', example => 'Tsukihime, Ever17, Demonbane' },
+ 5 => { txt => 'Very long', time => '> 50 hours', example => 'Clannad, Umineko, Fate/Stay Night' };
+
+
+
+# SQL: ENUM anime_type
+hash ANIME_TYPE => # anidb = what the UDP API returns, lowercased
+ tv => { txt => 'TV Series', anidb => 'tv series' },
+ ova => { txt => 'OVA', anidb => 'ova' },
+ mov => { txt => 'Movie', anidb => 'movie' },
+ oth => { txt => 'Other', anidb => 'other' },
+ web => { txt => 'Web', anidb => 'web' },
+ spe => { txt => 'TV Special', anidb => 'tv special' },
+ mv => { txt => 'Music Video', anidb => 'music video' };
+
+
+
+# SQL: ENUM tag_category
+hash TAG_CATEGORY =>
+ cont => 'Content',
+ ero => 'Sexual content',
+ tech => 'Technical';
+
+
hash WISHLIST_STATUS =>
0 => 'High',
diff --git a/util/jsgen.pl b/util/jsgen.pl
index 8c44fb99..04b4780a 100755
--- a/util/jsgen.pl
+++ b/util/jsgen.pl
@@ -46,7 +46,7 @@ sub vars {
release_types => [ map [ $_, ucfirst $_ ], @{$S{release_types}} ],
animated => [ map [ $_, $S{animated}[$_] ], 0..$#{$S{animated}} ],
voiced => [ map [ $_, $S{voiced}[$_] ], 0..$#{$S{voiced}} ],
- vn_lengths => [ map [ $_, $S{vn_lengths}[$_][0] ], 0..$#{$S{vn_lengths}} ],
+ vn_lengths => [ map [ $_, $VN_LENGTH{$_}{txt} ], keys %VN_LENGTH ],
blood_types => [ map [ $_, $BLOOD_TYPE{$_} ], keys %BLOOD_TYPE ],
genders => [ map [ $_, $GENDER{$_} ], keys %GENDER ],
credit_type => [ map [ $_, $CREDIT_TYPE{$_} ], keys %CREDIT_TYPE ],