summaryrefslogtreecommitdiff
path: root/lib/VNWeb/Releases
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-02-12 10:16:02 +0100
committerYorhel <git@yorhel.nl>2021-03-01 10:16:33 +0100
commitfc3721171f021807d1c8b23a5257fc1ac1809ea5 (patch)
treebcd63e797e26e17d73be02d90ea52b4f5c2da497 /lib/VNWeb/Releases
parent86d0191251fc80205dce92369b9b661cb40a3707 (diff)
SQL: vndbid data type conversion for most DB entries
I had wanted to split this up into multiple commits and roll out in stages, but couldn't really find a natural way to do so. There are several places that take a generic identifier and expect it to work the same for all entries they support, so changing one entry at a time wasn't going to be any easier. Only the tags & traits haven't been updated yet, I'll convert those later. While this is a major change and affects a lot of code, the individual changes are all pretty simple. I'm surprised how much code did not have to be updated at all. No doubt I've missed a few places, though, so this commit will almost certainly break something.
Diffstat (limited to 'lib/VNWeb/Releases')
-rw-r--r--lib/VNWeb/Releases/Edit.pm22
-rw-r--r--lib/VNWeb/Releases/Elm.pm2
-rw-r--r--lib/VNWeb/Releases/Lib.pm2
-rw-r--r--lib/VNWeb/Releases/Page.pm16
-rw-r--r--lib/VNWeb/Releases/VNTab.pm4
5 files changed, 23 insertions, 23 deletions
diff --git a/lib/VNWeb/Releases/Edit.pm b/lib/VNWeb/Releases/Edit.pm
index 839c42c5..fe6de7b9 100644
--- a/lib/VNWeb/Releases/Edit.pm
+++ b/lib/VNWeb/Releases/Edit.pm
@@ -4,7 +4,7 @@ use VNWeb::Prelude;
my $FORM = {
- id => { required => 0, id => 1 },
+ id => { required => 0, vndbid => 'r' },
title => { maxlength => 300 },
original => { required => 0, default => '', maxlength => 250 },
rtype => { default => 'complete', enum => \%RELEASE_TYPE },
@@ -33,11 +33,11 @@ my $FORM = {
extlinks => validate_extlinks('r'),
notes => { required => 0, default => '', maxlength => 10240 },
vn => { sort_keys => 'vid', aoh => {
- vid => { id => 1 },
+ vid => { vndbid => 'v' },
title => { _when => 'out' },
} },
producers => { sort_keys => 'pid', aoh => {
- pid => { id => 1 },
+ pid => { vndbid => 'p' },
developer => { anybool => 1 },
publisher => { anybool => 1 },
name => { _when => 'out' },
@@ -57,12 +57,12 @@ sub to_extlinks { $_[0]{extlinks} = { map +($_, delete $_[0]{$_}), grep /^l_/, k
TUWF::get qr{/$RE{rrev}/(?<action>edit|copy)} => sub {
- my $e = db_entry r => tuwf->capture('id'), tuwf->capture('rev') or return tuwf->resNotFound;
+ my $e = db_entry tuwf->captures('id', 'rev') or return tuwf->resNotFound;
my $copy = tuwf->capture('action') eq 'copy';
return tuwf->resDenied if !can_edit r => $copy ? {} : $e;
$e->{rtype} = delete $e->{type};
- $e->{editsum} = $copy ? "Copied from r$e->{id}.$e->{chrev}" : $e->{chrev} == $e->{maxrev} ? '' : "Reverted to revision r$e->{id}.$e->{chrev}";
+ $e->{editsum} = $copy ? "Copied from $e->{id}.$e->{chrev}" : $e->{chrev} == $e->{maxrev} ? '' : "Reverted to revision $e->{id}.$e->{chrev}";
$e->{authmod} = auth->permDbmod;
to_extlinks $e;
@@ -73,7 +73,7 @@ TUWF::get qr{/$RE{rrev}/(?<action>edit|copy)} => sub {
$e->@{qw/gtin catalog extlinks/} = elm_empty($FORM_OUT)->@{qw/gtin catalog extlinks/} if $copy;
my $title = ($copy ? 'Copy ' : 'Edit ').$e->{title};
- framework_ title => $title, type => 'r', dbobj => $e, tab => tuwf->capture('action'),
+ framework_ title => $title, dbobj => $e, tab => tuwf->capture('action'),
sub {
editmsg_ r => $e, $title, $copy;
elm_ ReleaseEdit => $FORM_OUT, $copy ? {%$e, id=>undef} : $e;
@@ -111,8 +111,8 @@ TUWF::get qr{/$RE{vid}/add}, sub {
br_;
ul_ sub {
li_ sub {
- txt_ '['.join(',', $_->{languages}->@*)."] r$_->{id}:";
- a_ href => "/r$_->{id}", title => $_->{original}||$_->{title}, $_->{title};
+ txt_ '['.join(',', $_->{languages}->@*)."] $_->{id}:";
+ a_ href => "/$_->{id}", title => $_->{original}||$_->{title}, $_->{title};
} for @$delrel;
}
}
@@ -126,7 +126,7 @@ TUWF::get qr{/$RE{vid}/add}, sub {
elm_api ReleaseEdit => $FORM_OUT, $FORM_IN, sub {
my $data = shift;
my $new = !$data->{id};
- my $e = $new ? { id => 0 } : db_entry r => $data->{id} or return tuwf->resNotFound;
+ my $e = $new ? { id => 0 } : db_entry $data->{id} or return tuwf->resNotFound;
return elm_Unauth if !can_edit r => $e;
if(!auth->permDbmod) {
@@ -151,8 +151,8 @@ elm_api ReleaseEdit => $FORM_OUT, $FORM_IN, sub {
delete $data->{extlinks};
$data->{type} = delete $data->{rtype};
- my($id,undef,$rev) = db_edit r => $e->{id}, $data;
- elm_Redirect "/r$id.$rev";
+ my $ch = db_edit r => $e->{id}, $data;
+ elm_Redirect "/$ch->{nitemid}.$ch->{nrev}";
};
diff --git a/lib/VNWeb/Releases/Elm.pm b/lib/VNWeb/Releases/Elm.pm
index 40e6bfad..09c9ede2 100644
--- a/lib/VNWeb/Releases/Elm.pm
+++ b/lib/VNWeb/Releases/Elm.pm
@@ -5,7 +5,7 @@ use VNWeb::Releases::Lib;
# Used by UList.Opt and CharEdit to fetch releases from a VN id.
-elm_api Release => undef, { vid => { id => 1 } }, sub {
+elm_api Release => undef, { vid => { vndbid => 'v' } }, sub {
my($data) = @_;
elm_Releases releases_by_vn $data->{vid};
};
diff --git a/lib/VNWeb/Releases/Lib.pm b/lib/VNWeb/Releases/Lib.pm
index 07bb6878..3c97d326 100644
--- a/lib/VNWeb/Releases/Lib.pm
+++ b/lib/VNWeb/Releases/Lib.pm
@@ -113,7 +113,7 @@ sub release_row_ {
abbr_ class => "icons rt$r->{type}", title => $r->{type}, '';
};
td_ class => 'tc4', sub {
- a_ href => "/r$r->{id}", title => $r->{original}||$r->{title}, $r->{title};
+ a_ href => "/$r->{id}", title => $r->{original}||$r->{title}, $r->{title};
my $note = join ' ', $r->{official} ? () : 'unofficial', $r->{patch} ? 'patch' : ();
b_ class => 'grayedout', " ($note)" if $note;
};
diff --git a/lib/VNWeb/Releases/Page.pm b/lib/VNWeb/Releases/Page.pm
index 8067de7c..3d97dfe5 100644
--- a/lib/VNWeb/Releases/Page.pm
+++ b/lib/VNWeb/Releases/Page.pm
@@ -21,8 +21,8 @@ sub enrich_item {
sub _rev_ {
my($r) = @_;
- revision_ r => $r, \&enrich_item,
- [ vn => 'Relations', fmt => sub { a_ href => "/v$_->{vid}", title => $_->{original}||$_->{title}, $_->{title} } ],
+ revision_ $r, \&enrich_item,
+ [ vn => 'Relations', fmt => sub { a_ href => "/$_->{vid}", title => $_->{original}||$_->{title}, $_->{title} } ],
[ type => 'Type' ],
[ official => 'Official', fmt => 'bool' ],
[ patch => 'Patch', fmt => 'bool' ],
@@ -45,7 +45,7 @@ sub _rev_ {
[ ani_ero => 'Ero animation', fmt => \%ANIMATED ],
[ engine => 'Engine' ],
[ producers => 'Producers', fmt => sub {
- a_ href => "/p$_->{pid}", title => $_->{original}||$_->{name}, $_->{name};
+ a_ href => "/$_->{pid}", title => $_->{original}||$_->{name}, $_->{name};
txt_ ' (';
txt_ join ', ', $_->{developer} ? 'developer' : (), $_->{publisher} ? 'publisher' : ();
txt_ ')';
@@ -62,7 +62,7 @@ sub _infotable_ {
td_ class => 'key', 'Relation';
td_ sub {
join_ \&br_, sub {
- a_ href => "/v$_->{vid}", title => $_->{original}||$_->{title}, $_->{title};
+ a_ href => "/$_->{vid}", title => $_->{original}||$_->{title}, $_->{title};
}, $r->{vn}->@*
}
};
@@ -168,7 +168,7 @@ sub _infotable_ {
td_ ucfirst($t).(@prod == 1 ? '' : 's');
td_ sub {
join_ \&br_, sub {
- a_ href => "/p$_->{pid}", title => $_->{original}||$_->{name}, $_->{name};
+ a_ href => "/$_->{pid}", title => $_->{original}||$_->{name}, $_->{name};
}, @prod
}
} if @prod;
@@ -205,20 +205,20 @@ sub _infotable_ {
TUWF::get qr{/$RE{rrev}} => sub {
- my $r = db_entry r => tuwf->capture('id'), tuwf->capture('rev');
+ my $r = db_entry tuwf->captures('id','rev');
return tuwf->resNotFound if !$r;
enrich_item $r;
enrich_extlinks r => $r;
- framework_ title => $r->{title}, index => !tuwf->capture('rev'), type => 'r', dbobj => $r, hiddenmsg => 1,
+ framework_ title => $r->{title}, index => !tuwf->capture('rev'), dbobj => $r, hiddenmsg => 1,
og => {
description => bb_format $r->{notes}, text => 1
},
sub {
_rev_ $r if tuwf->capture('rev');
div_ class => 'mainbox release', sub {
- itemmsg_ r => $r;
+ itemmsg_ $r;
h1_ sub { txt_ $r->{title}; debug_ $r };
h2_ class => 'alttitle', lang_attr($r->{lang}), $r->{original} if length $r->{original};
_infotable_ $r;
diff --git a/lib/VNWeb/Releases/VNTab.pm b/lib/VNWeb/Releases/VNTab.pm
index 0c326402..e3da0609 100644
--- a/lib/VNWeb/Releases/VNTab.pm
+++ b/lib/VNWeb/Releases/VNTab.pm
@@ -30,7 +30,7 @@ my @rel_cols = (
sort_field => 'title',
sort_sql => 'r.title %s, r.released %1$s',
column_string => 'Title',
- draw => sub { a_ href => "/r$_[0]{id}", $_[0]{title} },
+ draw => sub { a_ href => "/$_[0]{id}", $_[0]{title} },
}, { # Type
id => 'typ',
sort_field => 'type',
@@ -221,7 +221,7 @@ sub listing_ {
TUWF::get qr{/$RE{vid}/releases} => sub {
- my $v = dbobj v => tuwf->capture('id');
+ my $v = dbobj tuwf->capture('id');
return tuwf->resNotFound if !$v->{id};
my $opt = tuwf->validate(get =>