diff options
author | Yorhel <git@yorhel.nl> | 2020-07-05 10:55:18 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2020-07-05 10:55:18 +0200 |
commit | a7909fb9e21bf1e31e85d8795a72c74707543c68 (patch) | |
tree | 6e1f2fb3f57e6a84a8cbb3ef1de0f48bc4dd4b91 /lib/VNWeb | |
parent | 0a6254431d97a2f4de9429e738e58c4dca3bfaa5 (diff) |
VN::Edit: Add screenshot manager
Diffstat (limited to 'lib/VNWeb')
-rw-r--r-- | lib/VNWeb/Chars/Edit.pm | 2 | ||||
-rw-r--r-- | lib/VNWeb/Chars/Page.pm | 2 | ||||
-rw-r--r-- | lib/VNWeb/Elm.pm | 2 | ||||
-rw-r--r-- | lib/VNWeb/Releases/Elm.pm | 2 | ||||
-rw-r--r-- | lib/VNWeb/User/Lists.pm | 12 | ||||
-rw-r--r-- | lib/VNWeb/VN/Edit.pm | 32 |
6 files changed, 39 insertions, 13 deletions
diff --git a/lib/VNWeb/Chars/Edit.pm b/lib/VNWeb/Chars/Edit.pm index 6fb6a494..185466e3 100644 --- a/lib/VNWeb/Chars/Edit.pm +++ b/lib/VNWeb/Chars/Edit.pm @@ -65,7 +65,7 @@ sub enrich_releases { $e->{releases} = [ map !$vns{$_->{vid}}++ ? { id => $_->{vid} } : (), $e->{vns}->@* ]; enrich rels => id => vid => sub { sql ' - SELECT rv.vid, r.id, r.title, r.original, r.released, r.type as rtype + SELECT rv.vid, r.id, r.title, r.original, r.released, r.type as rtype, r.reso_x, r.reso_y FROM releases r JOIN releases_vn rv ON rv.id = r.id WHERE NOT r.hidden AND rv.vid IN', $_, ' diff --git a/lib/VNWeb/Chars/Page.pm b/lib/VNWeb/Chars/Page.pm index ebb6224b..77aa3c97 100644 --- a/lib/VNWeb/Chars/Page.pm +++ b/lib/VNWeb/Chars/Page.pm @@ -91,7 +91,7 @@ sub image_ { input_ type => 'checkbox', class => 'visuallyhidden', $hidden ? () : (checked => 'checked') if $hide_on_click; div_ class => 'imghover--visible', sub { img_ src => tuwf->imgurl($img->{id}), alt => $c->{name}; - a_ href => "/img/$img->{id}?view=".viewset(show_nsfw=>1), + a_ class => 'imghover--overlay', href => "/img/$img->{id}?view=".viewset(show_nsfw=>1), $img->{votecount} ? sprintf '%s / %s (%d)', $sexd, $viod, $img->{votecount} : 'Not flagged'; }; div_ class => 'imghover--warning', sub { diff --git a/lib/VNWeb/Elm.pm b/lib/VNWeb/Elm.pm index b0f4b0f0..d07a19d6 100644 --- a/lib/VNWeb/Elm.pm +++ b/lib/VNWeb/Elm.pm @@ -57,6 +57,8 @@ our %apis = ( original => { required => 0, default => '' }, released => { uint => 1 }, rtype => {}, + reso_x => { uint => 1 }, + reso_y => { uint => 1 }, lang => { type => 'array', values => {} }, platforms=> { type => 'array', values => {} }, } } ], diff --git a/lib/VNWeb/Releases/Elm.pm b/lib/VNWeb/Releases/Elm.pm index b151de41..f942488f 100644 --- a/lib/VNWeb/Releases/Elm.pm +++ b/lib/VNWeb/Releases/Elm.pm @@ -7,7 +7,7 @@ use VNWeb::Prelude; elm_api Release => undef, { vid => { id => 1 } }, sub { my($data) = @_; my $l = tuwf->dbAlli( - 'SELECT r.id, r.title, r.original, r.type AS rtype, r.released + 'SELECT r.id, r.title, r.original, r.type AS rtype, r.released, r.reso_x, r.reso_y FROM releases r JOIN releases_vn rv ON rv.id = r.id WHERE NOT r.hidden diff --git a/lib/VNWeb/User/Lists.pm b/lib/VNWeb/User/Lists.pm index bbc986d2..ff287c5e 100644 --- a/lib/VNWeb/User/Lists.pm +++ b/lib/VNWeb/User/Lists.pm @@ -166,15 +166,7 @@ my $VNOPT = form_compile any => { uid => { id => 1 }, vid => { id => 1 }, notes => {}, - rels => { aoh => { # Same structure as 'elm_Releases' response - id => { id => 1 }, - title => {}, - original => {}, - released => { uint => 1 }, - rtype => {}, - lang => { type => 'array', values => {} }, - platforms=> { type => 'array', values => {} }, - } }, + rels => $VNWeb::Elm::apis{Releases}[0], relstatus => { type => 'array', values => { uint => 1 } }, # List of release statuses, same order as rels }; @@ -469,7 +461,7 @@ sub listing_ { enrich_flatten labels => id => vid => sql('SELECT vid, lbl FROM ulist_vns_labels WHERE uid =', \$uid, 'AND vid IN'), $lst; enrich rels => id => vid => sub { sql ' - SELECT rv.vid, r.id, r.title, r.original, r.released, r.type as rtype, rl.status + SELECT rv.vid, r.id, r.title, r.original, r.released, r.type as rtype, rl.status, r.reso_x, r.reso_y FROM rlists rl JOIN releases r ON rl.rid = r.id JOIN releases_vn rv ON rv.id = r.id diff --git a/lib/VNWeb/VN/Edit.pm b/lib/VNWeb/VN/Edit.pm index 322a7ba2..625d477d 100644 --- a/lib/VNWeb/VN/Edit.pm +++ b/lib/VNWeb/VN/Edit.pm @@ -20,11 +20,17 @@ my $FORM = { } }, image => { required => 0, vndbid => 'cv' }, image_info => { _when => 'out', required => 0, type => 'hash', keys => $VNWeb::Elm::apis{ImageResult}[0]{aoh} }, + screenshots=> { sort_keys => 'scr', aoh => { + scr => { vndbid => 'sf' }, + rid => { required => 0, id => 1 }, + info => { _when => 'out', type => 'hash', keys => $VNWeb::Elm::apis{ImageResult}[0]{aoh} }, + } }, hidden => { anybool => 1 }, locked => { anybool => 1 }, authmod => { _when => 'out', anybool => 1 }, editsum => { _when => 'in out', editsum => 1 }, + releases => { _when => 'out', $VNWeb::Elm::apis{Releases}[0]->%* }, }; my $FORM_OUT = form_compile out => $FORM; @@ -46,9 +52,21 @@ TUWF::get qr{/$RE{vrev}/edit} => sub { } else { $e->{image_info} = undef; } + $_->{info} = {id=>$_->{scr}} for $e->{screenshots}->@*; + enrich_image 0, [map $_->{info}, $e->{screenshots}->@*]; enrich_merge aid => 'SELECT id AS aid, title_romaji AS title, title_kanji AS original FROM anime WHERE id IN', $e->{anime}; + $e->{releases} = tuwf->dbAlli(' + SELECT rv.vid, r.id, r.title, r.original, r.released, r.type as rtype, r.reso_x, r.reso_y + FROM releases r + JOIN releases_vn rv ON rv.id = r.id + WHERE NOT r.hidden AND rv.vid =', \$e->{id}, ' + ORDER BY r.released, r.title, r.id' + ); + enrich_flatten lang => id => id => sub { sql('SELECT id, lang FROM releases_lang WHERE id IN', $_, 'ORDER BY lang') }, $e->{releases}; + enrich_flatten platforms => id => id => sub { sql('SELECT id, platform FROM releases_platforms WHERE id IN', $_, 'ORDER BY platform') }, $e->{releases}; + framework_ title => "Edit $e->{title}", type => 'v', dbobj => $e, tab => 'edit', sub { editmsg_ v => $e, "Edit $e->{title}"; @@ -85,6 +103,20 @@ elm_api VNEdit => $FORM_OUT, $FORM_IN, sub { validate_dbid 'SELECT id FROM anime WHERE id IN', map $_->{aid}, $data->{anime}->@*; validate_dbid 'SELECT id FROM images WHERE id IN', $data->{image} if $data->{image}; + validate_dbid 'SELECT id FROM images WHERE id IN', map $_->{scr}, $data->{screenshots}->@*; + + die "Screenshot without releases assigned" if grep !$_->{rid}, $data->{screenshots}->@*; # This is only the case for *very* old revisions, form disallows this now. + # Allow linking to deleted or moved releases only if the previous revision also had that. + # (The form really should encourage the user to fix that, but disallowing the edit seems a bit overkill) + validate_dbid sub { ' + SELECT r.id FROM releases r JOIN releases_vn rv ON r.id = rv.id WHERE NOT r.hidden AND rv.vid =', \$e->{id}, ' AND r.id IN', $_, ' + UNION + SELECT rid FROM vn_screenshots WHERE id =', \$e->{id}, 'AND rid IN', $_ + }, map $_->{rid}, $data->{screenshots}->@*; + + $data->{image_nsfw} = $e->{image_nsfw}||0; + my %oldscr = map +($_->{scr}, $_->{nsfw}), @{ $e->{screenshots}||[] }; + $_->{nsfw} = $oldscr{$_->{scr}}||0 for $data->{screenshots}->@*; return elm_Unchanged if !$new && !form_changed $FORM_CMP, $data, $e; my($id,undef,$rev) = db_edit v => $e->{id}, $data; |