diff options
author | Yorhel <git@yorhel.nl> | 2022-01-20 09:02:15 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2022-02-08 11:36:07 +0100 |
commit | 727a4d84255f13badffe16c5858fdb036ddcdbce (patch) | |
tree | 6c77f72e2423a7c7425caea6aebc6ba8eaf001f8 /lib/VNWeb/Chars/List.pm | |
parent | 9d651b8d138349b3853f23117cc3802fcfe0ba6a (diff) |
VN: Add support for multiple titles in different languages
This implements the main database model part of custom title languages
(https://vndb.org/t12465). Selecting the right title for display is done
in SQL through the 'vnt' VIEW, which can be overridden in each session
with a TEMPORARY VIEW in order to support user title preferences, but
that part has not been implemented yet.
I had started out using an sql_vn() function that returned a subquery
instead of using a VIEW, but then ran into trouble with the item_info()
SQL function. This VIEW approach also happened to simplify much of the
code. I did have to get rid of the Discusssions::Lib::sql_boards()
function, as Postgres was unable to optimize the subquery inside a UNION
inside a subquery for some reason. Haven't run into any other noticeable
performance regressions yet.
TODO:
- Implement actual user title preferences
- Add the correct 'lang' HTML attributes everywhere a title is displayed
(we do have the information now, though it still isn't trivial)
- Add title fetching support to API
Diffstat (limited to 'lib/VNWeb/Chars/List.pm')
-rw-r--r-- | lib/VNWeb/Chars/List.pm | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/VNWeb/Chars/List.pm b/lib/VNWeb/Chars/List.pm index 5e44a606..81d2dc19 100644 --- a/lib/VNWeb/Chars/List.pm +++ b/lib/VNWeb/Chars/List.pm @@ -26,7 +26,7 @@ sub listing_ { td_ class => 'tc2', sub { a_ href => "/$_->{id}", title => $_->{original}||$_->{name}, $_->{name}; b_ class => 'grayedout', sub { - join_ ', ', sub { a_ href => "/$_->{id}", title => $_->{original}||$_->{title}, $_->{title} }, $_->{vn}->@*; + join_ ', ', sub { a_ href => "/$_->{id}", title => $_->{alttitle}||$_->{title}, $_->{title} }, $_->{vn}->@*; }; }; } for @$list; @@ -49,7 +49,7 @@ sub listing_ { a_ href => "/$_->{id}", title => $_->{original}||$_->{name}, $_->{name}; br_; b_ class => 'grayedout', sub { - join_ ', ', sub { a_ href => "/$_->{id}", title => $_->{original}||$_->{title}, $_->{title} }, $_->{vn}->@*; + join_ ', ', sub { a_ href => "/$_->{id}", title => $_->{alttitle}||$_->{title}, $_->{title} }, $_->{vn}->@*; }; }; } for @$list; @@ -71,9 +71,9 @@ sub listing_ { # Also used by VNWeb::TT::TraitPage sub enrich_listing { enrich vn => id => cid => sub { sql ' - SELECT DISTINCT cv.id AS cid, v.id, v.title, v.original + SELECT DISTINCT cv.id AS cid, v.id, v.title, v.alttitle FROM chars_vns cv - JOIN vn v ON v.id = cv.vid + JOIN vnt v ON v.id = cv.vid WHERE NOT v.hidden AND cv.spoil = 0 AND cv.id IN', $_, ' ORDER BY v.title' }, @_; |