summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--data/global.pl26
-rw-r--r--data/lang.txt43
-rw-r--r--lib/Multi/RG.pm22
-rw-r--r--lib/VNDB/Handler/VNEdit.pm15
-rw-r--r--lib/VNDB/Handler/VNPage.pm6
-rw-r--r--static/f/forms.js7
-rw-r--r--util/updates/update_2.8.sql18
8 files changed, 98 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index 9cb2bbd3..7f965f2f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
git - ?
- Converted relation graphs to use inline SVG
- Relation graphs now use the color scheme of selected skin
+ - VN relations are translatable in both the interface and the graphs
+ - Converted VN relations to an enum data type
2.7 - 2009-09-24
- Improved styling of the threeboxes layout
diff --git a/data/global.pl b/data/global.pl
index 4ab04d5b..aff1c6e1 100644
--- a/data/global.pl
+++ b/data/global.pl
@@ -46,19 +46,19 @@ our %S = (%S,
'TV Special',
'Music Video',
],
- vn_relations => [
- # Name, Reverse--
- [ 'Sequel', 0 ],
- [ 'Prequel', 1 ],
- [ 'Same setting', 0 ],
- [ 'Alternative version', 0 ],
- [ 'Shares characters', 0 ],
- [ 'Side story', 0 ],
- [ 'Parent story', 1 ],
- [ 'Same series', 0 ],
- [ 'Fandisc', 0 ],
- [ 'Original game', 1 ],
- ],
+ vn_relations => {
+ # id => [ order, reverse ]
+ seq => [ 0, 'preq' ],
+ preq => [ 1, 'seq' ],
+ set => [ 2, 'set' ],
+ alt => [ 3, 'alt' ],
+ char => [ 4, 'char' ],
+ side => [ 5, 'par' ],
+ par => [ 6, 'side' ],
+ ser => [ 7, 'ser' ],
+ fan => [ 8, 'orig' ],
+ orig => [ 9, 'fan' ],
+ },
age_ratings => {
-1 => [ 'Unknown' ],
0 => [ 'All ages' ,'CERO A' ],
diff --git a/data/lang.txt b/data/lang.txt
index e7ae5cfc..45722c42 100644
--- a/data/lang.txt
+++ b/data/lang.txt
@@ -291,6 +291,49 @@ en : Other
ru : Другая
+# VN relations
+
+:_vnrel_seq
+en : Sequel
+ru*:
+
+:_vnrel_preq
+en : Prequel
+ru*:
+
+:_vnrel_set
+en : Same setting
+ru*:
+
+:_vnrel_alt
+en : Alternative version
+ru*:
+
+:_vnrel_char
+en : Shares characters
+ru*:
+
+:_vnrel_side
+en : Side story
+ru*:
+
+:_vnrel_par
+en : Parent story
+ru*:
+
+:_vnrel_ser
+en : Same series
+ru*:
+
+:_vnrel_fan
+en : Fandisc
+ru*:
+
+:_vnrel_orig
+en : Original game
+ru*:
+
+
# producer types
:_ptype_co
diff --git a/lib/Multi/RG.pm b/lib/Multi/RG.pm
index 4ae0516e..be12fd17 100644
--- a/lib/Multi/RG.pm
+++ b/lib/Multi/RG.pm
@@ -78,8 +78,8 @@ sub getrel { # num, res, vid
$_[HEAP]{nodes}{$id} = 1;
for($_[ARG0] > 0 ? @{$_[ARG1]} : ()) {
- $_[HEAP]{rels}{$id.'-'.$_->{id}} = reverserel($_->{relation}) if $id < $_->{id};
- $_[HEAP]{rels}{$_->{id}.'-'.$id} = $_->{relation} if $id > $_->{id};
+ $_[HEAP]{rels}{$id.'-'.$_->{id}} = $VNDB::S{vn_relations}{$_->{relation}}[1] if $id < $_->{id};
+ $_[HEAP]{rels}{$_->{id}.'-'.$id} = $_->{relation} if $id > $_->{id};
if(!exists $_[HEAP]{nodes}{$_->{id}}) {
$_[HEAP]{nodes}{$_->{id}} = 0;
@@ -147,14 +147,13 @@ sub builddot { # num, res
# [older game] -> [newer game]
if($_->[4] > $_->[3]) {
($_->[0], $_->[1]) = ($_->[1], $_->[0]);
- $_->[2] = reverserel($_->[2]);
+ $_->[2] = $VNDB::S{vn_relations}{$_->[2]}[1];
}
+ my $rev = $VNDB::S{vn_relations}{$_->[2]}[1];
my $label =
- $VNDB::S{vn_relations}[$_->[2]][1]
- ? qq|headlabel = "$VNDB::S{vn_relations}[$_->[2]][0]", taillabel = "$VNDB::S{vn_relations}[$_->[2]-1][0]"| :
- $VNDB::S{vn_relations}[$_->[2]+1][1]
- ? qq|headlabel = "$VNDB::S{vn_relations}[$_->[2]][0]", taillabel = "$VNDB::S{vn_relations}[$_->[2]+1][0]"|
- : qq|label = " $VNDB::S{vn_relations}[$_->[2]][0]"|;
+ $rev ne $_->[2]
+ ? qq|headlabel = "\$____vnrel_$_->[2]____\$", taillabel = "\$____vnrel_${rev}____\$"|
+ : qq|label = "\$____vnrel_$_->[2]____\$"|;
$gv .= qq|\tv$$_[1] -- v$$_[0] [ $label ]\n|;
}
@@ -258,12 +257,5 @@ sub proc_child {
}
-
-# non-POE helper function
-sub reverserel { # relation
- return $VNDB::S{vn_relations}[$_[0]][1] ? $_[0]-1 : $VNDB::S{vn_relations}[$_[0]+1][1] ? $_[0]+1 : $_[0];
-}
-
-
1;
diff --git a/lib/VNDB/Handler/VNEdit.pm b/lib/VNDB/Handler/VNEdit.pm
index f09d6ddd..591e24a6 100644
--- a/lib/VNDB/Handler/VNEdit.pm
+++ b/lib/VNDB/Handler/VNEdit.pm
@@ -57,7 +57,7 @@ sub edit {
if(!$frm->{_err}) {
# parse and re-sort fields that have multiple representations of the same information
my $anime = { map +($_=>1), grep /^[0-9]+$/, split /[ ,]+/, $frm->{anime} };
- my $relations = [ map { /^([0-9]+),([0-9]+),(.+)$/ && (!$vid || $2 != $vid) ? [ $1, $2, $3 ] : () } split /\|\|\|/, $frm->{relations} ];
+ my $relations = [ map { /^([a-z]+),([0-9]+),(.+)$/ && (!$vid || $2 != $vid) ? [ $1, $2, $3 ] : () } split /\|\|\|/, $frm->{relations} ];
my $screenshots = [ map /^[0-9]+,[01],[0-9]+$/ ? [split /,/] : (), split / +/, $frm->{screenshots} ];
$frm->{anime} = join ' ', sort { $a <=> $b } keys %$anime;
@@ -202,7 +202,8 @@ sub _form {
td class => 'tc2';
txt ' is a ';
Select;
- option value => $_, $self->{vn_relations}[$_][0] for (0..$#{$self->{vn_relations}});
+ option value => $_, mt "_vnrel_$_"
+ for (sort { $self->{vn_relations}{$a}[0] <=> $self->{vn_relations}{$b}[0] } keys %{$self->{vn_relations}});
end;
txt ' of';
end;
@@ -250,11 +251,9 @@ sub _updreverse {
# compare %old and %new
for (keys %$old, keys %$new) {
if(exists $$old{$_} and !exists $$new{$_}) {
- $upd{$_} = -1;
- } elsif((!exists $$old{$_} and exists $$new{$_}) || ($$old{$_} != $$new{$_})) {
- $upd{$_} = $$new{$_};
- if ($self->{vn_relations}[$upd{$_} ][1]) { $upd{$_}-- }
- elsif($self->{vn_relations}[$upd{$_}+1][1]) { $upd{$_}++ }
+ $upd{$_} = undef;
+ } elsif((!exists $$old{$_} and exists $$new{$_}) || ($$old{$_} ne $$new{$_})) {
+ $upd{$_} = $self->{vn_relations}{$$new{$_}}[1];
}
}
@@ -264,7 +263,7 @@ sub _updreverse {
for my $i (keys %upd) {
my $r = $self->dbVNGet(id => $i, what => 'extended relations anime screenshots')->[0];
my @newrel = map $_->{id} != $vid ? [ $_->{relation}, $_->{id} ] : (), @{$r->{relations}};
- push @newrel, [ $upd{$i}, $vid ] if $upd{$i} != -1;
+ push @newrel, [ $upd{$i}, $vid ] if $upd{$i};
$self->dbVNEdit($i,
relations => \@newrel,
editsum => "Reverse relation update caused by revision v$vid.$rev",
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index f31b3eeb..a479bf64 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -58,6 +58,8 @@ sub rg {
$self->htmlHeader(title => $title);
*YAWF::XML::html = $sub;
+ $v->{svg} =~ s/\$___(_vnrel_[a-z]+)____\$/mt $1/eg;
+
$self->htmlMainTabs('v', $v, 'rg');
div class => 'mainbox';
h1 $title;
@@ -228,7 +230,7 @@ sub _revision {
}],
[ relations => join => '<br />', split => sub {
my @r = map sprintf('%s: <a href="/v%d" title="%s">%s</a>',
- $self->{vn_relations}[$_->{relation}][0], $_->{id}, xml_escape($_->{original}||$_->{title}), xml_escape shorten $_->{title}, 40
+ mt("_vnrel_$_->{relation}"), $_->{id}, xml_escape($_->{original}||$_->{title}), xml_escape shorten $_->{title}, 40
), sort { $a->{id} <=> $b->{id} } @{$_[0]};
return @r ? @r : (mt '_vndiff_none');
}],
@@ -295,7 +297,7 @@ sub _relations {
td class => 'relations';
dl;
for(sort keys %rel) {
- dt $self->{vn_relations}[$_][0];
+ dt mt "_vnrel_$_";
dd;
for (@{$rel{$_}}) {
a href => "/v$_->{id}", title => $_->{original}||$_->{title}, shorten $_->{title}, 40;
diff --git a/static/f/forms.js b/static/f/forms.js
index ce9daab5..8c3e4e8b 100644
--- a/static/f/forms.js
+++ b/static/f/forms.js
@@ -199,7 +199,7 @@ function relLoad() {
// fetch the relation types from the add new relation selectbox
l = x('relation_new').getElementsByTagName('select')[0].options;
for(i=0;i<l.length;i++)
- relTypes[Math.floor(l[i].value)] = l[i].text;
+ relTypes[l[i].value] = l[i].text;
// read the current relations
l = x('relations').value.split('|||');
@@ -247,7 +247,7 @@ function relAdd(rel, vid, title) {
o.appendChild(t);
var options = '';
- for(var i=0;i<relTypes.length;i++)
+ for(var i in relTypes)
options += '<option value="'+i+'"'+(i == rel ? ' selected="selected"' : '')+'>'+qq(relTypes[i])+'</option>';
t = document.createElement('td');
t.className = 'tc2';
@@ -289,10 +289,11 @@ function relSerialize() {
var l = x('relation_tbl').getElementsByTagName('tr');
for(i=0;i<l.length;i++) {
var title = l[i].getElementsByTagName('td')[0];
+ var rel = l[i].getElementsByTagName('select')[0];
title = title.innerText || title.textContent;
title = title.substr(title.indexOf(':')+1);
r += (r ? '|||' : '')
- +l[i].getElementsByTagName('select')[0].selectedIndex
+ +rel.options[rel.selectedIndex].value
+','+l[i].id.substr(12)+','+title;
}
x('relations').value = r;
diff --git a/util/updates/update_2.8.sql b/util/updates/update_2.8.sql
index a48c1e73..f9704be3 100644
--- a/util/updates/update_2.8.sql
+++ b/util/updates/update_2.8.sql
@@ -14,3 +14,21 @@ CREATE TABLE vn_graphs (
);
ALTER TABLE vn ADD FOREIGN KEY (rgraph) REFERENCES vn_graphs (id);
+
+-- VN relations stored as enum
+CREATE TYPE vn_relation AS ENUM ('seq', 'preq', 'set', 'alt', 'char', 'side', 'par', 'ser', 'fan', 'orig');
+ALTER TABLE vn_relations ALTER COLUMN relation DROP DEFAULT;
+ALTER TABLE vn_relations ALTER COLUMN relation TYPE vn_relation USING
+ CASE
+ WHEN relation = 0 THEN 'seq'::vn_relation
+ WHEN relation = 1 THEN 'preq'
+ WHEN relation = 2 THEN 'set'
+ WHEN relation = 3 THEN 'alt'
+ WHEN relation = 4 THEN 'char'
+ WHEN relation = 5 THEN 'side'
+ WHEN relation = 6 THEN 'par'
+ WHEN relation = 7 THEN 'ser'
+ WHEN relation = 8 THEN 'fan'
+ ELSE 'orig'
+ END;
+