summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormorkt <>2014-12-28 12:44:24 +0100
committerYorhel <git@yorhel.nl>2014-12-28 12:44:24 +0100
commit30acfccc74971acaf0addd521cf24bbb5221618b (patch)
tree1679224554d2e785f7504ba1f570821941985709
parent6399d6d4e21bd4464c7224f821d6ea071ea7a614 (diff)
staff: Import cast from other VN + some styling + more improvements
-rw-r--r--data/lang.txt15
-rw-r--r--data/script.js76
-rw-r--r--data/style.css18
-rw-r--r--lib/VNDB/DB/Chars.pm5
-rw-r--r--lib/VNDB/DB/Staff.pm1
-rw-r--r--lib/VNDB/DB/VN.pm17
-rw-r--r--lib/VNDB/Handler/Staff.pm109
-rw-r--r--lib/VNDB/Handler/VNEdit.pm15
-rw-r--r--lib/VNDB/Handler/VNPage.pm17
9 files changed, 188 insertions, 85 deletions
diff --git a/data/lang.txt b/data/lang.txt
index 07e30ff2..6b7ab0ae 100644
--- a/data/lang.txt
+++ b/data/lang.txt
@@ -5408,6 +5408,9 @@ en : No results found
:_staff_credits
en : Credits
+:_staff_voiced
+en : Voiced characters
+
:_staff_as
en : as [_1]
@@ -13150,6 +13153,12 @@ en : This message is a placeholder for concise guidelines regarding adding VN st
:_vnedit_cast
en : Cast
+:_vnedit_cast_import
+en : Import cast
+
+:_vnedit_cast_import_title
+en : Import character cast from related visual novels
+
:_vnedit_cast_char
en : Character
@@ -14634,6 +14643,12 @@ tr : karakter ekle
uk : додати персонажа
it : aggiungi personaggio
+:_vnpage_staff
+en : Staff
+
+:_vnpage_cast
+en : Cast of characters
+
:_vnpage_staff_add
en : add staff
diff --git a/data/script.js b/data/script.js
index 7d99566c..66520724 100644
--- a/data/script.js
+++ b/data/script.js
@@ -2142,23 +2142,27 @@ function onSubmit(form, handler) {
function vnsLoad() {
var credits = byId('credits').value.split('|||');
- var s = {}; // staff -> { aid: [ role, note ], .. }
var q = []; // list of a=X paramters
+ var s = {};
for (var i = 0; i < credits.length && credits[i].length > 1; i++) {
var c = credits[i].split('-', 3); // aid, role, note
- if (!s[c[0]])
+ if (!s[c[0]]) {
q.push('a='+c[0]);
- s[c[0]] = [ c[1], c[2] ];
+ s[c[0]] = 1;
+ }
}
if (q.length > 0)
ajax('/xml/staff.xml?'+q.join(';'), function(hs) {
var staff = hs.responseXML.getElementsByTagName('item');
+ var l = {};
for (var i = 0; i < staff.length; i++) {
var aid = staff[i].getAttribute('aid');
- if (s[aid])
- vnsAdd (staff[i], s[aid][0], s[aid][1]);
- else
- vnsAdd (staff[i], 'staff', '');
+ l[aid] = staff[i];
+ }
+ for (var i = 0; i < credits.length; i++) {
+ var c = credits[i].split('-', 3);
+ if (l[c[0]])
+ vnsAdd (l[c[0]], c[1], c[2]);
}
vnsEmpty();
}, 1);
@@ -2230,8 +2234,9 @@ function vnsSerialize() {
continue;
var aid = byName(byClass(l[i], 'tc_name')[0], 'input')[0];
var role = byName(byClass(l[i], 'tc_role')[0], 'select')[0];
- var note = byName(byClass(l[i], 'tc_note')[0], 'input')[0];
- c.push (aid.value+'-'+role.value+'-'+note.value);
+ var note = byName(byClass(l[i], 'tc_note')[0], 'input')[0].value;
+ note = note.replace(/|||+/g, '||');
+ c.push (aid.value+'-'+role.value+'-'+note);
}
byId('credits').value = c.join('|||');
return true;
@@ -2262,27 +2267,36 @@ if(byId('jt_box_vn_staff'))
function vncLoad() {
var cast = byId('seiyuu').value.split('|||');
- var s = {}; // seiyuu -> { aid: [ char, note ], .. }
var q = []; // list of a=X parameters
+ var s = {};
for (var i = 0; i < cast.length && cast[i].length > 1; i++) {
var c = cast[i].split('-', 3); // aid, char, note
- if (!s[c[0]])
+ if (!s[c[0]]) {
q.push('a='+c[0]);
- s[c[0]] = [ c[1], c[2] ];
+ s[c[0]] = 1;
+ }
}
if (q.length > 0)
ajax('/xml/staff.xml?'+q.join(';'), function(hs) {
var seiyuu = hs.responseXML.getElementsByTagName('item');
+ var s = {};
for (var i = 0; i < seiyuu.length; i++) {
var aid = seiyuu[i].getAttribute('aid');
- if (s[aid])
- vncAdd(seiyuu[i], s[aid][0], s[aid][1]);
+ s[aid] = seiyuu[i];
+ }
+ for (var i = 0; i < cast.length; i++) {
+ var c = cast[i].split('-', 3);
+ if (s[c[0]])
+ vncAdd(s[c[0]], c[1], c[2]);
}
vncEmpty();
}, 1);
else
vncEmpty();
+ var cast_import = byId('cast_import');
+ if (cast_import)
+ byName(cast_import, 'a')[0].onclick = vncImport;
onSubmit(byName(byId('maincontent'), 'form')[0], vncSerialize);
// dropdown search
@@ -2292,6 +2306,35 @@ function vncLoad() {
}, vncFormAdd);
}
+function vncImport() {
+ if (typeof vncImportData === 'undefined')
+ return false;
+ var c = {};
+ for (var i = 0; i < vncImportData.length; i++) {
+ var s = vncImportData[i];
+ c[s.cid] = s;
+ }
+ // exclude already credited cast from import list
+ var l = byName(byId('cast_tbl'), 'tr');
+ for (var i = 0; i < l.length; i++) {
+ if(l[i].id == 'cast_tr_none')
+ continue;
+ var role = byName(byClass(l[i], 'tc_char')[0], 'select')[0].value;
+ if (role in c)
+ delete c[role];
+ }
+ for (var cid in c) {
+ if (!c.hasOwnProperty(cid))
+ continue;
+ var s = document.createElement('item');
+ s.appendChild(document.createTextNode(c[cid].name));
+ s.setAttribute('id', c[cid].sid);
+ s.setAttribute('aid', c[cid].aid);
+ vncAdd(s, cid, '');
+ }
+ return false;
+}
+
function vncAdd(seiyuu, chr, note) {
var sid = seiyuu.getAttribute('id');
var aid = seiyuu.getAttribute('aid');
@@ -2357,8 +2400,9 @@ function vncSerialize() {
continue;
var aid = byName(byClass(l[i], 'tc_name')[0], 'input')[0];
var role = byName(byClass(l[i], 'tc_char')[0], 'select')[0];
- var note = byName(byClass(l[i], 'tc_note')[0], 'input')[0];
- c.push (aid.value+'-'+role.value+'-'+note.value);
+ var note = byName(byClass(l[i], 'tc_note')[0], 'input')[0].value;
+ note = note.replace(/|||+/g, '||');
+ c.push (aid.value+'-'+role.value+'-'+note);
}
byId('seiyuu').value = c.join('|||');
return true;
diff --git a/data/style.css b/data/style.css
index 77f568b8..7f717817 100644
--- a/data/style.css
+++ b/data/style.css
@@ -569,17 +569,27 @@ div.charb td.tc2 b a { color: $grayedout$!important }
div.staffbrowse { padding-bottom: 10px }
.staffbrowse ul { float: left; margin-top: -5px; margin-left: 3%; width: 28%; }
-.staffbrowse ul li { list-style-type: none; }
+.staffbrowse ul li { list-style-type: none; margin-bottom: 2px; }
.staffbrowse ul li acronym { margin-right: 5px; margin-top: 1px; }
-div.staffinfo { position: relative; float: left; margin-right: 3%; }
-div.staffdesc { margin-bottom: 10px; }
+.staffinfo { position: relative; float: left; margin-right: 3%; margin-bottom: 20px; }
+.staffinfo acronym { vertical-align: bottom; }
+.staffdesc h2, .staffroles h2 { margin: 0; padding: 5px 0; }
+.staffdesc { display: table; margin-bottom: 10px; padding: 0 5px; }
+.staffroles { padding: 0 5px; }
+.staffroles td { white-space: nowrap; padding-left: 20px; padding-right: 20px; }
+
+
+/***** Staff display *****/
+
+div.staff td { white-space: nowrap; padding-left: 20px; padding-right: 20px; }
/***** Staff edit *****/
+#jt_box_vn_cast #cast_import { clear: right; float: right; }
#jt_box_vn_cast table,
#jt_box_vn_staff table,
-#jt_box_staffe_aliases table { margin-bottom: 10px; }
+#jt_box_staffe_aliases table { margin-bottom: 10px; margin-left: 20px }
#jt_box_vn_cast h2,
#jt_box_vn_staff h2,
#jt_box_staffe_aliases h2 { margin: 0 0 3px 0px; }
diff --git a/lib/VNDB/DB/Chars.pm b/lib/VNDB/DB/Chars.pm
index a7dfb692..50923941 100644
--- a/lib/VNDB/DB/Chars.pm
+++ b/lib/VNDB/DB/Chars.pm
@@ -111,12 +111,11 @@ sub dbCharGet {
if($o{what} =~ /seiyuu/) {
push @{$r{ delete $_->{cid} }{seiyuu}}, $_ for (@{$self->dbAll(q|
- SELECT cr.id AS cid, sr.sid, sa.name, sa.original, vs.note, v.id AS vid, vr.title AS vntitle
+ SELECT cr.id AS cid, s.id AS sid, sa.name, sa.original, vs.note, v.id AS vid, vr.title AS vntitle
FROM vn_seiyuu vs
JOIN chars_rev cr ON cr.cid = vs.cid
JOIN staff_alias sa ON sa.id = vs.aid
- JOIN staff_rev sr ON sr.id = sa.rid
- JOIN staff s ON sr.id = s.latest
+ JOIN staff s ON sa.rid = s.latest
JOIN vn_rev vr ON vr.id = vs.vid
JOIN vn v ON v.latest = vs.vid
!W
diff --git a/lib/VNDB/DB/Staff.pm b/lib/VNDB/DB/Staff.pm
index 1c9438a0..798200f6 100644
--- a/lib/VNDB/DB/Staff.pm
+++ b/lib/VNDB/DB/Staff.pm
@@ -76,6 +76,7 @@ sub dbStaffGet {
JOIN vn_rev vr ON vr.id = vs.vid
JOIN vn v ON v.latest = vr.id
JOIN chars_rev cr ON cr.cid = vs.cid
+ JOIN chars c ON c.latest = cr.id
JOIN staff_alias sa ON vs.aid = sa.id
WHERE sa.rid IN(!l)
ORDER BY v.c_released ASC, vr.title ASC|, [ keys %r ]
diff --git a/lib/VNDB/DB/VN.pm b/lib/VNDB/DB/VN.pm
index 97fc3086..edb55377 100644
--- a/lib/VNDB/DB/VN.pm
+++ b/lib/VNDB/DB/VN.pm
@@ -7,7 +7,7 @@ use Exporter 'import';
use VNDB::Func 'gtintype', 'normalize_query';
use Encode 'decode_utf8';
-our @EXPORT = qw|dbVNGet dbVNRevisionInsert dbVNImageId dbScreenshotAdd dbScreenshotGet dbScreenshotRandom dbVNHasChar dbVNHasStaff|;
+our @EXPORT = qw|dbVNGet dbVNRevisionInsert dbVNImageId dbScreenshotAdd dbScreenshotGet dbScreenshotRandom dbVNHasChar dbVNHasStaff dbVNImportSeiyuu|;
# Options: id, rev, char, search, length, lang, olang, plat, tag_inc, tag_exc, tagspoil,
@@ -342,5 +342,20 @@ sub dbVNHasStaff {
}
+# returns seiyuus that voice characters referenced by $cids in VNs other than $vid
+sub dbVNImportSeiyuu {
+ my($self, $vid, $cids) = @_;
+ return $self->dbAll(q|
+ SELECT DISTINCT ON(cr.cid) cr.cid, cr.name AS c_name, s.id AS sid, sa.id AS aid, sa.name
+ FROM vn_seiyuu vs
+ JOIN vn v ON v.latest = vs.vid
+ JOIN chars c ON c.id = vs.cid
+ JOIN chars_rev cr ON cr.id = c.latest
+ JOIN staff_alias sa ON sa.id = vs.aid
+ JOIN staff s ON sa.rid = s.latest
+ WHERE vs.cid IN(!l) AND v.id <> ?|, $cids, $vid);
+}
+
+
1;
diff --git a/lib/VNDB/Handler/Staff.pm b/lib/VNDB/Handler/Staff.pm
index 45aaa574..06905251 100644
--- a/lib/VNDB/Handler/Staff.pm
+++ b/lib/VNDB/Handler/Staff.pm
@@ -48,13 +48,13 @@ sub page {
);
}
- div class => 'mainbox';
+ 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';
- txt $s->{original} if $s->{original};
end;
# info table
@@ -102,61 +102,62 @@ sub page {
end;
}
- if (@{$s->{roles}} || @{$s->{cast}}) {
- div class => 'staffroles';
- if (@{$s->{roles}}) {
- table class => 'stripe';
- thead;
- Tr;
- td class => 'tc1', mt '_staff_col_role';
- td class => 'tc2', mt '_staff_col_title';
- td class => 'tc3', mt '_staff_col_released';
- td class => 'tc4', mt '_staff_col_note';
- end;
+ div class => 'staffroles';
+ if (@{$s->{roles}}) {
+ h2 mt '_staff_credits';
+ table class => 'stripe';
+ thead;
+ Tr;
+ td class => 'tc1', mt '_staff_col_role';
+ td class => 'tc2', mt '_staff_col_title';
+ td class => 'tc3', mt '_staff_col_released';
+ td class => 'tc4', mt '_staff_col_note';
end;
- tbody;
- foreach my $r (@{$s->{roles}}) {
- Tr;
- td class => 'tc1', mt '_credit_'.$r->{role};
- td class => 'tc2'; a href => "/v$r->{vid}", title => $r->{t_original}, $r->{title}; end;
- td class => 'tc3'; lit $self->{l10n}->datestr($r->{c_released}); end;
- td class => 'tc4';
- lit '('.mt('_staff_as', $r->{name}).') ' if $r->{name} ne $s->{name};
- lit $r->{note};
- end;
+ end;
+ tbody;
+ foreach my $r (@{$s->{roles}}) {
+ Tr;
+ td class => 'tc1', mt '_credit_'.$r->{role};
+ td class => 'tc2'; a href => "/v$r->{vid}", title => $r->{t_original}, $r->{title}; end;
+ td class => 'tc3'; lit $self->{l10n}->datestr($r->{c_released}); end;
+ td class => 'tc4';
+ txt '('.mt('_staff_as', $r->{name}).') ' if $r->{name} ne $s->{name};
+ txt $r->{note};
end;
- }
- end;
+ end;
+ }
end;
- }
- if (@{$s->{cast}}) {
- table class => 'stripe';
- thead;
- Tr;
- td class => 'tc1', mt '_staff_col_cast';
- td class => 'tc2', mt '_staff_col_title';
- td class => 'tc3', mt '_staff_col_released';
- td class => 'tc4', mt '_staff_col_note';
- end;
+ end;
+ br;
+ }
+ if (@{$s->{cast}}) {
+ h2 mt '_staff_voiced';
+ table class => 'stripe';
+ thead;
+ Tr;
+ td class => 'tc1', mt '_staff_col_cast';
+ td class => 'tc2', mt '_staff_col_title';
+ td class => 'tc3', mt '_staff_col_released';
+ td class => 'tc4', mt '_staff_col_note';
end;
- tbody;
- foreach my $r (@{$s->{cast}}) {
- Tr;
- td class => 'tc1'; a href => "/c$r->{cid}", $r->{c_name}; end;
- td class => 'tc2'; a href => "/v$r->{vid}", title => $r->{t_original}, $r->{title}; end;
- td class => 'tc3'; lit $self->{l10n}->datestr($r->{c_released}); end;
- td class => 'tc4';
- lit '('.mt('_staff_as', $r->{name}).') ' if $r->{name} ne $s->{name};
- lit $r->{note};
- end;
+ end;
+ tbody;
+ foreach my $r (@{$s->{cast}}) {
+ Tr;
+ td class => 'tc1'; a href => "/c$r->{cid}", title => $r->{c_original}, $r->{c_name}; end;
+ td class => 'tc2'; a href => "/v$r->{vid}", title => $r->{t_original}, $r->{title}; end;
+ td class => 'tc3'; lit $self->{l10n}->datestr($r->{c_released}); end;
+ td class => 'tc4';
+ txt '('.mt('_staff_as', $r->{name}).') ' if $r->{name} ne $s->{name};
+ txt $r->{note};
end;
- }
- end;
+ end;
+ }
end;
- }
- end;
- }
- clearfloat;
+ end;
+ }
+ end;
+ clearfloat;
end;
$self->htmlFooter;
@@ -222,7 +223,7 @@ sub edit {
$self->htmlHeader(title => $title, noindex => 1);
$self->htmlMainTabs('s', $s, 'edit') if $s;
$self->htmlEditMessage('s', $s, $title);
- $self->htmlForm({ frm => $frm, action => $s ? "/s$sid/edit" : '/s/new', editsum => 1, upload => 1 },
+ $self->htmlForm({ frm => $frm, action => $s ? "/s$sid/edit" : '/s/new', editsum => 1 },
staffe_geninfo => [ mt('_staffe_form_generalinfo'),
[ hidden => short => 'aid' ],
[ input => name => mt('_staffe_form_name'), short => 'name' ],
@@ -312,8 +313,8 @@ sub list {
for ($perlist*$c..($perlist*($c+1))-1) {
li;
my $gender = $list->[$_]{gender};
- cssicon "gen $gender", mt "_gender_$gender" if $gender ne 'unknown';
-# cssicon 'lang '.$list->[$_]{lang}, mt "_lang_$list->[$_]{lang}";
+# cssicon "gen $gender", mt "_gender_$gender" if $gender ne 'unknown';
+ cssicon 'lang '.$list->[$_]{lang}, mt "_lang_$list->[$_]{lang}";
a href => "/s$list->[$_]{id}",
title => $list->[$_]{original}, $list->[$_]{name};
end;
diff --git a/lib/VNDB/Handler/VNEdit.pm b/lib/VNDB/Handler/VNEdit.pm
index bd98b941..963e8ce2 100644
--- a/lib/VNDB/Handler/VNEdit.pm
+++ b/lib/VNDB/Handler/VNEdit.pm
@@ -309,6 +309,21 @@ sub _form {
$chars && @{$chars} ? (vn_cast => [ mt('_vnedit_cast'),
[ hidden => short => 'seiyuu' ],
[ static => nolabel => 1, content => sub {
+ my $import = $self->dbVNImportSeiyuu($v->{id}, [ map $_->{id}, @$chars ]);
+ if (@$import) {
+ script type => 'text/javascript';
+ lit 'var vncImportData = [';
+ lit join ',', map {
+ my $name = $_->{name};
+ $name =~ s/["\\]/\\$&/g; # escape quotes in names
+ sprintf('{cid:%d,sid:%d,aid:%d,name:"%s"}', $_->{cid}, $_->{sid}, $_->{aid}, $name);
+ } @$import;
+ lit '];';
+ end;
+ div id => 'cast_import';
+ a href => '#', title => mt('_vnedit_cast_import_title'), mt '_vnedit_cast_import';
+ end;
+ }
table; tbody id => 'cast_tbl';
Tr id => 'cast_loading'; td colspan => '4', mt '_js_loading'; end;
end; end;
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index 2c1563e1..ddf605f4 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -1099,8 +1099,9 @@ sub _chars {
sub _staff {
my ($self, $v) = @_;
- div class => 'mainbox';
- if(@{$v->{credits}}) {
+ if(@{$v->{credits}}) {
+ div class => 'mainbox staff';
+ h1 mt '_vnpage_staff';
my $has_notes = grep { $_->{note} } @{$v->{credits}};
table class => 'stripe';
thead;
@@ -1122,9 +1123,11 @@ sub _staff {
$last_role = $s->{role};
}
end 'table';
- br;
- }
- if(@{$v->{seiyuu}}) {
+ end;
+ }
+ if(@{$v->{seiyuu}}) {
+ div class => 'mainbox staff cast';
+ h1 mt '_vnpage_cast';
my $has_notes = grep { $_->{note} } @{$v->{seiyuu}};
table class => 'stripe';
thead;
@@ -1146,8 +1149,8 @@ sub _staff {
end;
}
end 'table';
- }
- end;
+ end;
+ }
}