diff options
author | Yorhel <git@yorhel.nl> | 2019-11-12 20:15:32 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-11-12 20:19:55 +0100 |
commit | 06bacb61526f3945520dd344821d2aa7b85a5f43 (patch) | |
tree | 81e7469ab7ac1c1e3e2a80f79cf49022083f89b6 /lib/VNDB/Handler/VNPage.pm | |
parent | e525c5fb92612e5459ab04b1c010fb88a3dfa22a (diff) |
v2rw: Move entryLinks() into separate VNDB::ExtLinks module
This is yak shaving. The new module doesn't have much value as it is,
apart from having a central place to define link formats. This new
enrich_extlinks() approach is also a bit more efficient in that it can
avoid separate SQL queries for multiple objects.
But the real reason for these changes is that I can use that %LINKS hash
table to automatically generate the links part in the edit summary and
it should (hopefully) also be useful to generate a more
convenient/streamlined Elm edit form.
Diffstat (limited to 'lib/VNDB/Handler/VNPage.pm')
-rw-r--r-- | lib/VNDB/Handler/VNPage.pm | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm index e1e37f2f..4255a221 100644 --- a/lib/VNDB/Handler/VNPage.pm +++ b/lib/VNDB/Handler/VNPage.pm @@ -6,6 +6,7 @@ use warnings; use TUWF ':html', 'xml_escape'; use VNDB::Func; use VNDB::Types; +use VNDB::ExtLinks; use List::Util 'min'; use POSIX 'strftime'; @@ -341,6 +342,9 @@ sub page { my $r = $self->dbReleaseGet(vid => $vid, what => 'extended links vns producers platforms media', results => 200); + enrich_extlinks v => $v; + enrich_extlinks r => $r; + my $metadata = { 'og:title' => $v->{title}, 'og:description' => bb2text $v->{desc}, @@ -422,14 +426,13 @@ sub page { _producers($self, $r); _relations($self, $v) if @{$v->{relations}}; - my $links = $self->entryLinks(v => $v); - if(@$links) { + if($v->{extlinks}->@*) { Tr; td 'Links'; td; - for(@$links) { + for($v->{extlinks}->@*) { a href => $_->[1], $_->[0]; - txt ', ' if $_ ne $links->[$#$links]; + txt ', ' if $_ ne $v->{extlinks}[$#{$v->{extlinks}}]; } end; end; @@ -766,7 +769,7 @@ sub _affiliate_links { $rel->{type} eq 'partial' ? 2 : @{$rel->{vn}} > 1 ? 0 : 1; - for my $l (grep $_->[2], @{$self->entryLinks(r => $rel)}) { + for my $l (grep $_->[2], $rel->{extlinks}->@*) { $links{$l->[1]} = [ @$l, min $type, $links{$l->[1]}[3]||9 ]; } } |