summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Multi/API.pm22
-rw-r--r--lib/VNDB/ExtLinks.pm2
2 files changed, 21 insertions, 3 deletions
diff --git a/lib/Multi/API.pm b/lib/Multi/API.pm
index cb2999b7..8a99ddac 100644
--- a/lib/Multi/API.pm
+++ b/lib/Multi/API.pm
@@ -20,6 +20,7 @@ use VNDB::Types;
use VNDB::Config;
use JSON::XS;
use PWLookup;
+use VNDB::ExtLinks 'sql_extlinks';
# Linux-specific, not exported by the Socket module.
sub TCP_KEEPIDLE () { 4 }
@@ -714,7 +715,8 @@ my %GET_RELEASE = (
]
},
lang => {
- fetch => [[ 'id', 'SELECT id, lang, title, latin, mtl FROM releases_titles WHERE id IN(%s)',
+ fetch => [[ 'id', 'SELECT rt.id, rt.lang, rt.title, rt.latin, rt.mtl, rt.lang = r.olang AS main
+ FROM releases_titles rt JOIN releases r ON r.id = rt.id WHERE rt.id IN(%s)',
sub { my($r, $n) = @_;
for my $i (@$r) {
$i->{lang} = [ grep $i->{id} eq $_->{id}, @$n ];
@@ -722,6 +724,7 @@ my %GET_RELEASE = (
for (@$n) {
delete $_->{id};
$_->{mtl} = $_->{mtl} =~ /t/ ? TRUE : FALSE,
+ $_->{main} = $_->{main} =~ /t/ ? TRUE : FALSE,
}
}
]],
@@ -757,7 +760,22 @@ my %GET_RELEASE = (
}
}
]],
- }
+ },
+ links => {
+ select => sql_extlinks('r'),
+ proc => sub {
+ my($e) = @_;
+ $e->{links} = [];
+ for my $l (keys $VNDB::ExtLinks::LINKS{r}->%*) {
+ my $i = $VNDB::ExtLinks::LINKS{r}{$l};
+ my $v = $e->{$l};
+ push $e->{links}->@*,
+ map +{ label => $i->{label}, url => sprintf($i->{fmt}, $_) },
+ !$v || $v eq '{}' ? () : $v =~ /^{(.+)}$/ ? split /,/, $1 : ($v);
+ delete $e->{$l};
+ }
+ },
+ },
},
filters => {
id => [
diff --git a/lib/VNDB/ExtLinks.pm b/lib/VNDB/ExtLinks.pm
index 202afe3e..ffca7a7b 100644
--- a/lib/VNDB/ExtLinks.pm
+++ b/lib/VNDB/ExtLinks.pm
@@ -204,7 +204,7 @@ sub sql_extlinks {
my($type, $prefix) = @_;
$prefix ||= '';
my $l = $LINKS{$type} || die "DB entry type $type has no links";
- VNWeb::DB::sql_comma(map $prefix.$_, sort keys %$l)
+ join ',', map $prefix.$_, sort keys %$l
}