summaryrefslogtreecommitdiff
path: root/lib/VNWeb
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
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')
-rw-r--r--lib/VNWeb/AdvSearch.pm16
-rw-r--r--lib/VNWeb/Auth.pm4
-rw-r--r--lib/VNWeb/Chars/Edit.pm28
-rw-r--r--lib/VNWeb/Chars/List.pm14
-rw-r--r--lib/VNWeb/Chars/Page.pm30
-rw-r--r--lib/VNWeb/Chars/VNTab.pm4
-rw-r--r--lib/VNWeb/DB.pm13
-rw-r--r--lib/VNWeb/Discussions/Board.pm15
-rw-r--r--lib/VNWeb/Discussions/Edit.pm18
-rw-r--r--lib/VNWeb/Discussions/Elm.pm8
-rw-r--r--lib/VNWeb/Discussions/Index.pm2
-rw-r--r--lib/VNWeb/Discussions/Lib.pm4
-rw-r--r--lib/VNWeb/Discussions/PostEdit.pm2
-rw-r--r--lib/VNWeb/Discussions/Thread.pm4
-rw-r--r--lib/VNWeb/Discussions/UPosts.pm2
-rw-r--r--lib/VNWeb/Docs/Edit.pm14
-rw-r--r--lib/VNWeb/Docs/Lib.pm4
-rw-r--r--lib/VNWeb/Docs/Page.pm8
-rw-r--r--lib/VNWeb/Elm.pm20
-rw-r--r--lib/VNWeb/Graph.pm3
-rw-r--r--lib/VNWeb/HTML.pm68
-rw-r--r--lib/VNWeb/Images/Lib.pm2
-rw-r--r--lib/VNWeb/Images/List.pm14
-rw-r--r--lib/VNWeb/Images/Vote.pm2
-rw-r--r--lib/VNWeb/Misc/Feeds.pm6
-rw-r--r--lib/VNWeb/Misc/History.pm51
-rw-r--r--lib/VNWeb/Misc/HomePage.pm10
-rw-r--r--lib/VNWeb/Misc/Redirects.pm8
-rw-r--r--lib/VNWeb/Misc/Reports.pm13
-rw-r--r--lib/VNWeb/Prelude.pm76
-rw-r--r--lib/VNWeb/Producers/Edit.pm28
-rw-r--r--lib/VNWeb/Producers/Graph.pm8
-rw-r--r--lib/VNWeb/Producers/List.pm2
-rw-r--r--lib/VNWeb/Producers/Page.pm20
-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
-rw-r--r--lib/VNWeb/Reviews/Edit.pm8
-rw-r--r--lib/VNWeb/Reviews/List.pm8
-rw-r--r--lib/VNWeb/Reviews/Page.pm10
-rw-r--r--lib/VNWeb/Reviews/VNTab.pm6
-rw-r--r--lib/VNWeb/Staff/Edit.pm16
-rw-r--r--lib/VNWeb/Staff/List.pm2
-rw-r--r--lib/VNWeb/Staff/Page.pm14
-rw-r--r--lib/VNWeb/TT/TagLinks.pm8
-rw-r--r--lib/VNWeb/ULists/Elm.pm36
-rw-r--r--lib/VNWeb/ULists/Export.pm6
-rw-r--r--lib/VNWeb/ULists/Lib.pm2
-rw-r--r--lib/VNWeb/ULists/List.pm14
-rw-r--r--lib/VNWeb/User/Edit.pm14
-rw-r--r--lib/VNWeb/User/List.pm12
-rw-r--r--lib/VNWeb/User/Login.pm2
-rw-r--r--lib/VNWeb/User/Notifications.pm20
-rw-r--r--lib/VNWeb/User/Page.pm22
-rw-r--r--lib/VNWeb/User/PassReset.pm2
-rw-r--r--lib/VNWeb/User/PassSet.pm2
-rw-r--r--lib/VNWeb/User/Register.pm2
-rw-r--r--lib/VNWeb/VN/Edit.pm38
-rw-r--r--lib/VNWeb/VN/Graph.pm10
-rw-r--r--lib/VNWeb/VN/List.pm4
-rw-r--r--lib/VNWeb/VN/Page.pm66
-rw-r--r--lib/VNWeb/VN/Tagmod.pm4
-rw-r--r--lib/VNWeb/VN/Votes.pm2
-rw-r--r--lib/VNWeb/Validation.pm6
66 files changed, 437 insertions, 466 deletions
diff --git a/lib/VNWeb/AdvSearch.pm b/lib/VNWeb/AdvSearch.pm
index c42d3423..0d1b1635 100644
--- a/lib/VNWeb/AdvSearch.pm
+++ b/lib/VNWeb/AdvSearch.pm
@@ -322,7 +322,7 @@ f v => 65 => 'on-list', { uint => 1, range => [1,1] }, '=' => sub { auth
f v => 6 => 'developer-id',{ vndbid => 'p' },
'=' => sub { sql 'v.id IN(SELECT rv.vid FROM releases r JOIN releases_vn rv ON rv.id = r.id JOIN releases_producers rp ON rp.id = r.id
- WHERE NOT r.hidden AND rp.pid = vndbid_num(', \$_, ') AND rp.developer)' };
+ WHERE NOT r.hidden AND rp.pid =', \$_, 'AND rp.developer)' };
f v => 8 => 'tag', { type => 'any', func => \&_validate_tag },
compact => sub { my $id = ($_->[0] =~ s/^g//r)*1; $_->[1] == 0 && $_->[2] == 0 ? $id : [ $id, int($_->[2]*5)*3 + $_->[1] ] },
@@ -364,8 +364,8 @@ f r => 4 => 'platform', { required => 0, default => undef, enum => \%PLATFORM }
sql 'r.id', $neg ? 'NOT' : '', 'IN(SELECT id FROM releases_platforms WHERE platform IN', $val, $all && @$val > 1 ? ('GROUP BY id HAVING COUNT(platform) =', \scalar @$val) : (), ')';
};
-f r => 6 => 'developer-id',{ vndbid => 'p' }, '=' => sub { sql 'r.id IN(SELECT id FROM releases_producers WHERE developer AND pid = vndbid_num(', \$_, '))' };
-f r => 17 => 'producer-id', { vndbid => 'p' }, '=' => sub { sql 'r.id IN(SELECT id FROM releases_producers WHERE pid = vndbid_num(', \$_, '))' };
+f r => 6 => 'developer-id',{ vndbid => 'p' }, '=' => sub { sql 'r.id IN(SELECT id FROM releases_producers WHERE developer AND pid =', \$_, ')' };
+f r => 17 => 'producer-id', { vndbid => 'p' }, '=' => sub { sql 'r.id IN(SELECT id FROM releases_producers WHERE pid =', \$_, ')' };
f r => 7 => 'released', { fuzzyrdate => 1 }, sql => sub { sql 'r.released', $_[0], \($_ == 1 ? strftime('%Y%m%d', gmtime) : $_) };
f r => 8 => 'resolution', { type => 'array', length => 2, values => { uint => 1, max => 32767 } },
sql => sub { sql 'NOT r.patch AND r.reso_x', $_[0], \$_->[0], 'AND r.reso_y', $_[0], \$_->[1], $_->[0] ? 'AND r.reso_x > 0' : () };
@@ -425,7 +425,7 @@ f c => 53 => 'vn', 'v', '=' => sub { sql 'c.id IN(SELECT cv.id FROM chars_vn
# Staff filters need both 'staff s' and 'staff_alias sa' - aliases are treated as separate rows.
f s => 2 => 'lang', { enum => \%LANGUAGE }, '=' => sub { sql 's.lang =', \$_ };
-f s => 3 => 'id', { vndbid => 's' }, '=' => sub { sql 's.id = vndbid_num(', \$_, ')' };
+f s => 3 => 'id', { vndbid => 's' }, '=' => sub { sql 's.id = ', \$_ };
f s => 4 => 'gender', { enum => \%GENDER }, '=' => sub { sql 's.gender =', \$_ };
f s => 5 => 'role', { enum => [ 'seiyuu', keys %CREDIT_TYPE ] },
sql_list_grp => sub { $_ eq 'seiyuu' ? undef : '' },
@@ -605,7 +605,7 @@ sub _sql_where_trait {
# Assumption: All labels in a group are for the same uid and label==0 has its own group.
sub _sql_where_label {
my($neg, $all, $val) = @_;
- my $uid = $val->[0][0] =~ s/^u//r;
+ my $uid = $val->[0][0];
my $own = VNWeb::ULists::Lib::ulists_own($uid);
my @lbl = map $_->[1], @$val;
@@ -726,10 +726,10 @@ sub elm_search_query {
my(%o,%ids);
_extract_ids($self->{type}, $self->{query}, \%ids) if $self->{query};
- $o{producers} = [ map +{id => $_=~s/^p//rg}, grep /^p/, keys %ids ];
+ $o{producers} = [ map +{id => $_}, grep /^p/, keys %ids ];
enrich_merge id => 'SELECT id, name, original, hidden FROM producers WHERE id IN', $o{producers};
- $o{staff} = [ map +{id => $_=~s/^s//rg}, grep /^s/, keys %ids ];
+ $o{staff} = [ map +{id => $_}, grep /^s/, keys %ids ];
enrich_merge id => 'SELECT s.id, sa.aid, sa.name, sa.original FROM staff s JOIN staff_alias sa ON sa.aid = s.aid WHERE s.id IN', $o{staff};
$o{tags} = [ map +{id => $_=~s/^g//rg}, grep /^g/, keys %ids ];
@@ -752,7 +752,7 @@ sub elm_ {
my($self) = @_;
state $schema ||= tuwf->compile({ type => 'hash', keys => {
- uid => { uint => 1, required => 0 },
+ uid => { vndbid => 'u', required => 0 },
labels => { aoh => { id => { uint => 1 }, label => {} } },
defaultSpoil => { uint => 1 },
saved => { aoh => { name => {}, query => {} } },
diff --git a/lib/VNWeb/Auth.pm b/lib/VNWeb/Auth.pm
index 694ea18a..08ec4dad 100644
--- a/lib/VNWeb/Auth.pm
+++ b/lib/VNWeb/Auth.pm
@@ -39,7 +39,7 @@ our @EXPORT = ('auth');
sub auth {
tuwf->req->{auth} ||= do {
my $cookie = tuwf->reqCookie('auth')||'';
- my($uid, $token_e) = $cookie =~ /^([a-fA-F0-9]{40})\.?(\d+)$/ ? ($2, sha1_hex pack 'H*', $1) : (0, '');
+ my($uid, $token_e) = $cookie =~ /^([a-fA-F0-9]{40})\.?u?(\d+)$/ ? ('u'.$2, sha1_hex pack 'H*', $1) : (0, '');
my $auth = __PACKAGE__->new();
$auth->_load_session($uid, $token_e);
@@ -53,7 +53,7 @@ sub auth {
# have a lot of influence in this)
TUWF::set log_format => sub {
my(undef, $uri, $msg) = @_;
- sprintf "[%s] %s %s: %s\n", scalar localtime(), $uri, tuwf->req && auth ? 'u'.auth->uid : '-', $msg;
+ sprintf "[%s] %s %s: %s\n", scalar localtime(), $uri, tuwf->req && auth ? auth->uid : '-', $msg;
};
diff --git a/lib/VNWeb/Chars/Edit.pm b/lib/VNWeb/Chars/Edit.pm
index 3d0a357a..5f15afd6 100644
--- a/lib/VNWeb/Chars/Edit.pm
+++ b/lib/VNWeb/Chars/Edit.pm
@@ -6,7 +6,7 @@ use VNWeb::Releases::Lib;
my $FORM = {
- id => { required => 0, id => 1 },
+ id => { required => 0, vndbid => 'c' },
name => { maxlength => 200 },
original => { required => 0, default => '', maxlength => 200 },
alias => { required => 0, default => '', maxlength => 500 },
@@ -23,7 +23,7 @@ my $FORM = {
weight => { required => 0, uint => 1, range => [ 0, 32767 ] },
bloodt => { default => 'unknown', enum => \%BLOOD_TYPE },
cup_size => { required => 0, default => '', enum => \%CUP_SIZE },
- main => { required => 0, id => 1 },
+ main => { required => 0, vndbid => 'c' },
main_spoil => { uint => 1, range => [0,2] },
main_ref => { _when => 'out', anybool => 1 },
main_name => { _when => 'out', default => '' },
@@ -39,8 +39,8 @@ my $FORM = {
new => { _when => 'out', anybool => 1 },
} },
vns => { sort_keys => ['vid', 'rid'], aoh => {
- vid => { id => 1 },
- rid => { id => 1, required => 0 },
+ vid => { vndbid => 'v' },
+ rid => { vndbid => 'r', required => 0 },
spoil => { uint => 1, range => [0,2] },
role => { enum => \%CHAR_ROLE },
title => { _when => 'out' },
@@ -51,7 +51,7 @@ my $FORM = {
authmod => { _when => 'out', anybool => 1 },
editsum => { _when => 'in out', editsum => 1 },
releases => { _when => 'out', aoh => {
- id => { id => 1 },
+ id => { vndbid => 'r' },
rels => $VNWeb::Elm::apis{Releases}[0]
} },
};
@@ -62,7 +62,7 @@ my $FORM_CMP = form_compile cmp => $FORM;
TUWF::get qr{/$RE{crev}/(?<action>edit|copy)} => sub {
- my $e = db_entry c => 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 c => $copy ? {} : $e;
@@ -73,7 +73,7 @@ TUWF::get qr{/$RE{crev}/(?<action>edit|copy)} => sub {
$e->{traits} = [ sort { ($a->{order}//99) <=> ($b->{order}//99) || $a->{name} cmp $b->{name} } grep !$copy || $_->{applicable}, $e->{traits}->@* ];
enrich_merge vid => 'SELECT id AS vid, title FROM vn WHERE id IN', $e->{vns};
- $e->{vns} = [ sort { $a->{title} cmp $b->{title} || $a->{vid} <=> $b->{vid} || ($a->{rid}||0) <=> ($b->{rid}||0) } $e->{vns}->@* ];
+ $e->{vns} = [ sort { $a->{title} cmp $b->{title} || idcmp($a->{vid}, $b->{vid}) || idcmp($a->{rid}||'r0', $b->{rid}||'r0') } $e->{vns}->@* ];
my %vns;
$e->{releases} = [ map !$vns{$_->{vid}}++ ? { id => $_->{vid}, rels => releases_by_vn $_->{vid} } : (), $e->{vns}->@* ];
@@ -86,10 +86,10 @@ TUWF::get qr{/$RE{crev}/(?<action>edit|copy)} => sub {
}
$e->{authmod} = auth->permDbmod;
- $e->{editsum} = $copy ? "Copied from c$e->{id}.$e->{chrev}" : $e->{chrev} == $e->{maxrev} ? '' : "Reverted to revision c$e->{id}.$e->{chrev}";
+ $e->{editsum} = $copy ? "Copied from $e->{id}.$e->{chrev}" : $e->{chrev} == $e->{maxrev} ? '' : "Reverted to revision $e->{id}.$e->{chrev}";
my $title = ($copy ? 'Copy ' : 'Edit ').$e->{name};
- framework_ title => $title, type => 'c', dbobj => $e, tab => tuwf->capture('action'),
+ framework_ title => $title, dbobj => $e, tab => tuwf->capture('action'),
sub {
editmsg_ c => $e, $title, $copy;
elm_ CharEdit => $FORM_OUT, $copy ? {%$e, id=>undef} : $e;
@@ -117,7 +117,7 @@ TUWF::get qr{/$RE{vid}/addchar}, sub {
elm_api CharEdit => $FORM_OUT, $FORM_IN, sub {
my $data = shift;
my $new = !$data->{id};
- my $e = $new ? { id => 0 } : db_entry c => $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 c => $e;
if(!auth->permDbmod) {
@@ -128,7 +128,7 @@ elm_api CharEdit => $FORM_OUT, $FORM_IN, sub {
$data->{b_day} = 0 if !$data->{b_month};
$data->{main} = undef if $data->{hidden};
- die "Attempt to set main to self" if $data->{main} && $data->{main} == $e->{id};
+ die "Attempt to set main to self" if $data->{main} && $data->{main} eq $e->{id};
die "Attempt to set main while this character is already referenced." if $data->{main} && tuwf->dbVali('SELECT 1 AS ref FROM chars WHERE main =', \$e->{id});
# It's possible that the referenced character has been deleted since it was added as main, so don't die() on this one, just unset main.
$data->{main} = undef if $data->{main} && !tuwf->dbVali('SELECT 1 FROM chars WHERE NOT hidden AND main IS NULL AND id =', \$data->{main});
@@ -146,12 +146,12 @@ elm_api CharEdit => $FORM_OUT, $FORM_IN, sub {
# and the char hasn't been updated yet. Would be nice to give a better
# error message in that case.
for($data->{vns}->@*) {
- die "Bad release for v$_->{vid}: r$_->{rid}\n" if defined $_->{rid} && !tuwf->dbVali('SELECT 1 FROM releases_vn WHERE id =', \$_->{rid}, 'AND vid =', \$_->{vid});
+ die "Bad release for $_->{vid}: $_->{rid}\n" if defined $_->{rid} && !tuwf->dbVali('SELECT 1 FROM releases_vn WHERE id =', \$_->{rid}, 'AND vid =', \$_->{vid});
}
return elm_Unchanged if !$new && !form_changed $FORM_CMP, $data, $e;
- my($id,undef,$rev) = db_edit c => $e->{id}, $data;
- elm_Redirect "/c$id.$rev";
+ my $ch = db_edit c => $e->{id}, $data;
+ elm_Redirect "/$ch->{nitemid}.$ch->{nrev}";
};
1;
diff --git a/lib/VNWeb/Chars/List.pm b/lib/VNWeb/Chars/List.pm
index 7f48981c..8c01672f 100644
--- a/lib/VNWeb/Chars/List.pm
+++ b/lib/VNWeb/Chars/List.pm
@@ -24,9 +24,9 @@ sub listing_ {
abbr_ class => "icons gen $_->{gender}", title => $GENDER{$_->{gender}}, '' if $_->{gender} ne 'unknown';
};
td_ class => 'tc2', sub {
- a_ href => "/c$_->{id}", title => $_->{original}||$_->{name}, $_->{name};
+ a_ href => "/$_->{id}", title => $_->{original}||$_->{name}, $_->{name};
b_ class => 'grayedout', sub {
- join_ ', ', sub { a_ href => "/v$_->{id}", title => $_->{original}||$_->{title}, $_->{title} }, $_->{vn}->@*;
+ join_ ', ', sub { a_ href => "/$_->{id}", title => $_->{original}||$_->{title}, $_->{title} }, $_->{vn}->@*;
};
};
} for @$list;
@@ -39,17 +39,17 @@ sub listing_ {
div_ sub {
if($_->{image}) {
my($iw,$ih) = imgsize $_->{image}{width}*100, $_->{image}{height}*100, $w, $h;
- image_ $_->{image}, alt => $_->{name}, width => $iw, height => $ih, url => "/c$_->{id}";
+ image_ $_->{image}, alt => $_->{name}, width => $iw, height => $ih, url => "/$_->{id}";
} else {
txt_ 'no image';
}
};
div_ sub {
abbr_ class => "icons gen $_->{gender}", title => $GENDER{$_->{gender}}, '' if $_->{gender} ne 'unknown';
- a_ href => "/c$_->{id}", title => $_->{original}||$_->{name}, $_->{name};
+ a_ href => "/$_->{id}", title => $_->{original}||$_->{name}, $_->{name};
br_;
b_ class => 'grayedout', sub {
- join_ ', ', sub { a_ href => "/v$_->{id}", title => $_->{original}||$_->{title}, $_->{title} }, $_->{vn}->@*;
+ join_ ', ', sub { a_ href => "/$_->{id}", title => $_->{original}||$_->{title}, $_->{title} }, $_->{vn}->@*;
};
};
} for @$list;
@@ -58,11 +58,11 @@ sub listing_ {
div_ class => 'mainbox charbgrid', sub {
my($w,$h) = (160,200);
div_ sub {
- a_ href => "/c$_->{id}", title => $_->{original}||$_->{name}, $_->{name};
+ a_ href => "/$_->{id}", title => $_->{original}||$_->{name}, $_->{name};
div_ sub {
if($_->{image}) {
my($iw,$ih) = imgsize $_->{image}{width}*100, $_->{image}{height}*100, $w, $h;
- image_ $_->{image}, alt => $_->{name}, width => $iw, height => $ih, url => "/c$_->{id}";
+ image_ $_->{image}, alt => $_->{name}, width => $iw, height => $ih, url => "/$_->{id}";
} else {
txt_ 'no image';
}
diff --git a/lib/VNWeb/Chars/Page.pm b/lib/VNWeb/Chars/Page.pm
index eca3e26c..ca18a2f8 100644
--- a/lib/VNWeb/Chars/Page.pm
+++ b/lib/VNWeb/Chars/Page.pm
@@ -26,7 +26,7 @@ sub enrich_item {
'SELECT t.id AS tid, t.name, t.state, t.applicable, t.sexual, coalesce(g.id, t.id) AS group, coalesce(g.name, t.name) AS groupname, coalesce(g.order,0) AS order
FROM traits t LEFT JOIN traits g ON t.group = g.id WHERE t.id IN', $c->{traits};
- $c->{vns} = [ sort { $a->{title} cmp $b->{title} || $a->{vid} <=> $b->{vid} || ($a->{rid}||999999) <=> ($b->{rid}||999999) } $c->{vns}->@* ];
+ $c->{vns} = [ sort { $a->{title} cmp $b->{title} || idcmp($a->{vid}, $b->{vid}) || idcmp($a->{rid}||'r999999', $b->{rid}||'r999999') } $c->{vns}->@* ];
$c->{traits} = [ sort { $a->{order} <=> $b->{order} || $a->{groupname} cmp $b->{groupname} || $a->{name} cmp $b->{name} } $c->{traits}->@* ];
}
@@ -67,7 +67,7 @@ sub fetch_chars {
sub _rev_ {
my($c) = @_;
- revision_ c => $c, \&enrich_item,
+ revision_ $c, \&enrich_item,
[ name => 'Name' ],
[ original => 'Original name' ],
[ alias => 'Aliases' ],
@@ -86,14 +86,14 @@ sub _rev_ {
[ age => 'Age', ],
[ main => 'Instance of', empty => 0, fmt => sub {
my $c = tuwf->dbRowi('SELECT id, name, original FROM chars WHERE id =', \$_);
- a_ href => "/c$c->{id}", title => $c->{name}, "c$c->{id}"
+ a_ href => "/$c->{id}", title => $c->{name}, $c->{id}
} ],
[ main_spoil => 'Spoiler', fmt => sub { txt_ fmtspoil $_ } ],
[ image => 'Image', fmt => sub { image_ $_ } ],
[ vns => 'Visual novels', fmt => sub {
- a_ href => "/v$_->{vid}", title => $_->{original}||$_->{title}, "v$_->{vid}";
+ a_ href => "/$_->{vid}", title => $_->{original}||$_->{title}, $_->{vid};
if($_->{rid}) {
- txt_ ' ['; a_ href => "/r$_->{rid}", "r$_->{rid}"; txt_ ']';
+ txt_ ' ['; a_ href => "/$_->{rid}", $_->{rid}; txt_ ']';
}
txt_ " $CHAR_ROLE{$_->{role}}{txt} (".fmtspoil($_->{spoil}).')';
} ],
@@ -118,7 +118,7 @@ sub chartable_ {
table_ class => 'stripe', sub {
thead_ sub { tr_ sub { td_ colspan => 2, sub {
$link
- ? a_ href => "/c$c->{id}", style => 'margin-right: 10px; font-weight: bold', $c->{name}
+ ? a_ href => "/$c->{id}", style => 'margin-right: 10px; font-weight: bold', $c->{name}
: b_ style => 'margin-right: 10px', $c->{name};
b_ class => 'grayedout', style => 'margin-right: 10px', $c->{original} if $c->{original};
abbr_ class => "icons gen $c->{gender}", title => $GENDER{$c->{gender}}, '' if $c->{gender} ne 'unknown';
@@ -173,7 +173,7 @@ sub chartable_ {
td_ sub {
my @vns;
for(@visvns) {
- push @vns, $_ if !@vns || $vns[$#vns]{vid} != $_->{vid};
+ push @vns, $_ if !@vns || $vns[$#vns]{vid} ne $_->{vid};
push $vns[$#vns]{rels}->@*, $_;
}
join_ \&br_, sub {
@@ -181,18 +181,18 @@ sub chartable_ {
# Just a VN link, no releases
if(!$vn && $v->{rels}->@* == 1 && !$v->{rels}[0]{rid}) {
txt_ $CHAR_ROLE{$v->{role}}{txt}.' - ';
- a_ href => "/v$v->{vid}", title => $v->{original}||$v->{title}, $v->{title};
+ a_ href => "/$v->{vid}", title => $v->{original}||$v->{title}, $v->{title};
spoil_ $v->{spoil};
# With releases
} else {
- a_ href => "/v$v->{vid}", title => $v->{original}||$v->{title}, $v->{title} if !$vn;
+ a_ href => "/$v->{vid}", title => $v->{original}||$v->{title}, $v->{title} if !$vn;
br_ if !$vn;
join_ \&br_, sub {
b_ class => 'grayedout', '> ';
txt_ $CHAR_ROLE{$_->{role}}{txt}.' - ';
if($_->{rid}) {
- b_ class => 'grayedout', "r$_->{rid}:";
- a_ href => "/r$_->{rid}", title => $_->{roriginal}||$_->{rtitle}, $_->{rtitle};
+ b_ class => 'grayedout', "$_->{rid}:";
+ a_ href => "/$_->{rid}", title => $_->{roriginal}||$_->{rtitle}, $_->{rtitle};
} else {
txt_ 'All other releases';
}
@@ -207,7 +207,7 @@ sub chartable_ {
td_ class => 'key', 'Voiced by';
td_ sub {
join_ \&br_, sub {
- a_ href => "/s$_->{id}", title => $_->{original}||$_->{name}, $_->{name};
+ a_ href => "/$_->{id}", title => $_->{original}||$_->{name}, $_->{name};
txt_ " ($_->{note})" if $_->{note};
}, $c->{seiyuu}->@*;
};
@@ -226,7 +226,7 @@ sub chartable_ {
TUWF::get qr{/$RE{crev}} => sub {
- my $c = db_entry c => tuwf->capture('id'), tuwf->capture('rev');
+ my $c = db_entry tuwf->captures('id','rev');
return tuwf->resNotFound if !$c;
enrich_item $c;
@@ -252,7 +252,7 @@ TUWF::get qr{/$RE{crev}} => sub {
# Only display the sexual traits toggle when there are sexual traits within the current spoiler level.
my $has_sex = grep $_->{state} == 2 && $_->{spoil} <= $view->{spoilers} && $_->{sexual}, map $_->{traits}->@*, $c, @$inst;
- framework_ title => $c->{name}, index => !tuwf->capture('rev'), type => 'c', dbobj => $c, hiddenmsg => 1,
+ framework_ title => $c->{name}, index => !tuwf->capture('rev'), dbobj => $c, hiddenmsg => 1,
og => {
description => bb_format($c->{desc}, text => 1),
image => $c->{image} && $c->{image}{votecount} && !$c->{image}{sexual} && !$c->{image}{violence} ? imgurl($c->{image}{id}) : undef,
@@ -260,7 +260,7 @@ TUWF::get qr{/$RE{crev}} => sub {
sub {
_rev_ $c if tuwf->capture('rev');
div_ class => 'mainbox', sub {
- itemmsg_ c => $c;
+ itemmsg_ $c;
h1_ sub { txt_ $c->{name}; debug_ $c };
h2_ class => 'alttitle', $c->{original} if length $c->{original};
p_ class => 'chardetailopts', sub {
diff --git a/lib/VNWeb/Chars/VNTab.pm b/lib/VNWeb/Chars/VNTab.pm
index fbcc9550..6dd9836a 100644
--- a/lib/VNWeb/Chars/VNTab.pm
+++ b/lib/VNWeb/Chars/VNTab.pm
@@ -44,12 +44,12 @@ sub chars_ {
TUWF::get qr{/$RE{vid}/chars}, sub {
- my $v = db_entry v => tuwf->capture('id');
+ my $v = db_entry tuwf->capture('id');
return tuwf->resNotFound if !$v;
VNWeb::VN::Page::enrich_vn($v);
- framework_ title => $v->{title}, index => 1, type => 'v', dbobj => $v, hiddenmsg => 1,
+ framework_ title => $v->{title}, index => 1, dbobj => $v, hiddenmsg => 1,
sub {
VNWeb::VN::Page::infobox_($v);
VNWeb::VN::Page::tabs_($v, 'chars');
diff --git a/lib/VNWeb/DB.pm b/lib/VNWeb/DB.pm
index ecfdae8b..5a9a3a58 100644
--- a/lib/VNWeb/DB.pm
+++ b/lib/VNWeb/DB.pm
@@ -282,16 +282,16 @@ my $entry_types = do {
# - Combine the enrich_merge() calls into a single query.
# - Fixed ordering of arrays (use primary keys)
sub db_entry {
- my($type, $id, $rev) = @_;
- my $t = $entry_types->{$type}||die;
+ my($id, $rev) = @_;
+ my $t = $entry_types->{ substr $id, 0, 1 }||die;
- my $maxrev = tuwf->dbVali('SELECT MAX(rev) FROM changes WHERE type =', \$type, ' AND itemid =', \$id);
+ my $maxrev = tuwf->dbVali('SELECT MAX(rev) FROM changes WHERE itemid =', \$id);
return undef if !$maxrev;
$rev ||= $maxrev;
my $entry = tuwf->dbRowi(q{
SELECT itemid AS id, id AS chid, rev AS chrev, ihid AS hidden, ilock AS locked
FROM changes
- WHERE}, { type => $type, itemid => $id, rev => $rev }
+ WHERE}, { itemid => $id, rev => $rev }
);
return undef if !$entry->{id};
$entry->{maxrev} = $maxrev;
@@ -335,7 +335,7 @@ sub db_edit {
$id ||= undef;
my $t = $entry_types->{$type}||die;
- tuwf->dbExeci("SELECT edit_${type}_init(", \$id, ', (SELECT MAX(rev) FROM changes WHERE type = ', \$type, ' AND itemid = ', \$id, '))');
+ tuwf->dbExeci("SELECT edit_${type}_init(", \$id, ', (SELECT MAX(rev) FROM changes WHERE itemid = ', \$id, '))');
tuwf->dbExeci('UPDATE edit_revision SET', {
requester => $uid // scalar VNWeb::Auth::auth()->uid(),
ip => scalar tuwf->reqIP(),
@@ -372,8 +372,7 @@ sub db_edit {
tuwf->dbExeci("INSERT INTO edit_${base} (", @colnames, ') VALUES ', sql_comma @rows) if @rows;
}
- my $r = tuwf->dbRow("SELECT * FROM edit_${type}_commit()");
- ($r->{itemid}, $r->{chid}, $r->{rev})
+ tuwf->dbRow("SELECT * FROM edit_${type}_commit()");
}
1;
diff --git a/lib/VNWeb/Discussions/Board.pm b/lib/VNWeb/Discussions/Board.pm
index 6262deaf..a5673d49 100644
--- a/lib/VNWeb/Discussions/Board.pm
+++ b/lib/VNWeb/Discussions/Board.pm
@@ -5,18 +5,19 @@ use VNWeb::Discussions::Lib;
TUWF::get qr{/t/(all|$BOARD_RE)}, sub {
- my($type, $id) = tuwf->capture(1) =~ /^([^0-9]+)([0-9]*)$/;
+ my $id = tuwf->capture(1);
+ my($type) = $id =~ /^([^0-9]+)/;
+ $id = undef if $id !~ /[0-9]$/;
my $page = tuwf->validate(get => p => { upage => 1 })->data;
- my $obj = $id ? dbobj $type, $id : undef;
+ my $obj = $id ? dbobj $id : undef;
return tuwf->resNotFound if $id && !$obj->{id};
- my $ititle = $obj && ($obj->{title} || user_displayname $obj);
- my $title = $obj ? "Related discussions for $ititle" : $type eq 'all' ? 'All boards' : $BOARD_TYPE{$type}{txt};
- my $createurl = '/t/'.($id ? $type.$id : $type eq 'db' ? 'db' : 'ge').'/new';
+ my $title = $obj ? "Related discussions for $obj->{title}" : $type eq 'all' ? 'All boards' : $BOARD_TYPE{$type}{txt};
+ my $createurl = '/t/'.($id || ($type eq 'db' ? 'db' : 'ge')).'/new';
- framework_ title => $title, type => $type, dbobj => $obj, tab => 'disc',
+ framework_ title => $title, dbobj => $obj, tab => 'disc',
sub {
div_ class => 'mainbox', sub {
h1_ $title;
@@ -29,7 +30,7 @@ TUWF::get qr{/t/(all|$BOARD_RE)}, sub {
threadlist_
where => $type ne 'all' && sql('t.id IN(SELECT tid FROM threads_boards WHERE type =', \$type, $id ? ('AND iid =', \$id) : (), ')'),
- boards => $type ne 'all' && sql('NOT (tb.type =', \$type, 'AND tb.iid =', \($id||0), ')'),
+ boards => $type ne 'all' && sql('NOT (tb.type =', \$type, 'AND tb.iid IS NOT DISTINCT FROM', \$id, ')'),
results => 50,
sort => $type eq 'an' ? 't.id DESC' : undef,
page => $page,
diff --git a/lib/VNWeb/Discussions/Edit.pm b/lib/VNWeb/Discussions/Edit.pm
index b85514ec..90769d74 100644
--- a/lib/VNWeb/Discussions/Edit.pm
+++ b/lib/VNWeb/Discussions/Edit.pm
@@ -8,11 +8,7 @@ my $FORM = {
tid => { required => 0, vndbid => 't' }, # Thread ID, only when editing a post
title => { required => 0, maxlength => 50 },
- boards => { required => 0, sort_keys => [ 'boardtype', 'iid' ], aoh => {
- btype => { enum => \%BOARD_TYPE },
- iid => { required => 0, default => 0, id => 1 }, #
- title => { required => 0 },
- } },
+ boards => { required => 0, sort_keys => [ 'boardtype', 'iid' ], aoh => $VNWeb::Elm::apis{BoardResult}[0]{aoh} },
poll => { required => 0, type => 'hash', keys => {
question => { maxlength => 100 },
max_options => { uint => 1, min => 1, max => 20 }, #
@@ -54,7 +50,7 @@ elm_api DiscussionsEdit => $FORM_OUT, $FORM_IN, sub {
tuwf->dbExeci('DELETE FROM threads WHERE id =', \$tid);
return elm_Redirect '/t';
}
- auth->audit($t->{user_id}, 'post edit', "edited $tid.1") if $tid && $t->{user_id} != auth->uid;
+ auth->audit($t->{user_id}, 'post edit', "edited $tid.1") if $tid && $t->{user_id} ne auth->uid;
die "Invalid title" if !length $data->{title};
@@ -88,7 +84,7 @@ elm_api DiscussionsEdit => $FORM_OUT, $FORM_IN, sub {
$tid = tuwf->dbVali('INSERT INTO threads', $thread, 'RETURNING id') if !$tid;
tuwf->dbExeci('DELETE FROM threads_boards WHERE tid =', \$tid);
- tuwf->dbExeci('INSERT INTO threads_boards', { tid => $tid, type => $_->{btype}, iid => $_->{iid}//0 }) for $data->{boards}->@*;
+ tuwf->dbExeci('INSERT INTO threads_boards', { tid => $tid, type => $_->{btype}, iid => $_->{iid} }) for $data->{boards}->@*;
if($pollchanged) {
tuwf->dbExeci('DELETE FROM threads_poll_options WHERE tid =', \$tid);
@@ -110,7 +106,9 @@ elm_api DiscussionsEdit => $FORM_OUT, $FORM_IN, sub {
TUWF::get qr{(?:/t/(?<board>$BOARD_RE)/new|/$RE{tid}\.1/edit)}, sub {
- my($board_type, $board_id) = (tuwf->capture('board')||'') =~ /^([^0-9]+)([0-9]*)$/;
+ my $board_id = tuwf->capture('board')||'';
+ my($board_type) = $board_id =~ /^([^0-9]+)/;
+ $board_id = undef if $board_id !~ /[0-9]$/;
my $tid = tuwf->capture('id');
$board_type = 'ge' if $board_type && $board_type eq 'an' && !auth->permBoardmod;
@@ -134,13 +132,13 @@ TUWF::get qr{(?:/t/(?<board>$BOARD_RE)/new|/$RE{tid}\.1/edit)}, sub {
} else {
$t->{boards} = [ {
btype => $board_type,
- iid => $board_id||0,
+ iid => $board_id||undef,
title => !$board_id ? undef :
tuwf->dbVali('SELECT title FROM', sql_boards(), 'x WHERE btype =', \$board_type, 'AND iid =', \$board_id)
} ];
return tuwf->resNotFound if $board_id && !length $t->{boards}[0]{title};
push $t->{boards}->@*, { btype => 'u', iid => auth->uid, title => auth->user->{user_name} }
- if $board_type eq 'u' && $board_id != auth->uid;
+ if $board_type eq 'u' && $board_id ne auth->uid;
}
$t->{can_mod} = auth->permBoardmod;
diff --git a/lib/VNWeb/Discussions/Elm.pm b/lib/VNWeb/Discussions/Elm.pm
index 81fe7a9b..8b39560e 100644
--- a/lib/VNWeb/Discussions/Elm.pm
+++ b/lib/VNWeb/Discussions/Elm.pm
@@ -13,11 +13,11 @@ elm_api Boards => undef, {
my sub subq {
my($prio, $where) = @_;
- sql 'SELECT', $prio, ' AS prio, btype, iid, CASE WHEN iid = 0 THEN NULL ELSE title END AS title
+ sql 'SELECT', $prio, ' AS prio, btype, iid, CASE WHEN iid IS NULL THEN NULL ELSE title END AS title
FROM (',
sql_join('UNION ALL',
sql('SELECT btype, iid, title, original FROM', sql_boards(), 'a'),
- map sql('SELECT', \$_, '::board_type, 0,', \$BOARD_TYPE{$_}{txt}, q{, ''}),
+ map sql('SELECT', \$_, '::board_type, NULL,', \$BOARD_TYPE{$_}{txt}, q{, ''}),
grep !$BOARD_TYPE{$_}{dbitem} && ($BOARD_TYPE{$_}{post_perm} eq 'board' || auth->permBoardmod),
keys %BOARD_TYPE
),
@@ -30,8 +30,8 @@ elm_api Boards => undef, {
FROM (',
sql_join('UNION ALL',
# ID match
- $q =~ /^($BOARD_RE)$/ && $q =~ /^([a-z]+)([0-9]*)$/
- ? subq(0, sql_and sql('btype =', \"$1"), $2 ? sql('iid =', \"$2") : ()) : (),
+ $q =~ /^($BOARD_RE)$/ && $q =~ /^(([a-z]+)[0-9]*)$/
+ ? subq(0, sql_and sql('btype =', \"$2"), $1 ne $2 ? sql('iid =', \"$1") : ()) : (),
subq(
sql('1+LEAST(substr_score(lower(title),', \$qs, '), substr_score(lower(original),', \$qs, '))'),
sql('title ILIKE', \"%$qs%", ' OR original ILIKE', \"%$qs%")
diff --git a/lib/VNWeb/Discussions/Index.pm b/lib/VNWeb/Discussions/Index.pm
index 90ac31b1..920aa934 100644
--- a/lib/VNWeb/Discussions/Index.pm
+++ b/lib/VNWeb/Discussions/Index.pm
@@ -23,7 +23,7 @@ TUWF::get qr{/t}, sub {
};
threadlist_
where => sql('t.id IN(SELECT tid FROM threads_boards WHERE type =', \$b, ')'),
- boards => sql('NOT (tb.type =', \$b, 'AND tb.iid = 0)'),
+ boards => sql('NOT (tb.type =', \$b, 'AND tb.iid IS NULL)'),
results => $BOARD_TYPE{$b}{index_rows},
page => 1;
}
diff --git a/lib/VNWeb/Discussions/Lib.pm b/lib/VNWeb/Discussions/Lib.pm
index 986ce90a..574c8c18 100644
--- a/lib/VNWeb/Discussions/Lib.pm
+++ b/lib/VNWeb/Discussions/Lib.pm
@@ -11,7 +11,7 @@ our $BOARD_RE = join '|', map $_.($BOARD_TYPE{$_}{dbitem}?'(?:[1-9][0-9]{0,5})?'
# Returns a WHERE condition to filter threads that the current user is allowed to see.
sub sql_visible_threads {
- return '1=1' if auth && auth->uid == 2; # Yorhel sees everything
+ return '1=1' if auth && auth->uid eq 'u2'; # Yorhel sees everything
sql_and
auth->permBoardmod ? () : ('NOT t.hidden'),
sql('NOT t.private OR EXISTS(SELECT 1 FROM threads_boards WHERE tid = t.id AND type = \'u\' AND iid =', \auth->uid, ')');
@@ -93,7 +93,7 @@ sub threadlist_ {
};
b_ class => 'boards', sub {
join_ ', ', sub {
- a_ href => "/t/$_->{btype}".($_->{iid}||''),
+ a_ href => '/t/'.($_->{iid}||$_->{btype}),
title => $_->{original}||$BOARD_TYPE{$_->{btype}}{txt},
shorten $_->{title}||$BOARD_TYPE{$_->{btype}}{txt}, 30;
}, $l->{boards}->@[0 .. min 4, $#{$l->{boards}}];
diff --git a/lib/VNWeb/Discussions/PostEdit.pm b/lib/VNWeb/Discussions/PostEdit.pm
index 520a215f..e740c029 100644
--- a/lib/VNWeb/Discussions/PostEdit.pm
+++ b/lib/VNWeb/Discussions/PostEdit.pm
@@ -52,7 +52,7 @@ elm_api DiscussionsPostEdit => $FORM_OUT, $FORM_IN, sub {
tuwf->dbExeci('DELETE FROM reviews_posts WHERE id =', \$id, 'AND num =', \$num);
return elm_Redirect "/$id";
}
- auth->audit($t->{user_id}, 'post edit', "edited $id.$num") if $t->{user_id} != auth->uid;
+ auth->audit($t->{user_id}, 'post edit', "edited $id.$num") if $t->{user_id} ne auth->uid;
my $post = {
tid => $id,
diff --git a/lib/VNWeb/Discussions/Thread.pm b/lib/VNWeb/Discussions/Thread.pm
index 94bf7d02..3836bd46 100644
--- a/lib/VNWeb/Discussions/Thread.pm
+++ b/lib/VNWeb/Discussions/Thread.pm
@@ -80,10 +80,10 @@ sub metabox_ {
a_ href => "/t/$_->{btype}", $BOARD_TYPE{$_->{btype}}{txt};
if($_->{iid}) {
txt_ ' > ';
- a_ style => 'font-weight: bold', href => "/t/$_->{btype}$_->{iid}", "$_->{btype}$_->{iid}";
+ a_ style => 'font-weight: bold', href => "/t/$_->{iid}", $_->{iid};
txt_ ':';
if($_->{title}) {
- a_ href => "/$_->{btype}$_->{iid}", title => $_->{original}||$_->{title}, $_->{title};
+ a_ href => "/$_->{iid}", title => $_->{original}||$_->{title}, $_->{title};
} else {
b_ '[deleted]';
}
diff --git a/lib/VNWeb/Discussions/UPosts.pm b/lib/VNWeb/Discussions/UPosts.pm
index d3bfa95c..955f0790 100644
--- a/lib/VNWeb/Discussions/UPosts.pm
+++ b/lib/VNWeb/Discussions/UPosts.pm
@@ -59,7 +59,7 @@ TUWF::get qr{/$RE{uid}/posts}, sub {
FROM ', $sql, 'ORDER BY date DESC'
);
- my $own = auth && $u->{id} == auth->uid;
+ my $own = auth && $u->{id} eq auth->uid;
my $title = $own ? 'My posts' : 'Posts by '.user_displayname $u;
framework_ title => $title, type => 'u', dbobj => $u, tab => 'posts',
sub {
diff --git a/lib/VNWeb/Docs/Edit.pm b/lib/VNWeb/Docs/Edit.pm
index dfab77a3..f4551dae 100644
--- a/lib/VNWeb/Docs/Edit.pm
+++ b/lib/VNWeb/Docs/Edit.pm
@@ -5,7 +5,7 @@ use VNWeb::Docs::Lib;
my $FORM = {
- id => { id => 1 },
+ id => { vndbid => 'd' },
title => { maxlength => 200 },
content => { required => 0, default => '' },
hidden => { anybool => 1 },
@@ -20,12 +20,12 @@ my $FORM_CMP = form_compile cmp => $FORM;
TUWF::get qr{/$RE{drev}/edit} => sub {
- my $d = db_entry d => tuwf->capture('id'), tuwf->capture('rev') or return tuwf->resNotFound;
+ my $d = db_entry tuwf->captures('id', 'rev') or return tuwf->resNotFound;
return tuwf->resDenied if !can_edit d => $d;
- $d->{editsum} = $d->{chrev} == $d->{maxrev} ? '' : "Reverted to revision d$d->{id}.$d->{chrev}";
+ $d->{editsum} = $d->{chrev} == $d->{maxrev} ? '' : "Reverted to revision $d->{id}.$d->{chrev}";
- framework_ title => "Edit $d->{title}", type => 'd', dbobj => $d, tab => 'edit',
+ framework_ title => "Edit $d->{title}", dbobj => $d, tab => 'edit',
sub {
elm_ DocEdit => $FORM_OUT, $d;
};
@@ -34,14 +34,14 @@ TUWF::get qr{/$RE{drev}/edit} => sub {
elm_api DocEdit => $FORM_OUT, $FORM_IN, sub {
my $data = shift;
- my $doc = db_entry d => $data->{id} or return tuwf->resNotFound;
+ my $doc = db_entry $data->{id} or return tuwf->resNotFound;
return elm_Unauth if !can_edit d => $doc;
return elm_Unchanged if !form_changed $FORM_CMP, $data, $doc;
$data->{html} = md2html $data->{content};
- my($id,undef,$rev) = db_edit d => $doc->{id}, $data;
- elm_Redirect "/d$id.$rev";
+ my $c = db_edit d => $doc->{id}, $data;
+ elm_Redirect "/$c->{nitemid}.$c->{nrev}";
};
diff --git a/lib/VNWeb/Docs/Lib.pm b/lib/VNWeb/Docs/Lib.pm
index 6c7351d4..2f2b273c 100644
--- a/lib/VNWeb/Docs/Lib.pm
+++ b/lib/VNWeb/Docs/Lib.pm
@@ -16,7 +16,7 @@ sub _moderators {
xml_string sub {
dl_ sub {
for my $u (@$l) {
- dt_ sub { a_ href => "/u$u->{id}", $u->{username} };
+ dt_ sub { a_ href => "/$u->{id}", $u->{username} };
dd_ @special_perms == grep($u->{"perm_$_"}, @special_perms) ? 'admin'
: join ', ', grep $u->{"perm_$_"}, @special_perms;
}
@@ -35,7 +35,7 @@ sub _skincontrib {
xml_string sub {
dl_ sub {
for my $u (@$u) {
- dt_ sub { a_ href => "/u$u->{id}", $u->{username} };
+ dt_ sub { a_ href => "/$u->{id}", $u->{username} };
dd_ sub {
join_ ', ', sub { a_ href => "?skin=$_->[0]", $_->[1] }, $users{$u->{id}}->@*
}
diff --git a/lib/VNWeb/Docs/Page.pm b/lib/VNWeb/Docs/Page.pm
index eeda0d00..29b7ec5a 100644
--- a/lib/VNWeb/Docs/Page.pm
+++ b/lib/VNWeb/Docs/Page.pm
@@ -32,21 +32,21 @@ sub _index_ {
sub _rev_ {
my $d = shift;
- revision_ d => $d, sub {},
+ revision_ $d, sub {},
[ title => 'Title' ],
[ content => 'Contents' ];
}
TUWF::get qr{/$RE{drev}} => sub {
- my $d = db_entry d => tuwf->capture('id'), tuwf->capture('rev');
+ my $d = db_entry tuwf->captures('id', 'rev');
return tuwf->resNotFound if !$d;
- framework_ title => $d->{title}, index => !tuwf->capture('rev'), type => 'd', dbobj => $d, hiddenmsg => 1,
+ framework_ title => $d->{title}, index => !tuwf->capture('rev'), dbobj => $d, hiddenmsg => 1,
sub {
_rev_ $d if tuwf->capture('rev');
div_ class => 'mainbox', sub {
- itemmsg_ d => $d;
+ itemmsg_ $d;
h1_ $d->{title};
div_ class => 'docs', sub {
_index_;
diff --git a/lib/VNWeb/Elm.pm b/lib/VNWeb/Elm.pm
index 04a05100..62f7aaf0 100644
--- a/lib/VNWeb/Elm.pm
+++ b/lib/VNWeb/Elm.pm
@@ -58,7 +58,7 @@ our %apis = (
name => {},
} } ],
Releases => [ { aoh => { # Response to 'Release'
- id => { id => 1 },
+ id => { vndbid => 'r' },
title => {},
original => { required => 0, default => '' },
released => { uint => 1 },
@@ -77,8 +77,8 @@ our %apis = (
count => { uint => 1 },
} } ],
BoardResult => [ { aoh => { # Response to 'Boards'
- btype => {},
- iid => { required => 0, default => 0, id => 1 },
+ btype => { enum => \%BOARD_TYPE },
+ iid => { required => 0, vndbid => ['p','v','u'] },
title => { required => 0 },
} } ],
TagResult => [ { aoh => { # Response to 'Tags'
@@ -99,29 +99,29 @@ our %apis = (
group_name => { required => 0 },
} } ],
VNResult => [ { aoh => { # Response to 'VN'
- id => { id => 1 },
+ id => { vndbid => 'v' },
title => {},
original => { required => 0, default => '' },
hidden => { anybool => 1 },
} } ],
ProducerResult => [ { aoh => { # Response to 'Producers'
- id => { id => 1 },
+ id => { vndbid => 'p' },
name => {},
original => { required => 0, default => '' },
hidden => { anybool => 1 },
} } ],
StaffResult => [ { aoh => { # Response to 'Staff'
- id => { id => 1 },
+ id => { vndbid => 's' },
aid => { id => 1 },
name => {},
original => { required => 0, default => '' },
} } ],
CharResult => [ { aoh => { # Response to 'Chars'
- id => { id => 1 },
+ id => { vndbid => 'c' },
name => {},
original => { required => 0, default => '' },
main => { required => 0, type => 'hash', keys => {
- id => { id => 1 },
+ id => { vndbid => 'c' },
name => {},
original => { required => 0, default => '' },
} }
@@ -132,7 +132,7 @@ our %apis = (
original => { required => 0, default => '' },
} } ],
ImageResult => [ { aoh => { # Response to 'Images'
- id => { }, # image id...
+ id => { vndbid => ['ch','cv','sf'] },
token => { required => 0 },
width => { uint => 1 },
height => { uint => 1 },
@@ -150,7 +150,7 @@ our %apis = (
} },
votes => { unique => 0, aoh => {
user => {},
- uid => { uint => 1, required => 0 },
+ uid => { vndbid => 'u', required => 0 },
sexual => { uint => 1 },
violence => { uint => 1 },
ignore => { anybool => 1 },
diff --git a/lib/VNWeb/Graph.pm b/lib/VNWeb/Graph.pm
index 1e826a70..d25bd61c 100644
--- a/lib/VNWeb/Graph.pm
+++ b/lib/VNWeb/Graph.pm
@@ -9,6 +9,7 @@ use Encode 'encode_utf8', 'decode_utf8';
use Exporter 'import';
use List::Util 'max';
use VNDB::Config;
+use VNDB::Func 'idcmp';
our @EXPORT = qw/gen_nodes dot2svg val_escape node_more gen_dot/;
@@ -91,7 +92,7 @@ sub gen_dot {
my $rankdir = $max_fanout > 6 ? 'LR' : 'TB';
for (@$rel) {
- next if $_->{id0} < $_->{id1};
+ next if idcmp($_->{id0}, $_->{id1}) < 0;
my $r1 = $rel_types->{$_->{relation}};
my $r2 = $rel_types->{ $r1->{reverse} };
my $style = exists $_->{official} && !$_->{official} ? 'style="dotted", ' : '';
diff --git a/lib/VNWeb/HTML.pm b/lib/VNWeb/HTML.pm
index 8d9c21eb..132e46fa 100644
--- a/lib/VNWeb/HTML.pm
+++ b/lib/VNWeb/HTML.pm
@@ -75,7 +75,7 @@ sub user_ {
return b_ class => 'grayedout', 'anonymous' if !f 'id';
my $fancy = !(auth->pref('nodistract_can') && auth->pref('nodistract_nofancy'));
my $uniname = f 'uniname_can' && f 'uniname';
- a_ href => '/u'.f('id'),
+ a_ href => '/'.f('id'),
$fancy && $uniname ? (title => f('name'), $uniname) :
(!$fancy && $uniname ? (title => $uniname) : (), $capital ? ucfirst f 'name' : f 'name');
txt_ '⭐' if $fancy && f 'support_can' && f 'support_enabled';
@@ -229,7 +229,7 @@ sub _menu_ {
};
div_ class => 'menubox', sub {
- my $uid = sprintf '/u%d', auth->uid;
+ my $uid = '/'.auth->uid;
my $nc = auth && tuwf->dbVali('SELECT count(*) FROM notifications WHERE uid =', \auth->uid, 'AND read IS NULL');
h2_ sub { user_ auth->user, 'user_', 1 };
div_ sub {
@@ -303,7 +303,7 @@ sub _footer_ {
my $q = tuwf->dbRow('SELECT vid, quote FROM quotes ORDER BY RANDOM() LIMIT 1');
if($q && $q->{vid}) {
lit_ '"';
- a_ href => "/v$q->{vid}", style => 'text-decoration: none', $q->{quote};
+ a_ href => "/$q->{vid}", style => 'text-decoration: none', $q->{quote};
txt_ '"';
br_;
}
@@ -357,7 +357,7 @@ sub _maintabs_subscribe_ {
) x(x)')
: $id =~ /^[vrpcsd]/ && auth->pref('notify_dbedit') && tuwf->dbVali('
- SELECT 1 FROM changes WHERE type = vndbid_type(', \$id, ')::dbentry_type AND itemid = vndbid_num(', \$id, ') AND requester =', \auth->uid);
+ SELECT 1 FROM changes WHERE itemid =', \$id, 'AND requester =', \auth->uid);
my $sub = tuwf->dbRowi('SELECT subnum, subreview, subapply FROM notification_subs WHERE uid =', \auth->uid, 'AND iid =', \$id);
@@ -415,7 +415,7 @@ sub _maintabs_ {
SELECT COUNT(*)
FROM threads_boards tb
JOIN threads t ON t.id = tb.tid
- WHERE tb.type =}, \$t, 'AND tb.iid =', \$o->{id}, 'AND', VNWeb::Discussions::Lib::sql_visible_threads());
+ WHERE tb.type =}, \$t, 'AND tb.iid =', \$o->{id}, ' AND', VNWeb::Discussions::Lib::sql_visible_threads());
t disc => "/t/$id", "discussions ($cnt)";
};
@@ -429,9 +429,9 @@ sub _maintabs_ {
# Attempt to figure out the board id from a database entry ($type, $dbobj) combination
sub _board_id {
my($type, $obj) = @_;
- $type =~ /[vp]/ ? $type.$obj->{id} :
- $type eq 'r' && $obj->{vn}->@* ? 'v'.$obj->{vn}[0]{vid} :
- $type eq 'c' && $obj->{vns}->@* ? 'v'.$obj->{vns}[0]{vid} : 'db';
+ $type =~ /[vp]/ ? $obj->{id} :
+ $type eq 'r' && $obj->{vn}->@* ? $obj->{vn}[0]{vid} :
+ $type eq 'c' && $obj->{vns}->@* ? $obj->{vns}[0]{vid} : 'db';
}
@@ -445,7 +445,7 @@ sub _hidden_msg_ {
my $msg = tuwf->dbVali(
'SELECT comments
FROM changes
- WHERE', { type => $o->{type}, itemid => $o->{dbobj}{id} },
+ WHERE itemid =', \$o->{dbobj}{id},
'ORDER BY id DESC LIMIT 1'
);
div_ class => 'mainbox', sub {
@@ -455,7 +455,7 @@ sub _hidden_msg_ {
p_ sub {
if($o->{type} eq 'r' && $o->{dbobj}{vn}) {
txt_ 'This was a release entry for ';
- join_ ',', sub { a_ href => "/v$_->{vid}", $_->{title} }, $o->{dbobj}{vn}->@*;
+ join_ ',', sub { a_ href => "/$_->{vid}", $_->{title} }, $o->{dbobj}{vn}->@*;
txt_ '.';
br_;
}
@@ -479,7 +479,7 @@ sub _hidden_msg_ {
# js => 1/0, set to 1 to ensure 'plain.js' is included on the page even if no elm_() modules are loaded.
# search => $query
# og => { opengraph metadata }
-# type => Database entry type (used for the main tabs & hidden message)
+# type => Database entry type (used for the main tabs & hidden message) (obsolete, inferred from dbobj->{id})
# dbobj => Database entry object (used for the main tabs & hidden message)
# Recognized object fields: id, entry_hidden, entry_locked
# tab => Current tab, or empty for the main tab
@@ -491,6 +491,7 @@ sub framework_ {
my %o = @_;
tuwf->req->{pagevars} = { $o{pagevars}->%* } if $o{pagevars};
tuwf->req->{js} ||= $o{js};
+ $o{type} ||= $1 if $o{dbobj} && $o{dbobj}{id} =~ /^([a-z])/;
html_ lang => 'en', sub {
head_ sub { _head_ \%o };
@@ -517,15 +518,15 @@ sub framework_ {
sub _revision_header_ {
- my($type, $obj) = @_;
+ my($obj) = @_;
b_ "Revision $obj->{chrev}";
debug_ $obj;
if(auth) {
lit_ ' (';
- a_ href => "/$type$obj->{id}.$obj->{chrev}/edit", $obj->{chrev} == $obj->{maxrev} ? 'edit' : 'revert to';
+ a_ href => "/$obj->{id}.$obj->{chrev}/edit", $obj->{chrev} == $obj->{maxrev} ? 'edit' : 'revert to';
if($obj->{rev_user_id}) {
lit_ ' / ';
- a_ href => "/t/u$obj->{rev_user_id}/new?title=Regarding%20$type$obj->{id}.$obj->{chrev}", 'msg user';
+ a_ href => "/t/$obj->{rev_user_id}/new?title=Regarding%20$obj->{id}.$obj->{chrev}", 'msg user';
}
lit_ ')';
}
@@ -613,7 +614,7 @@ sub _stringify_scalars_rec {
}
sub _revision_diff_ {
- my($type, $old, $new, $field, $name, %opt) = @_;
+ my($old, $new, $field, $name, %opt) = @_;
# First do a diff on the raw field elements.
# (if the field is a scalar, it's considered a single element and the diff just tests equality)
@@ -647,14 +648,14 @@ sub _revision_diff_ {
sub _revision_cmp_ {
- my($type, $old, $new, @fields) = @_;
+ my($old, $new, @fields) = @_;
table_ class => 'stripe', sub {
thead_ sub {
tr_ sub {
td_ ' ';
- td_ sub { _revision_header_ $type, $old };
- td_ sub { _revision_header_ $type, $new };
+ td_ sub { _revision_header_ $old };
+ td_ sub { _revision_header_ $new };
};
tr_ sub {
td_ ' ';
@@ -666,7 +667,7 @@ sub _revision_cmp_ {
};
};
};
- _revision_diff_ $type, $old, $new, @$_ for(
+ _revision_diff_ $old, $new, @$_ for(
[ hidden => 'Hidden', fmt => 'bool' ],
[ locked => 'Locked', fmt => 'bool' ],
@fields,
@@ -677,7 +678,7 @@ sub _revision_cmp_ {
# Revision info box.
#
-# Arguments: $type, $object, \&enrich_for_diff, @fields
+# Arguments: $object, \&enrich_for_diff, @fields
#
# The given $object is assumed to originate from VNWeb::DB::db_entry() and
# should have the 'id', 'hidden', 'locked', 'chrev' and 'maxrev' fields in
@@ -702,9 +703,9 @@ sub _revision_cmp_ {
# empty => str - What value should be considered "empty", e.g. (empty => 0) for integer fields.
# undef or empty string are always considered empty values.
sub revision_ {
- my($type, $new, $enrich, @fields) = @_;
+ my($new, $enrich, @fields) = @_;
- my $old = $new->{chrev} == 1 ? undef : db_entry $type, $new->{id}, $new->{chrev} - 1;
+ my $old = $new->{chrev} == 1 ? undef : db_entry $new->{id}, $new->{chrev} - 1;
$enrich->($old) if $old;
enrich_merge chid => sql(
@@ -716,19 +717,19 @@ sub revision_ {
div_ class => 'mainbox revision', sub {
h1_ "Revision $new->{chrev}";
- a_ class => 'prev', href => sprintf('/%s%d.%d', $type, $new->{id}, $new->{chrev}-1), '<- earlier revision' if $new->{chrev} > 1;
- a_ class => 'next', href => sprintf('/%s%d.%d', $type, $new->{id}, $new->{chrev}+1), 'later revision ->' if $new->{chrev} < $new->{maxrev};
- p_ class => 'center', sub { a_ href => "/$type$new->{id}", $type.$new->{id} };
+ a_ class => 'prev', href => sprintf('/%s.%d', $new->{id}, $new->{chrev}-1), '<- earlier revision' if $new->{chrev} > 1;
+ a_ class => 'next', href => sprintf('/%s.%d', $new->{id}, $new->{chrev}+1), 'later revision ->' if $new->{chrev} < $new->{maxrev};
+ p_ class => 'center', sub { a_ href => "/$new->{id}", $new->{id} };
div_ class => 'rev', sub {
- _revision_header_ $type, $new;
+ _revision_header_ $new;
br_;
b_ 'Edit summary';
br_; br_;
lit_ bb_format $new->{rev_comments}||'-';
} if !$old;
- _revision_cmp_ $type, $old, $new, @fields if $old;
+ _revision_cmp_ $old, $new, @fields if $old;
};
}
@@ -814,17 +815,16 @@ sub searchbox_ {
# Generate a message to display on an entry page to report the entry and to indicate it has been locked or the user can't edit it.
sub itemmsg_ {
- my($type, $obj) = @_;
+ my($obj) = @_;
p_ class => 'itemmsg', sub {
- if($type ne 'd' && $type ne 'w') {
+ if($obj->{id} !~ /^[dw]/) {
if($obj->{entry_locked}) {
txt_ 'Locked for editing. ';
- } elsif(auth && !can_edit $type => $obj) {
+ } elsif(auth && !can_edit(($obj->{id} =~ /^(.)/), $obj)) {
txt_ 'You can not edit this page. ';
}
}
- my $id = $obj->{id} =~ /^[0-9]*$/ ? "$type$obj->{id}" : $obj->{id};
- a_ href => "/report/$id", 'Report an issue on this page.';
+ a_ href => "/report/$obj->{id}", 'Report an issue on this page.';
};
}
@@ -848,7 +848,7 @@ sub editmsg_ {
h2_ "You're not editing an entry!";
p_ sub {;
txt_ "You're about to insert a new entry into the database with information based on ";
- a_ href => "/$type$obj->{id}", "$type$obj->{id}";
+ a_ href => "/$obj->{id}", $obj->{id};
txt_ '.';
br_;
txt_ "Hit the 'edit' tab on the right-top if you intended to edit the entry instead of creating a new one.";
@@ -878,7 +878,7 @@ sub editmsg_ {
# TODO: Include a list of the most recent edits in this page.
li_ sub {
txt_ 'Browse the ';
- a_ href => "/$type$obj->{id}/hist", 'edit history';
+ a_ href => "/$obj->{id}/hist", 'edit history';
txt_ ' for any recent changes related to what you want to change.';
};
} elsif($type ne 'r') {
diff --git a/lib/VNWeb/Images/Lib.pm b/lib/VNWeb/Images/Lib.pm
index 157b9679..25de1b13 100644
--- a/lib/VNWeb/Images/Lib.pm
+++ b/lib/VNWeb/Images/Lib.pm
@@ -25,7 +25,7 @@ sub enrich_image {
, i.c_violence_avg AS violence_avg, i.c_violence_stddev AS violence_stddev
, iv.sexual AS my_sexual, iv.violence AS my_violence
, COALESCE(EXISTS(SELECT 1 FROM image_votes iv0 WHERE iv0.id = i.id AND iv0.ignore) AND NOT iv.ignore, FALSE) AS my_overrule
- , COALESCE('v'||v.id, 'c'||c.id, 'v'||vsv.id) AS entry_id
+ , COALESCE(v.id, c.id, vsv.id) AS entry_id
, COALESCE(v.title, c.name, vsv.title) AS entry_title
FROM images i
LEFT JOIN image_votes iv ON iv.id = i.id AND iv.uid =}, \auth->uid, q{
diff --git a/lib/VNWeb/Images/List.pm b/lib/VNWeb/Images/List.pm
index 69925f99..132386b6 100644
--- a/lib/VNWeb/Images/List.pm
+++ b/lib/VNWeb/Images/List.pm
@@ -29,7 +29,7 @@ sub graph_ {
$y = 13;
line_ 'Avg', $avg-$stddev, $avg, $avg+$stddev if defined $avg;
line_ 'User', $user, $user, $avg if defined $user;
- line_ 'My', $my, $my, $avg if defined $my && $opt->{u} != $opt->{u2};
+ line_ 'My', $my, $my, $avg if defined $my && $opt->{u} ne $opt->{u2};
}
tag_ 'svg', width => '190px', height => '100px', viewBox => '0 0 190 100', sub {
@@ -76,7 +76,7 @@ sub opts_ {
form_ sub {
input_ type => 'hidden', class => 'hidden', name => 'u', value => $opt->{u} if $opt->{u};
- input_ type => 'hidden', class => 'hidden', name => 'u2', value => $opt->{u2} if $opt->{u2} != (auth->uid||0);
+ input_ type => 'hidden', class => 'hidden', name => 'u2', value => $opt->{u2} if $opt->{u2} ne (auth->uid||'');
input_ type => 'hidden', class => 'hidden', name => 'view', value => viewset(show_nsfw => viewget('show_nsfw'));
table_ style => 'margin: auto', sub {
tr_ sub {
@@ -98,7 +98,7 @@ sub opts_ {
tr_ sub {
td_ '';
td_ class => 'linkradio', sub { opt_ checkbox => my => 1, 'Only images I voted on' };
- } if auth && $opt->{u} != $opt->{u2};
+ } if auth && $opt->{u} ne $opt->{u2};
tr_ sub {
td_ 'Time filter';
td_ class => 'linkradio', sub {
@@ -136,13 +136,13 @@ TUWF::get qr{/img/list}, sub {
t => { onerror => [], scalar => 1, type => 'array', values => { enum => [qw/ ch cv sf /] } },
m => { onerror => 0, range => [0,10] },
d => { onerror => 0, range => [0,10000] },
- u => { onerror => 0, id => 1 },
- u2 => { onerror => 0, id => 1 }, # Hidden option, allows comparing two users by overriding the 'My' user.
+ u => { onerror => '', vndbid => 'u' },
+ u2 => { onerror => '', vndbid => 'u' }, # Hidden option, allows comparing two users by overriding the 'My' user.
my => { anybool => 1 },
p => { page => 1 },
)->data;
- $opt->{u2} ||= auth->uid || 0;
+ $opt->{u2} ||= auth->uid || '';
$opt->{s} = 'weight' if !$opt->{u} && ($opt->{s} eq 'date' || $opt->{s} eq 'diff');
$opt->{t} = [ List::Util::uniq sort $opt->{t}->@* ];
$opt->{t} = [] if $opt->{t}->@* == 3;
@@ -163,7 +163,7 @@ TUWF::get qr{/img/list}, sub {
$opt->{u} ? ', iu.sexual as user_sexual, iu.violence as user_violence' : (), '
FROM images i',
$opt->{u} ? ('JOIN image_votes iu ON iu.uid =', \$opt->{u}, ' AND iu.id = i.id') : (),
- $opt->{my} ? () : 'LEFT', 'JOIN image_votes iv ON iv.uid =', \$opt->{u2}, ' AND iv.id = i.id
+ $opt->{my} ? () : 'LEFT', 'JOIN image_votes iv ON iv.uid =', \($opt->{u2}||undef), ' AND iv.id = i.id
WHERE', $where, '
ORDER BY', {
weight => 'i.c_weight DESC',
diff --git a/lib/VNWeb/Images/Vote.pm b/lib/VNWeb/Images/Vote.pm
index aba0342f..ad320155 100644
--- a/lib/VNWeb/Images/Vote.pm
+++ b/lib/VNWeb/Images/Vote.pm
@@ -45,7 +45,7 @@ elm_api Images => $SEND, { excl_voted => { anybool => 1 } }, sub {
SELECT id
FROM images TABLESAMPLE SYSTEM (', \$tablesample, ')
WHERE c_weight > 0',
- $data->{excl_voted} ? ('AND NOT (c_uids && ARRAY[', \auth->uid, '::int])') : (), '
+ $data->{excl_voted} ? ('AND NOT (c_uids && ARRAY[', \auth->uid, '::vndbid])') : (), '
ORDER BY random() ^ (1.0/c_weight) DESC
LIMIT', \30
);
diff --git a/lib/VNWeb/Misc/Feeds.pm b/lib/VNWeb/Misc/Feeds.pm
index fdc6606c..ed58b37e 100644
--- a/lib/VNWeb/Misc/Feeds.pm
+++ b/lib/VNWeb/Misc/Feeds.pm
@@ -27,7 +27,7 @@ sub feed {
tag published => datetime $_->{published} if $_->{published};
tag author => sub {
tag name => $_->{user_name};
- tag uri => "$base/u$_->{user_id}";
+ tag uri => "$base/$_->{user_id}";
} if $_->{user_id};
tag link => rel => 'alternate', type => 'text/html', href => "$base/$_->{id}", undef;
tag summary => type => 'html', bb_format $_->{summary}, maxlength => 300 if $_->{summary};
@@ -52,9 +52,9 @@ TUWF::get qr{/feeds/announcements.atom}, sub {
TUWF::get qr{/feeds/changes.atom}, sub {
- my($lst) = VNWeb::Misc::History::fetch(undef, undef, {m=>1,h=>1,p=>1}, {results=>25});
+ my($lst) = VNWeb::Misc::History::fetch(undef, {m=>1,h=>1,p=>1}, {results=>25});
for (@$lst) {
- $_->{id} = "$_->{type}$_->{itemid}.$_->{rev}";
+ $_->{id} = "$_->{itemid}.$_->{rev}";
$_->{summary} = $_->{comments};
$_->{updated} = $_->{added};
}
diff --git a/lib/VNWeb/Misc/History.pm b/lib/VNWeb/Misc/History.pm
index cd94c28f..f8e15f27 100644
--- a/lib/VNWeb/Misc/History.pm
+++ b/lib/VNWeb/Misc/History.pm
@@ -5,32 +5,27 @@ use VNWeb::Prelude;
# Also used by Misc::HomePage and Misc::Feeds
sub fetch {
- my($type, $id, $filt, $opt) = @_;
+ my($id, $filt, $opt) = @_;
my $where = sql_and
- !$type ? ()
- : $type eq 'u' ? sql 'c.requester =', \$id
- : sql_or(
- sql('c.type =', \$type, ' AND c.itemid =', \$id),
+ !$id ? ()
+ : $id =~ /^u/ ? sql 'c.requester =', \$id
+ : $id =~ /^v/ && $filt->{r} ? sql 'c.itemid =', \$id, 'OR c.id IN(SELECT chid FROM releases_vn_hist WHERE vid =', \$id, ')' # This may need an index on releases_vn_hist.vid
+ : sql('c.itemid =', \$id),
- # This may need an index on releases_vn_hist.vid
- $type eq 'v' && $filt->{r} ?
- sql 'c.id IN(SELECT chid FROM releases_vn_hist WHERE vid =', \$id, ')' : ()
- ),
-
- $filt->{t} && $filt->{t}->@* ? sql 'c.type IN', \$filt->{t} : (),
- $filt->{m} ? sql 'c.requester IS DISTINCT FROM 1' : (),
+ $filt->{t} && $filt->{t}->@* ? sql_or map sql('c.itemid BETWEEN vndbid(', \"$_", ',1) AND vndbid_max(', \"$_", ')'), $filt->{t}->@* : (),
+ $filt->{m} ? sql 'c.requester IS DISTINCT FROM \'u1\'' : (),
$filt->{e} && $filt->{e} == 1 ? sql 'c.rev <> 1' : (),
$filt->{e} && $filt->{e} ==-1 ? sql 'c.rev = 1' : (),
$filt->{h} ? sql $filt->{h} == 1 ? 'NOT' : '',
'EXISTS(SELECT 1 FROM changes c_i
- WHERE c_i.type = c.type AND c_i.itemid = c.itemid AND c_i.ihid
- AND c_i.rev = (SELECT MAX(c_ii.rev) FROM changes c_ii WHERE c_ii.type = c.type AND c_ii.itemid = c.itemid))' : ();
+ WHERE c_i.itemid = c.itemid AND c_i.ihid
+ AND c_i.rev = (SELECT MAX(c_ii.rev) FROM changes c_ii WHERE c_ii.itemid = c.itemid))' : ();
my($lst, $np) = tuwf->dbPagei({ page => $filt->{p}, results => $opt->{results}||50 }, q{
- SELECT c.id, c.type, c.itemid, c.comments, c.rev,}, sql_totime('c.added'), q{ AS added, }, sql_user(), q{
+ SELECT c.id, c.itemid, c.comments, c.rev,}, sql_totime('c.added'), q{ AS added, }, sql_user(), q{
FROM changes c
LEFT JOIN users u ON c.requester = u.id
WHERE}, $where, q{
@@ -55,9 +50,9 @@ sub fetch {
# Also used by User::Page.
# %opt: nopage => 1/0, results => $num
sub tablebox_ {
- my($type, $id, $filt, %opt) = @_;
+ my($id, $filt, %opt) = @_;
- my($lst, $np) = fetch $type, $id, $filt, \%opt;
+ my($lst, $np) = fetch $id, $filt, \%opt;
my sub url { '?'.query_encode %$filt, p => $_ }
@@ -73,9 +68,9 @@ sub tablebox_ {
}};
tr_ sub {
my $i = $_;
- my $revurl = "/$i->{type}$i->{itemid}.$i->{rev}";
+ my $revurl = "/$i->{itemid}.$i->{rev}";
- td_ class => 'tc1_1', sub { a_ href => $revurl, "$i->{type}$i->{itemid}" };
+ td_ class => 'tc1_1', sub { a_ href => $revurl, $i->{itemid} };
td_ class => 'tc1_2', sub { a_ href => $revurl, ".$i->{rev}" };
td_ class => 'tc2', fmtdate $i->{added}, 'full';
td_ class => 'tc3', sub { user_ $i };
@@ -168,23 +163,21 @@ sub filters_ {
}
-TUWF::get qr{/(?:([upvrcsd])([1-9]\d*)/)?hist} => sub {
- my($type, $id) = (tuwf->capture(1)||'', tuwf->capture(2));
-
- my $obj = dbobj $type, $id;
+TUWF::get qr{/(?:([upvrcsd][1-9][0-9]{0,6})/)?hist} => sub {
+ my $id = tuwf->capture(1)||'';
+ my $obj = dbobj $id;
- return tuwf->resNotFound if $type && !$obj->{id};
- $obj->{title} = user_displayname $obj if $type eq 'u';
+ return tuwf->resNotFound if $id && !$obj->{id};
- my $title = $type ? "Edit history of $obj->{title}" : 'Recent changes';
- framework_ title => $title, type => $type, dbobj => $obj, tab => 'hist',
+ my $title = $id ? "Edit history of $obj->{title}" : 'Recent changes';
+ framework_ title => $title, dbobj => $obj, tab => 'hist',
sub {
my $filt;
div_ class => 'mainbox', sub {
h1_ $title;
- $filt = filters_ $type;
+ $filt = filters_($id =~ /^(.)/ or '');
};
- tablebox_ $type, $id, $filt;
+ tablebox_ $id, $filt;
};
};
diff --git a/lib/VNWeb/Misc/HomePage.pm b/lib/VNWeb/Misc/HomePage.pm
index bcf7052f..c591568a 100644
--- a/lib/VNWeb/Misc/HomePage.pm
+++ b/lib/VNWeb/Misc/HomePage.pm
@@ -32,7 +32,7 @@ sub screens_ {
);
p_ class => 'screenshots', sub {
- a_ href => "/v$_->{vid}", title => $_->{title}, sub {
+ a_ href => "/$_->{vid}", title => $_->{title}, sub {
my($w, $h) = imgsize $_->{width}, $_->{height}, config->{scr_size}->@*;
img_ src => imgurl($_->{id}, 1), alt => $_->{title}, width => $w, height => $h;
} for @$lst;
@@ -41,7 +41,7 @@ sub screens_ {
sub recent_changes_ {
- my($lst) = VNWeb::Misc::History::fetch(undef, undef, {m=>1,h=>1,p=>1}, {results=>10});
+ my($lst) = VNWeb::Misc::History::fetch(undef, {m=>1,h=>1,p=>1}, {results=>10});
h1_ sub {
a_ href => '/hist', 'Recent Changes'; txt_ ' ';
a_ href => '/feeds/changes.atom', sub { abbr_ class => 'icons feed', title => 'Atom Feed', '' };
@@ -49,8 +49,8 @@ sub recent_changes_ {
ul_ sub {
li_ sub {
span_ sub {
- txt_ "$_->{type}:";
- a_ href => "/$_->{type}$_->{itemid}.$_->{rev}", title => $_->{original}||$_->{title}, $_->{title};
+ txt_ "$1:" if $_->{itemid} =~ /^(.)/;
+ a_ href => "/$_->{itemid}.$_->{rev}", title => $_->{original}||$_->{title}, $_->{title};
};
span_ sub {
lit_ " by ";
@@ -192,7 +192,7 @@ sub releases_ {
abbr_ class => "icons $_", title => $PLATFORM{$_}, '' for $_->{plat}->@*;
abbr_ class => "icons lang $_", title => $LANGUAGE{$_}, '' for $_->{lang}->@*;
txt_ ' ';
- a_ href => "/r$_->{id}", title => $_->{original}||$_->{title}, $_->{title};
+ a_ href => "/$_->{id}", title => $_->{original}||$_->{title}, $_->{title};
}
} for @$lst;
};
diff --git a/lib/VNWeb/Misc/Redirects.pm b/lib/VNWeb/Misc/Redirects.pm
index 636a766c..72ba7369 100644
--- a/lib/VNWeb/Misc/Redirects.pm
+++ b/lib/VNWeb/Misc/Redirects.pm
@@ -21,9 +21,9 @@ TUWF::get qr{/u/list(/[a-z0]|/all)?}, sub { tuwf->resRedirect('/u'.(tuwf->captur
TUWF::get qr{/$RE{uid}/tags}, sub { tuwf->resRedirect('/g/links?u='.tuwf->capture('id'), 'perm') };
-TUWF::get qr{/$RE{vid}/staff}, sub { tuwf->resRedirect(sprintf '/v%s#staff', tuwf->capture('id')) };
-TUWF::get qr{/$RE{vid}/stats}, sub { tuwf->resRedirect(sprintf '/v%s#stats', tuwf->capture('id')) };
-TUWF::get qr{/$RE{vid}/scr}, sub { tuwf->resRedirect(sprintf '/v%s#screenshots', tuwf->capture('id')) };
+TUWF::get qr{/$RE{vid}/staff}, sub { tuwf->resRedirect(sprintf '/%s#staff', tuwf->capture('id')) };
+TUWF::get qr{/$RE{vid}/stats}, sub { tuwf->resRedirect(sprintf '/%s#stats', tuwf->capture('id')) };
+TUWF::get qr{/$RE{vid}/scr}, sub { tuwf->resRedirect(sprintf '/%s#screenshots', tuwf->capture('id')) };
TUWF::get qr{/v/rand}, sub {
@@ -38,7 +38,7 @@ TUWF::get qr{/v/rand}, sub {
ORDER BY random() LIMIT 1'
);
return tuwf->resNotFound if !$vn;
- tuwf->resRedirect("/v$vn", 'temp');
+ tuwf->resRedirect("/$vn", 'temp');
};
1;
diff --git a/lib/VNWeb/Misc/Reports.pm b/lib/VNWeb/Misc/Reports.pm
index c275efa9..3697922f 100644
--- a/lib/VNWeb/Misc/Reports.pm
+++ b/lib/VNWeb/Misc/Reports.pm
@@ -48,13 +48,12 @@ sub enrich_object {
user_ $post;
} if $post->{num};
- } elsif($o->{object} =~ /^([vrpcsd])$RE{num}$/ && !defined $o->{objectnum}) {
- my($t,$id) = ($1, $+{num});
- my $obj = dbobj $t, $id;
+ } elsif($o->{object} =~ /^([vrpcsd]$RE{num})$/ && !defined $o->{objectnum}) {
+ my $obj = dbobj $1;
$o->{title} = xml_string sub {
- txt_ {qw/v VN r Release p Producer c Character s Staff d Doc/}->{$t};
+ txt_ {qw/v VN r Release p Producer c Character s Staff d Doc/}->{substr $obj->{id}, 0, 1};
txt_ ': ';
- a_ href => "/$t$id", $obj->{title};
+ a_ href => "/$obj->{id}", $obj->{title};
} if $obj->{id};
}
}
@@ -119,9 +118,9 @@ sub report_ {
b_ class => 'grayedout', ' '.fmtdate $r->{date}, 'full';
txt_ ' by ';
if($r->{uid}) {
- a_ href => "/u$r->{uid}", $r->{username};
+ a_ href => "/$r->{uid}", $r->{username};
txt_ ' (';
- a_ href => "/t/u$r->{uid}/new?title=Regarding your report on $objid&priv=1", 'pm';
+ a_ href => "/t/$r->{uid}/new?title=Regarding your report on $objid&priv=1", 'pm';
txt_ ')';
} else {
txt_ $r->{ip}||'[anonymous]';
diff --git a/lib/VNWeb/Prelude.pm b/lib/VNWeb/Prelude.pm
index ca7a423e..5a893232 100644
--- a/lib/VNWeb/Prelude.pm
+++ b/lib/VNWeb/Prelude.pm
@@ -71,80 +71,60 @@ sub import {
no strict 'refs';
*{$c.'::RE'} = *RE;
- *{$c.'::in'} = \&in;
- *{$c.'::idcmp'} = \&idcmp;
*{$c.'::dbobj'} = \&dbobj;
}
# Regular expressions for use in path registration
my $num = qr{[1-9][0-9]{0,6}}; # Allow up to 10 mil, SQL vndbid type can't handle more than 2^26-1 (~ 67 mil).
-my $id = qr{(?<id>$num)};
my $rev = qr{(?:\.(?<rev>$num))};
our %RE = (
num => qr{(?<num>$num)},
- uid => qr{u$id},
- vid => qr{v$id},
- rid => qr{r$id},
- sid => qr{s$id},
- cid => qr{c$id},
- pid => qr{p$id},
- iid => qr{i$id},
- did => qr{d$id},
+ uid => qr{(?<id>u$num)},
+ vid => qr{(?<id>v$num)},
+ rid => qr{(?<id>r$num)},
+ sid => qr{(?<id>s$num)},
+ cid => qr{(?<id>c$num)},
+ pid => qr{(?<id>p$num)},
+ iid => qr{i(?<id>$num)},
+ did => qr{(?<id>d$num)},
tid => qr{(?<id>t$num)},
- gid => qr{g$id},
+ gid => qr{g(?<id>$num)},
wid => qr{(?<id>w$num)},
imgid=> qr{(?<id>(?:ch|cv|sf)$num)},
- vrev => qr{v$id$rev?},
- rrev => qr{r$id$rev?},
- prev => qr{p$id$rev?},
- srev => qr{s$id$rev?},
- crev => qr{c$id$rev?},
- drev => qr{d$id$rev?},
+ vrev => qr{(?<id>v$num)$rev?},
+ rrev => qr{(?<id>r$num)$rev?},
+ prev => qr{(?<id>p$num)$rev?},
+ srev => qr{(?<id>s$num)$rev?},
+ crev => qr{(?<id>c$num)$rev?},
+ drev => qr{(?<id>d$num)$rev?},
postid => qr{(?<id>t$num)\.(?<num>$num)},
);
-# Simple "is this element in the array?" function, using 'eq' to test equality.
-# Supports both an @array and \@array.
-# Usage:
-#
-# my $contains_hi = in 'hi', qw/ a b hi c /; # true
-#
-sub in {
- my($q, @a) = @_;
- $_ eq $q && return 1 for map ref $_ eq 'ARRAY' ? @$_ : ($_), @a;
- 0
-}
-
-
-# Compare two vndbids, using proper numeric order
-sub idcmp($$) {
- my($a1, $a2) = $_[0] =~ /^([a-z]+)([0-9]+)$/;
- my($b1, $b2) = $_[1] =~ /^([a-z]+)([0-9]+)$/;
- $a1 cmp $b1 || $a2 <=> $b2
-}
-
-
# Returns very generic information on a DB entry object.
# Only { id, title, entry_hidden, entry_locked } for now.
# Suitable for passing to HTML::framework_'s dbobj argument.
+# TODO: Merge with SQL's item_info() or something.
sub dbobj {
- my($type, $id) = @_;
+ my($id) = @_;
my sub item {
my($table, $title) = @_;
tuwf->dbRowi('SELECT id,', $title, ' AS title, hidden AS entry_hidden, locked AS entry_locked FROM', $table, 'WHERE id =', \$id);
};
- !$type ? undef :
- $type eq 'u' ? tuwf->dbRowi('SELECT id, ', sql_user(), 'FROM users u WHERE id =', \$id) :
- $type eq 'p' ? item producers => 'name' :
- $type eq 'v' ? item vn => 'title' :
- $type eq 'r' ? item releases => 'title' :
- $type eq 'c' ? item chars => 'name' :
- $type eq 's' ? item staff => '(SELECT name FROM staff_alias WHERE aid = staff.aid)' :
- $type eq 'd' ? item docs => 'title' : die;
+ my $o = !$id ? undef :
+ $id =~ /^u/ ? tuwf->dbRowi('SELECT id, ', sql_user(), 'FROM users u WHERE id =', \$id) :
+ $id =~ /^p/ ? item producers => 'name' :
+ $id =~ /^v/ ? item vn => 'title' :
+ $id =~ /^r/ ? item releases => 'title' :
+ $id =~ /^c/ ? item chars => 'name' :
+ $id =~ /^s/ ? item staff => '(SELECT name FROM staff_alias WHERE aid = staff.aid)' :
+ $id =~ /^d/ ? item docs => 'title' : die;
+
+ $o->{title} = VNWeb::HTML::user_displayname $o if $id =~ /^u/;
+ $o;
}
1;
diff --git a/lib/VNWeb/Producers/Edit.pm b/lib/VNWeb/Producers/Edit.pm
index 0a5df222..fbd14e5f 100644
--- a/lib/VNWeb/Producers/Edit.pm
+++ b/lib/VNWeb/Producers/Edit.pm
@@ -4,7 +4,7 @@ use VNWeb::Prelude;
my $FORM = {
- id => { required => 0, id => 1 },
+ id => { required => 0, vndbid => 'p' },
ptype => { default => 'co', enum => \%PRODUCER_TYPE },
name => { maxlength => 200 },
original => { required => 0, default => '', maxlength => 200 },
@@ -14,7 +14,7 @@ my $FORM = {
l_wikidata => { required => 0, uint => 1, max => (1<<31)-1 },
desc => { required => 0, default => '', maxlength => 5000 },
relations => { sort_keys => 'pid', aoh => {
- pid => { id => 1 },
+ pid => { vndbid => 'p' },
relation => { enum => \%PRODUCER_RELATION },
name => { _when => 'out' },
original => { _when => 'out', required => 0, default => '' },
@@ -32,16 +32,16 @@ my $FORM_CMP = form_compile cmp => $FORM;
TUWF::get qr{/$RE{prev}/edit} => sub {
- my $e = db_entry p => tuwf->capture('id'), tuwf->capture('rev') or return tuwf->resNotFound;
+ my $e = db_entry tuwf->captures('id', 'rev') or return tuwf->resNotFound;
return tuwf->resDenied if !can_edit p => $e;
$e->{authmod} = auth->permDbmod;
- $e->{editsum} = $e->{chrev} == $e->{maxrev} ? '' : "Reverted to revision p$e->{id}.$e->{chrev}";
+ $e->{editsum} = $e->{chrev} == $e->{maxrev} ? '' : "Reverted to revision $e->{id}.$e->{chrev}";
$e->{ptype} = delete $e->{type};
enrich_merge pid => 'SELECT id AS pid, name, original FROM producers WHERE id IN', $e->{relations};
- framework_ title => "Edit $e->{name}", type => 'p', dbobj => $e, tab => 'edit',
+ framework_ title => "Edit $e->{name}", dbobj => $e, tab => 'edit',
sub {
editmsg_ p => $e, "Edit $e->{name}";
elm_ ProducerEdit => $FORM_OUT, $e;
@@ -63,7 +63,7 @@ TUWF::get qr{/p/add}, sub {
elm_api ProducerEdit => $FORM_OUT, $FORM_IN, sub {
my $data = shift;
my $new = !$data->{id};
- my $e = $new ? { id => 0 } : db_entry p => $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 p => $e;
if(!auth->permDbmod) {
@@ -75,14 +75,14 @@ elm_api ProducerEdit => $FORM_OUT, $FORM_IN, sub {
$data->{relations} = [] if $data->{hidden};
validate_dbid 'SELECT id FROM producers WHERE id IN', map $_->{pid}, $data->{relations}->@*;
- die "Relation with self" if grep $_->{pid} == $e->{id}, $data->{relations}->@*;
+ die "Relation with self" if grep $_->{pid} eq $e->{id}, $data->{relations}->@*;
$e->{ptype} = $e->{type};
$data->{type} = $data->{ptype};
return elm_Unchanged if !$new && !form_changed $FORM_CMP, $data, $e;
- my($id,undef,$rev) = db_edit p => $e->{id}, $data;
- update_reverse($id, $rev, $e, $data);
- elm_Redirect "/p$id.$rev";
+ my $ch = db_edit p => $e->{id}, $data;
+ update_reverse($ch->{nitemid}, $ch->{nrev}, $e, $data);
+ elm_Redirect "/$ch->{nitemid}.$ch->{nrev}";
};
@@ -107,13 +107,13 @@ sub update_reverse {
}
for my $i (keys %upd) {
- my $e = db_entry p => $i;
+ my $e = db_entry $i;
$e->{relations} = [
$upd{$i} ? $upd{$i} : (),
- grep $_->{pid} != $id, $e->{relations}->@*
+ grep $_->{pid} ne $id, $e->{relations}->@*
];
- $e->{editsum} = "Reverse relation update caused by revision p$id.$rev";
- db_edit p => $i, $e, 1;
+ $e->{editsum} = "Reverse relation update caused by revision $id.$rev";
+ db_edit p => $i, $e, 'u1';
}
}
diff --git a/lib/VNWeb/Producers/Graph.pm b/lib/VNWeb/Producers/Graph.pm
index 66f7e63c..005a2492 100644
--- a/lib/VNWeb/Producers/Graph.pm
+++ b/lib/VNWeb/Producers/Graph.pm
@@ -29,18 +29,18 @@ TUWF::get qr{/$RE{pid}/rg}, sub {
my @lines;
my $params = $num == 15 ? '' : "?num=$num";
- for my $n (sort { $a->{id} <=> $b->{id} } values %$nodes) {
+ for my $n (sort { idcmp $a->{id}, $b->{id} } values %$nodes) {
my $name = val_escape shorten $n->{name}, 27;
my $tooltip = val_escape $n->{name};
my $nodeid = $n->{distance} == 0 ? 'id = "graph_current", ' : '';
push @lines,
- qq|n$n->{id} [ $nodeid URL = "/p$n->{id}", tooltip = "$tooltip", label=<|.
+ qq|n$n->{id} [ $nodeid URL = "/$n->{id}", tooltip = "$tooltip", label=<|.
qq|<TABLE CELLSPACING="0" CELLPADDING="2" BORDER="0" CELLBORDER="1" BGCOLOR="#222222">|.
qq|<TR><TD COLSPAN="2" ALIGN="CENTER" CELLPADDING="3"><FONT POINT-SIZE="9"> $name </FONT></TD></TR>|.
qq|<TR><TD ALIGN="CENTER"> $LANGUAGE{$n->{lang}} </TD><TD ALIGN="CENTER"> $PRODUCER_TYPE{$n->{type}} </TD></TR>|.
qq|</TABLE>> ]|;
- push @lines, node_more $n->{id}, "/p$n->{id}/rg$params", scalar grep !$nodes->{$_}, $n->{rels}->@*;
+ push @lines, node_more $n->{id}, "/$n->{id}/rg$params", scalar grep !$nodes->{$_}, $n->{rels}->@*;
}
$rel = [ grep $nodes->{$_->{id0}} && $nodes->{$_->{id1}}, @$rel ];
@@ -59,7 +59,7 @@ TUWF::get qr{/$RE{pid}/rg}, sub {
if($_ == min $num, $total_nodes) {
txt_ $_ ;
} else {
- a_ href => "/p$id/rg?num=$_", $_;
+ a_ href => "/$id/rg?num=$_", $_;
}
}, grep($_ < $total_nodes, 10, 15, 25, 50, 75, 100, 150, 250, 500, 750, 1000), $total_nodes;
txt_ '.';
diff --git a/lib/VNWeb/Producers/List.pm b/lib/VNWeb/Producers/List.pm
index bd301aaf..d6193ed5 100644
--- a/lib/VNWeb/Producers/List.pm
+++ b/lib/VNWeb/Producers/List.pm
@@ -17,7 +17,7 @@ sub listing_ {
ul_ sub {
li_ sub {
abbr_ class => "icons lang $_->{lang}", title => $LANGUAGE{$_->{lang}}, '';
- a_ href => "/p$_->{id}", title => $_->{original}||$_->{name}, $_->{name};
+ a_ href => "/$_->{id}", title => $_->{original}||$_->{name}, $_->{name};
} for @$list;
}
}
diff --git a/lib/VNWeb/Producers/Page.pm b/lib/VNWeb/Producers/Page.pm
index ee494518..f95c7489 100644
--- a/lib/VNWeb/Producers/Page.pm
+++ b/lib/VNWeb/Producers/Page.pm
@@ -14,7 +14,7 @@ sub enrich_item {
sub rev_ {
my($p) = @_;
- revision_ p => $p, \&enrich_item,
+ revision_ $p, \&enrich_item,
[ name => 'Name' ],
[ original => 'Original name' ],
[ alias => 'Aliases' ],
@@ -23,7 +23,7 @@ sub rev_ {
[ lang => 'Language', fmt => \%LANGUAGE ],
[ relations => 'Relations', fmt => sub {
txt_ $PRODUCER_RELATION{$_->{relation}}{txt}.': ';
- a_ href => "/p$_->{pid}", title => $_->{original}||$_->{name}, $_->{name};
+ a_ href => "/$_->{pid}", title => $_->{original}||$_->{name}, $_->{name};
} ],
revision_extlinks 'p'
}
@@ -54,7 +54,7 @@ sub info_ {
join_ \&br_, sub {
txt_ $PRODUCER_RELATION{$_}{txt}.': ';
join_ ', ', sub {
- a_ href => "/p$_->{pid}", title => $_->{original}||$_->{name}, $_->{name};
+ a_ href => "/$_->{pid}", title => $_->{original}||$_->{name}, $_->{name};
}, $rel{$_}->@*;
}, grep $rel{$_}, keys %PRODUCER_RELATION;
} if $p->{relations}->@*;
@@ -98,7 +98,7 @@ sub rel_ {
tr_ class => 'vn', sub {
# TODO: VN list status & management
td_ colspan => 8, sub {
- a_ href => "/v$v->{id}", title => $v->{original}||$v->{title}, $v->{title};
+ a_ href => "/$v->{id}", title => $v->{original}||$v->{title}, $v->{title};
};
my $ropt = { id => $v->{id}, prod => 1, lang => 1 };
release_row_ $_, $ropt for $vn{$v->{id}}->@*;
@@ -133,7 +133,7 @@ sub vns_ {
ul_ class => 'prodvns', sub {
li_ sub {
span_ sub { rdate_ $_->{released} };
- a_ href => "/v$_->{id}", title => $_->{original}||$_->{title}, $_->{title};
+ a_ href => "/$_->{id}", title => $_->{original}||$_->{title}, $_->{title};
span_ join ' & ',
$_->{publisher} ? 'Publisher' : (),
$_->{developer} ? 'Developer' : ();
@@ -144,7 +144,7 @@ sub vns_ {
TUWF::get qr{/$RE{prev}(?:/(?<tab>vn|rel))?}, sub {
- my $p = db_entry p => tuwf->capture('id'), tuwf->capture('rev');
+ my $p = db_entry tuwf->captures('id', 'rev');
return tuwf->resNotFound if !$p;
enrich_item $p;
@@ -153,7 +153,7 @@ TUWF::get qr{/$RE{prev}(?:/(?<tab>vn|rel))?}, sub {
tuwf->resCookie(prodrelexpand => $tab eq 'vn' ? 1 : undef, expires => time + 315360000) if $tab && $tab ne $pref;
$tab = 'rel' if !$tab;
- framework_ title => $p->{name}, index => !tuwf->capture('rev'), type => 'p', dbobj => $p, hiddenmsg => 1,
+ framework_ title => $p->{name}, index => !tuwf->capture('rev'), dbobj => $p, hiddenmsg => 1,
og => {
title => $p->{name},
description => bb_format($p->{desc}, text => 1),
@@ -161,13 +161,13 @@ TUWF::get qr{/$RE{prev}(?:/(?<tab>vn|rel))?}, sub {
sub {
rev_ $p if tuwf->capture('rev');
div_ class => 'mainbox', sub {
- itemmsg_ p => $p;
+ itemmsg_ $p;
info_ $p;
};
div_ class => 'maintabs right', sub {
ul_ sub {
- li_ mkclass(tabselected => $tab eq 'vn'), sub { a_ href => "/p$p->{id}/vn", 'Visual Novels' };
- li_ mkclass(tabselected => $tab eq 'rel'), sub { a_ href => "/p$p->{id}/rel", 'Releases' };
+ li_ mkclass(tabselected => $tab eq 'vn'), sub { a_ href => "/$p->{id}/vn", 'Visual Novels' };
+ li_ mkclass(tabselected => $tab eq 'rel'), sub { a_ href => "/$p->{id}/rel", 'Releases' };
};
};
div_ class => 'mainbox', sub { rel_ $p } if $tab eq 'rel';
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 =>
diff --git a/lib/VNWeb/Reviews/Edit.pm b/lib/VNWeb/Reviews/Edit.pm
index 0ae4e652..d98b4e42 100644
--- a/lib/VNWeb/Reviews/Edit.pm
+++ b/lib/VNWeb/Reviews/Edit.pm
@@ -6,9 +6,9 @@ use VNWeb::Releases::Lib;
my $FORM = {
id => { vndbid => 'w', required => 0 },
- vid => { id => 1 },
+ vid => { vndbid => 'v' },
vntitle => { _when => 'out' },
- rid => { id => 1, required => 0 },
+ rid => { vndbid => 'r', required => 0 },
spoiler => { anybool => 1 },
isfull => { anybool => 1 },
text => { maxlength => 100_000, required => 0, default => '' },
@@ -58,7 +58,7 @@ TUWF::get qr{/$RE{wid}/edit}, sub {
$e->{releases} = releases_by_vn $e->{vid};
$e->{mod} = auth->permBoardmod;
- framework_ title => "Edit review for $e->{vntitle}", type => 'w', dbobj => $e, tab => 'edit', sub {
+ framework_ title => "Edit review for $e->{vntitle}", dbobj => $e, tab => 'edit', sub {
elm_ 'Reviews.Edit' => $FORM_OUT, $e;
};
};
@@ -83,7 +83,7 @@ elm_api ReviewsEdit => $FORM_OUT, $FORM_IN, sub {
if($id) {
$data->{lastmod} = sql 'NOW()';
tuwf->dbExeci('UPDATE reviews SET', $data, 'WHERE id =', \$id) if $id;
- auth->audit($review->{user_id}, 'review edit', "edited $review->{id}") if auth->uid != $review->{user_id};
+ auth->audit($review->{user_id}, 'review edit', "edited $review->{id}") if auth->uid ne $review->{user_id};
} else {
return elm_Unauth if tuwf->dbVali('SELECT 1 FROM reviews WHERE vid =', \$data->{vid}, 'AND uid =', \auth->uid);
diff --git a/lib/VNWeb/Reviews/List.pm b/lib/VNWeb/Reviews/List.pm
index eed0abf9..bb65c75b 100644
--- a/lib/VNWeb/Reviews/List.pm
+++ b/lib/VNWeb/Reviews/List.pm
@@ -46,7 +46,7 @@ TUWF::get qr{/w}, sub {
p => { page => 1 },
s => { onerror => 'id', enum => [qw[id lastpost rating]] },
o => { onerror => 'd', enum => [qw[a d]] },
- u => { onerror => 0, id => 1 },
+ u => { onerror => 0, vndbid => 'u' },
)->data;
$opt->{s} = 'id' if $opt->{s} eq 'rating' && !auth->isMod;
@@ -70,13 +70,13 @@ TUWF::get qr{/w}, sub {
);
my $title = $u ? 'Reviews by '.user_displayname($u) : 'Browse reviews';
- framework_ title => $title, $u ? (type => 'u', dbobj => $u, tab => 'reviews') : (), sub {
+ framework_ title => $title, $u ? (dbobj => $u, tab => 'reviews') : (), sub {
div_ class => 'mainbox', sub {
h1_ $title;
if($u && !$count) {
- p_ +(auth && $u->{id} == auth->uid ? 'You have' : user_displayname($u).' has').' not submitted any reviews yet.';
+ p_ +(auth && $u->{id} eq auth->uid ? 'You have' : user_displayname($u).' has').' not submitted any reviews yet.';
}
- p_ 'Note: The score column is only visible to moderators.' if auth->isMod;
+ p_ 'Note: The score column is only visible to moderators.' if $count && auth->isMod;
};
tablebox_ $opt, $lst, $count if $count;
};
diff --git a/lib/VNWeb/Reviews/Page.pm b/lib/VNWeb/Reviews/Page.pm
index 83a0755c..72b3b8d0 100644
--- a/lib/VNWeb/Reviews/Page.pm
+++ b/lib/VNWeb/Reviews/Page.pm
@@ -33,13 +33,13 @@ sub review_ {
tr_ sub {
td_ 'Subject';
td_ sub {
- a_ href => "/v$w->{vid}", $w->{title};
+ a_ href => "/$w->{vid}", $w->{title};
if($w->{rid}) {
br_;
abbr_ class => "icons $_", title => $PLATFORM{$_}, '' for grep $_ ne 'oth', $w->{platforms}->@*;
abbr_ class => "icons lang $_", title => $LANGUAGE{$_}, '' for $w->{lang}->@*;
abbr_ class => "icons rt$w->{rtype}", title => $w->{rtype}, '';
- a_ href => "/r$w->{rid}", title => $w->{roriginal}||$w->{rtitle}, $w->{rtitle};
+ a_ href => "/$w->{rid}", title => $w->{roriginal}||$w->{rtitle}, $w->{rtitle};
}
};
};
@@ -126,14 +126,14 @@ TUWF::get qr{/$RE{wid}(?:(?<sep>[\./])$RE{num})?}, sub {
auth->notiRead($id, undef);
auth->notiRead($id, [ map $_->{num}, $posts->@* ]) if @$posts;
- my $newreview = auth && auth->uid == $w->{user_id} && tuwf->reqGet('submit');
+ my $newreview = auth && auth->uid eq $w->{user_id} && tuwf->reqGet('submit');
my $title = "Review of $w->{title}";
- framework_ title => $title, index => 1, type => 'w', dbobj => $w,
+ framework_ title => $title, index => 1, dbobj => $w,
$num||$page>1 ? (pagevars => {sethash=>$num?$num:'threadstart'}) : (),
sub {
div_ class => 'mainbox', sub {
- itemmsg_ w => $w;
+ itemmsg_ $w;
h1_ $title;
div_ class => 'notice', sub {
b_ 'Review has been successfully submitted! ';
diff --git a/lib/VNWeb/Reviews/VNTab.pm b/lib/VNWeb/Reviews/VNTab.pm
index b2120e18..aa2949ec 100644
--- a/lib/VNWeb/Reviews/VNTab.pm
+++ b/lib/VNWeb/Reviews/VNTab.pm
@@ -32,7 +32,7 @@ sub reviews_ {
txt_ 'By '; user_ $r; txt_ ' on '.fmtdate $r->{date}, 'compact';
b_ class => 'grayedout', ' contains spoilers' if $r->{spoiler} && (auth->pref('spoilers')||0) == 2;
};
- a_ href => "/r$r->{rid}", "r$r->{rid}" if $r->{rid};
+ a_ href => "/$r->{rid}", $r->{rid} if $r->{rid};
span_ "Vote: ".fmtvote($r->{vote}) if $r->{vote};
};
div_ sub {
@@ -69,11 +69,11 @@ sub reviews_ {
TUWF::get qr{/$RE{vid}/(?<mini>mini|full)?reviews}, sub {
my $mini = !tuwf->capture('mini') ? undef : tuwf->capture('mini') eq 'mini' ? 1 : 0;
- my $v = db_entry v => tuwf->capture('id');
+ my $v = db_entry tuwf->capture('id');
return tuwf->resNotFound if !$v;
VNWeb::VN::Page::enrich_vn($v);
- framework_ title => ($mini?'Mini reviews':'Reviews')." for $v->{title}", index => 1, type => 'v', dbobj => $v, hiddenmsg => 1,
+ framework_ title => ($mini?'Mini reviews':'Reviews')." for $v->{title}", index => 1, dbobj => $v, hiddenmsg => 1,
sub {
VNWeb::VN::Page::infobox_($v);
VNWeb::VN::Page::tabs_($v, !defined $mini ? 'reviews' : $mini ? 'minireviews' : 'fullreviews');
diff --git a/lib/VNWeb/Staff/Edit.pm b/lib/VNWeb/Staff/Edit.pm
index 98b90d9f..24311d89 100644
--- a/lib/VNWeb/Staff/Edit.pm
+++ b/lib/VNWeb/Staff/Edit.pm
@@ -4,7 +4,7 @@ use VNWeb::Prelude;
my $FORM = {
- id => { required => 0, id => 1 },
+ id => { required => 0, vndbid => 's' },
aid => { int => 1, range => [ -1000, 1<<40 ] }, # X
alias => { maxlength => 100, sort_keys => 'aid', aoh => {
aid => { int => 1, range => [ -1000, 1<<40 ] }, # X, negative IDs are for new aliases
@@ -34,11 +34,11 @@ my $FORM_CMP = form_compile cmp => $FORM;
TUWF::get qr{/$RE{srev}/edit} => sub {
- my $e = db_entry s => tuwf->capture('id'), tuwf->capture('rev') or return tuwf->resNotFound;
+ my $e = db_entry tuwf->captures('id', 'rev') or return tuwf->resNotFound;
return tuwf->resDenied if !can_edit s => $e;
$e->{authmod} = auth->permDbmod;
- $e->{editsum} = $e->{chrev} == $e->{maxrev} ? '' : "Reverted to revision s$e->{id}.$e->{chrev}";
+ $e->{editsum} = $e->{chrev} == $e->{maxrev} ? '' : "Reverted to revision $e->{id}.$e->{chrev}";
my $alias_inuse = 'EXISTS(SELECT 1 FROM vn_staff WHERE aid = sa.aid UNION ALL SELECT 1 FROM vn_seiyuu WHERE aid = sa.aid)';
enrich_merge aid => sub { "SELECT aid, $alias_inuse AS inuse, false AS wantdel FROM unnest(", sql_array(@$_), '::int[]) AS sa(aid)' }, $e->{alias};
@@ -51,7 +51,7 @@ TUWF::get qr{/$RE{srev}/edit} => sub {
)->@* if $e->{chrev} != $e->{maxrev};
my $name = (grep $_->{aid} == $e->{aid}, @{$e->{alias}})[0]{name};
- framework_ title => "Edit $name", type => 's', dbobj => $e, tab => 'edit',
+ framework_ title => "Edit $name", dbobj => $e, tab => 'edit',
sub {
editmsg_ s => $e, "Edit $name";
elm_ StaffEdit => $FORM_OUT, $e;
@@ -76,7 +76,7 @@ TUWF::get qr{/s/new}, sub {
elm_api StaffEdit => $FORM_OUT, $FORM_IN, sub {
my $data = shift;
my $new = !$data->{id};
- my $e = $new ? { id => 0 } : db_entry s => $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 s => $e;
if(!auth->permDbmod) {
@@ -93,7 +93,7 @@ elm_api StaffEdit => $FORM_OUT, $FORM_IN, sub {
# For positive alias IDs: Make sure they exist and are (or were) owned by this entry.
validate_dbid
- sql('SELECT aid FROM staff_alias_hist WHERE chid IN(SELECT id FROM changes WHERE type = \'s\' AND itemid =', \$e->{id}, ') AND aid IN'),
+ sql('SELECT aid FROM staff_alias_hist WHERE chid IN(SELECT id FROM changes WHERE itemid =', \$e->{id}, ') AND aid IN'),
grep $_>=0, map $_->{aid}, $data->{alias}->@*;
# For negative alias IDs: Assign a new ID.
@@ -105,8 +105,8 @@ elm_api StaffEdit => $FORM_OUT, $FORM_IN, sub {
# We rely on Postgres to throw an error if we attempt to delete an alias that is still being referenced.
return elm_Unchanged if !$new && !form_changed $FORM_CMP, $data, $e;
- my($id,undef,$rev) = db_edit s => $e->{id}, $data;
- elm_Redirect "/s$id.$rev";
+ my $ch = db_edit s => $e->{id}, $data;
+ elm_Redirect "/$ch->{nitemid}.$ch->{nrev}";
};
1;
diff --git a/lib/VNWeb/Staff/List.pm b/lib/VNWeb/Staff/List.pm
index 07bcd5d8..d83e7827 100644
--- a/lib/VNWeb/Staff/List.pm
+++ b/lib/VNWeb/Staff/List.pm
@@ -14,7 +14,7 @@ sub listing_ {
ul_ sub {
li_ sub {
abbr_ class => "icons lang $_->{lang}", title => $LANGUAGE{$_->{lang}}, '';
- a_ href => "/s$_->{id}", title => $_->{original}||$_->{name}, $_->{name};
+ a_ href => "/$_->{id}", title => $_->{original}||$_->{name}, $_->{name};
} for @$list;
};
};
diff --git a/lib/VNWeb/Staff/Page.pm b/lib/VNWeb/Staff/Page.pm
index 8f6e0897..c8665eaf 100644
--- a/lib/VNWeb/Staff/Page.pm
+++ b/lib/VNWeb/Staff/Page.pm
@@ -16,7 +16,7 @@ sub enrich_item {
sub _rev_ {
my($s) = @_;
- revision_ s => $s, \&enrich_item,
+ revision_ $s, \&enrich_item,
[ alias => 'Names', fmt => sub {
txt_ $_->{name};
txt_ " ($_->{original})" if $_->{original};
@@ -95,7 +95,7 @@ sub _roles_ {
tr_ sub {
my($v, $a) = ($_, $alias{$_->{aid}});
td_ class => 'tc1', sub {
- a_ href => "/v$v->{id}", title => $v->{original}||$v->{title}, shorten $v->{title}, 60;
+ a_ href => "/$v->{id}", title => $v->{original}||$v->{title}, shorten $v->{title}, 60;
};
td_ class => 'tc2', sub { rdate_ $v->{c_released} };
td_ class => 'tc3', $CREDIT_TYPE{$v->{role}};
@@ -147,11 +147,11 @@ sub _cast_ {
tr_ sub {
my($v, $a) = ($_, $alias{$_->{aid}});
td_ class => 'tc1', sub {
- a_ href => "/v$v->{id}", title => $v->{original}||$v->{title}, shorten $v->{title}, 60;
+ a_ href => "/$v->{id}", title => $v->{original}||$v->{title}, shorten $v->{title}, 60;
};
td_ class => 'tc2', sub { rdate_ $v->{c_released} };
td_ class => 'tc3', sub {
- a_ href => "/c$v->{cid}", title => $v->{c_original}||$v->{c_name}, $v->{c_name};
+ a_ href => "/$v->{cid}", title => $v->{c_original}||$v->{c_name}, $v->{c_name};
};
td_ class => 'tc4', title => $a->{original}||$a->{name}, $a->{name};
td_ class => 'tc5', $v->{note};
@@ -162,21 +162,21 @@ sub _cast_ {
TUWF::get qr{/$RE{srev}} => sub {
- my $s = db_entry s => tuwf->capture('id'), tuwf->capture('rev');
+ my $s = db_entry tuwf->captures('id', 'rev');
return tuwf->resNotFound if !$s;
enrich_item $s;
enrich_extlinks s => $s;
my($main) = grep $_->{aid} == $s->{aid}, $s->{alias}->@*;
- framework_ title => $main->{name}, index => !tuwf->capture('rev'), type => 's', dbobj => $s, hiddenmsg => 1,
+ framework_ title => $main->{name}, index => !tuwf->capture('rev'), dbobj => $s, hiddenmsg => 1,
og => {
description => bb_format $s->{desc}, text => 1
},
sub {
_rev_ $s if tuwf->capture('rev');
div_ class => 'mainbox staffpage', sub {
- itemmsg_ s => $s;
+ itemmsg_ $s;
h1_ sub { txt_ $main->{name}; debug_ $s };
h2_ class => 'alttitle', lang => $s->{lang}, $main->{original} if $main->{original};
_infotable_ $main, $s;
diff --git a/lib/VNWeb/TT/TagLinks.pm b/lib/VNWeb/TT/TagLinks.pm
index 656c6b77..4f2f8846 100644
--- a/lib/VNWeb/TT/TagLinks.pm
+++ b/lib/VNWeb/TT/TagLinks.pm
@@ -38,7 +38,7 @@ sub listing_ {
};
td_ class => 'tc6', sub {
a_ href => $url->(v => $i->{vid}, p=>undef), class => 'setfil', '> ' if !defined $opt->{v};
- a_ href => "/v$i->{vid}", shorten $i->{title}, 50;
+ a_ href => "/$i->{vid}", shorten $i->{title}, 50;
};
td_ class => 'tc7', sub { lit_ bb_format $i->{notes}, inline => 1 };
} for @$lst;
@@ -53,8 +53,8 @@ TUWF::get qr{/g/links}, sub {
p => { page => 1 },
o => { onerror => 'd', enum => ['a', 'd'] },
s => { onerror => 'date', enum => [qw|date tag|] },
- v => { onerror => undef, id => 1 },
- u => { onerror => undef, id => 1 },
+ v => { onerror => undef, vndbid => 'v' },
+ u => { onerror => undef, vndbid => 'u' },
t => { onerror => undef, id => 1 },
)->data;
@@ -98,7 +98,7 @@ TUWF::get qr{/g/links}, sub {
li_ sub {
txt_ '['; a_ href => url(v=>undef, p=>undef), 'remove'; txt_ '] ';
txt_ 'Visual novel'; txt_ ' ';
- a_ href => "/v$opt->{v}", tuwf->dbVali('SELECT title FROM vn WHERE id=', \$opt->{v})||'Unknown VN';
+ a_ href => "/$opt->{v}", tuwf->dbVali('SELECT title FROM vn WHERE id=', \$opt->{v})||'Unknown VN';
} if defined $opt->{v};
}
}
diff --git a/lib/VNWeb/ULists/Elm.pm b/lib/VNWeb/ULists/Elm.pm
index 9177496e..e1a61737 100644
--- a/lib/VNWeb/ULists/Elm.pm
+++ b/lib/VNWeb/ULists/Elm.pm
@@ -12,7 +12,7 @@ sub updcache {
our $LABELS = form_compile any => {
- uid => { id => 1 },
+ uid => { vndbid => 'u' },
labels => { aoh => {
id => { int => 1 },
label => { maxlength => 50 },
@@ -77,8 +77,8 @@ elm_api UListManageLabels => undef, $LABELS, sub {
our $VNVOTE = form_compile any => {
- uid => { id => 1 },
- vid => { id => 1 },
+ uid => { vndbid => 'u' },
+ vid => { vndbid => 'v' },
vote => { vnvote => 1 },
};
@@ -101,8 +101,8 @@ elm_api UListVoteEdit => undef, $VNVOTE, sub {
my $VNLABELS = {
- uid => { id => 1 },
- vid => { id => 1 },
+ uid => { vndbid => 'u' },
+ vid => { vndbid => 'v' },
label => { _when => 'in', id => 1 },
applied => { _when => 'in', anybool => 1 },
labels => { _when => 'out', aoh => { id => { int => 1 }, label => {}, private => { anybool => 1 } } },
@@ -136,8 +136,8 @@ elm_api UListLabelEdit => $VNLABELS_OUT, $VNLABELS_IN, sub {
our $VNDATE = form_compile any => {
- uid => { id => 1 },
- vid => { id => 1 },
+ uid => { vndbid => 'u' },
+ vid => { vndbid => 'v' },
date => { required => 0, default => '', regex => qr/^(?:19[7-9][0-9]|20[0-9][0-9])-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])$/ }, # 1970 - 2099 for sanity
start => { anybool => 1 }, # Field selection, started/finished
};
@@ -158,8 +158,8 @@ elm_api UListDateEdit => undef, $VNDATE, sub {
our $VNOPT = form_compile any => {
own => { anybool => 1 },
- uid => { id => 1 },
- vid => { id => 1 },
+ uid => { vndbid => 'u' },
+ vid => { vndbid => 'v' },
notes => {},
rels => $VNWeb::Elm::apis{Releases}[0],
relstatus => { type => 'array', values => { uint => 1 } }, # List of release statuses, same order as rels
@@ -167,8 +167,8 @@ our $VNOPT = form_compile any => {
our $VNPAGE = form_compile any => {
- uid => { id => 1 },
- vid => { id => 1 },
+ uid => { vndbid => 'u' },
+ vid => { vndbid => 'v' },
onlist => { anybool => 1 },
canvote => { anybool => 1 },
vote => { vnvote => 1 },
@@ -182,8 +182,8 @@ our $VNPAGE = form_compile any => {
# UListVNNotes module is abused for the UList.Opts and UList.VNPage flag definition
elm_api UListVNNotes => $VNOPT, {
- uid => { id => 1 },
- vid => { id => 1 },
+ uid => { vndbid => 'u' },
+ vid => { vndbid => 'v' },
notes => { required => 0, default => '', maxlength => 2000 },
}, sub {
my($data) = @_;
@@ -199,8 +199,8 @@ elm_api UListVNNotes => $VNOPT, {
elm_api UListDel => undef, {
- uid => { id => 1 },
- vid => { id => 1 },
+ uid => { vndbid => 'u' },
+ vid => { vndbid => 'v' },
}, sub {
my($data) = @_;
return elm_Unauth if !ulists_own $data->{uid};
@@ -215,8 +215,8 @@ elm_api UListDel => undef, {
# Adds the release when not in the list.
# $RLIST_STATUS is also referenced from VNWeb::Releases::Page.
our $RLIST_STATUS = form_compile any => {
- uid => { id => 1 },
- rid => { id => 1 },
+ uid => { vndbid => 'u' },
+ rid => { vndbid => 'r' },
status => { required => 0, uint => 1, enum => \%RLIST_STATUS }, # undef meaning delete
empty => { required => 0, default => '' }, # An 'out' field
};
@@ -248,7 +248,7 @@ our %SAVED_OPTS = (
);
my $SAVED_OPTS = {
- uid => { id => 1 },
+ uid => { vndbid => 'u' },
opts => { type => 'hash', keys => \%SAVED_OPTS },
field => { _when => 'in', enum => [qw/ vnlist votes wish /] },
};
diff --git a/lib/VNWeb/ULists/Export.pm b/lib/VNWeb/ULists/Export.pm
index acfbcccf..655bbd54 100644
--- a/lib/VNWeb/ULists/Export.pm
+++ b/lib/VNWeb/ULists/Export.pm
@@ -72,13 +72,13 @@ TUWF::get qr{/$RE{uid}/list-export/xml}, sub {
tag 'vndb-export' => version => '1.0', date => $d->{'export-date'}, sub {
tag user => sub {
tag name => $d->{user}{name};
- tag url => config->{url}.'/u'.$d->{user}{id};
+ tag url => config->{url}.'/'.$d->{user}{id};
};
tag labels => sub {
tag label => id => $_->{id}, label => $_->{label}, private => $_->{private}?'true':'false', undef for $d->{labels}->@*;
};
tag vns => sub {
- tag vn => id => "v$_->{id}", private => grep(!$_->{private}, $_->{labels}->@*)?'false':'true', sub {
+ tag vn => id => $_->{id}, private => grep(!$_->{private}, $_->{labels}->@*)?'false':'true', sub {
tag title => length($_->{original}) ? (original => $_->{original}) : (), $_->{title};
tag label => id => $_->{id}, label => $_->{label}, undef for $_->{labels}->@*;
tag added => $_->{added};
@@ -87,7 +87,7 @@ TUWF::get qr{/$RE{uid}/list-export/xml}, sub {
tag started => $_->{started} if $_->{started};
tag finished => $_->{finished} if $_->{finished};
tag notes => $_->{notes} if length $_->{notes};
- tag release => id => "r$_->{id}", sub {
+ tag release => id => $_->{id}, sub {
tag title => length($_->{original}) ? (original => $_->{original}) : (), $_->{title};
tag 'release-date' => rdate $_->{released};
tag status => $RLIST_STATUS{$_->{status}};
diff --git a/lib/VNWeb/ULists/Lib.pm b/lib/VNWeb/ULists/Lib.pm
index d831692a..637decfb 100644
--- a/lib/VNWeb/ULists/Lib.pm
+++ b/lib/VNWeb/ULists/Lib.pm
@@ -7,7 +7,7 @@ our @EXPORT = qw/ulists_own/;
# Do we have "ownership" access to this users' list (i.e. can we edit and see private stuff)?
sub ulists_own {
- auth->permUsermod || (auth && auth->uid == shift)
+ auth->permUsermod || (auth && auth->uid eq shift)
}
1;
diff --git a/lib/VNWeb/ULists/List.pm b/lib/VNWeb/ULists/List.pm
index dbdfddc9..ae443955 100644
--- a/lib/VNWeb/ULists/List.pm
+++ b/lib/VNWeb/ULists/List.pm
@@ -132,7 +132,7 @@ sub vn_ {
} if in label => $opt->{c};
td_ class => 'tc_title', sub {
- a_ href => "/v$v->{id}", title => $v->{original}||$v->{title}, shorten $v->{title}, 70;
+ a_ href => "/$v->{id}", title => $v->{original}||$v->{title}, shorten $v->{title}, 70;
b_ class => 'grayedout', id => 'ulist_notes_'.$v->{id}, $v->{notes} if $v->{notes} || $own;
};
@@ -305,9 +305,9 @@ TUWF::get qr{/$RE{uid}/ulist}, sub {
: $num_core_labels == 1 && $opt_labels->{5} ? 'wish' : 'list';
my $title = $own ? 'My list' : user_displayname($u)."'s list";
- framework_ title => $title, type => 'u', dbobj => $u, tab => $tab, js => 1,
+ framework_ title => $title, dbobj => $u, tab => $tab, js => 1,
$own ? ( pagevars => {
- uid => $u->{id}*1,
+ uid => $u->{id},
labels => $VNWeb::ULists::Elm::LABELS->analyze->{keys}{labels}->coerce_for_json($labels),
voteprivate => (map \($_->{private}?1:0), grep $_->{id} == 7, @$labels),
} ) : (),
@@ -330,7 +330,7 @@ TUWF::get qr{/$RE{uid}/ulist}, sub {
txt_ '(there is currently no import function, more export options may be added later).';
br_;
br_;
- a_ href => "/u$u->{id}/list-export/xml", "Download XML export.";
+ a_ href => "/$u->{id}/list-export/xml", "Download XML export.";
} if $own;
}
};
@@ -341,9 +341,9 @@ TUWF::get qr{/$RE{uid}/ulist}, sub {
# Redirects for old URLs
-TUWF::get qr{/$RE{uid}/votes}, sub { tuwf->resRedirect("/u".tuwf->capture('id').'/ulist?votes=1', 'perm') };
-TUWF::get qr{/$RE{uid}/list}, sub { tuwf->resRedirect("/u".tuwf->capture('id').'/ulist?vnlist=1', 'perm') };
-TUWF::get qr{/$RE{uid}/wish}, sub { tuwf->resRedirect("/u".tuwf->capture('id').'/ulist?wishlist=1', 'perm') };
+TUWF::get qr{/$RE{uid}/votes}, sub { tuwf->resRedirect("/".tuwf->capture('id').'/ulist?votes=1', 'perm') };
+TUWF::get qr{/$RE{uid}/list}, sub { tuwf->resRedirect("/".tuwf->capture('id').'/ulist?vnlist=1', 'perm') };
+TUWF::get qr{/$RE{uid}/wish}, sub { tuwf->resRedirect("/".tuwf->capture('id').'/ulist?wishlist=1', 'perm') };
1;
diff --git a/lib/VNWeb/User/Edit.pm b/lib/VNWeb/User/Edit.pm
index 02161c50..59c0f0d0 100644
--- a/lib/VNWeb/User/Edit.pm
+++ b/lib/VNWeb/User/Edit.pm
@@ -5,7 +5,7 @@ use VNDB::Skins;
my $FORM = {
- id => { uint => 1 },
+ id => { vndbid => 'u' },
title => { _when => 'out' },
username => { username => 1 }, # Can only be modified with perm_usermod
@@ -79,7 +79,7 @@ TUWF::get qr{/$RE{uid}/edit}, sub {
$u->{opts}{perm_boardmod} = auth->permBoardmod;
$u->{opts}{perm_imgmod} = auth->permImgmod;
- $u->{prefs} = $u->{id} == auth->uid || auth->permUsermod ?
+ $u->{prefs} = $u->{id} eq auth->uid || auth->permUsermod ?
tuwf->dbRowi(
'SELECT max_sexual, max_violence, traits_sexual, tags_all, tags_cont, tags_ero, tags_tech, spoilers, skin, customcss
, nodistract_noads, nodistract_nofancy, support_enabled, uniname, pubskin_enabled
@@ -93,7 +93,7 @@ TUWF::get qr{/$RE{uid}/edit}, sub {
$u->{password} = undef;
- $u->{title} = $u->{id} == auth->uid ? 'My Account' : "Edit $u->{username}";
+ $u->{title} = $u->{id} eq auth->uid ? 'My Account' : "Edit $u->{username}";
framework_ title => $u->{title}, type => 'u', dbobj => $u, tab => 'edit',
sub {
elm_ 'User.Edit', $FORM_OUT, $u;
@@ -108,7 +108,7 @@ elm_api UserEdit => $FORM_OUT, $FORM_IN, sub {
return tuwf->resNotFound if !$username;
return elm_Unauth if !can_edit u => $data;
- my $own = $data->{id} == auth->uid || auth->permUsermod;
+ my $own = $data->{id} eq auth->uid || auth->permUsermod;
my %set;
if($own) {
@@ -140,7 +140,7 @@ elm_api UserEdit => $FORM_OUT, $FORM_IN, sub {
return elm_InsecurePass if is_insecurepass $data->{password}{new};
my $ok = 1;
- if(auth->uid == $data->{id}) {
+ if(auth->uid eq $data->{id}) {
$ok = 0 if !auth->setpass($data->{id}, undef, $data->{password}{old}, $data->{password}{new});
} else {
tuwf->dbExeci(select => sql_func user_admin_setpass => \$data->{id}, \auth->uid,
@@ -170,7 +170,7 @@ elm_api UserEdit => $FORM_OUT, $FORM_IN, sub {
."%s"
."\n\n"
."vndb.org",
- $username, $oldmail, $newmail, tuwf->reqBaseURI()."/u$data->{id}/setmail/$token";
+ $username, $oldmail, $newmail, tuwf->reqBaseURI()."/$data->{id}/setmail/$token";
tuwf->mail($body,
To => $newmail,
@@ -188,7 +188,7 @@ elm_api UserEdit => $FORM_OUT, $FORM_IN, sub {
$_ = JSON::XS->new->allow_nonref->encode($_) for values %$old, %$new;
my @diff = grep $old->{$_} ne $new->{$_}, keys %set;
auth->audit($data->{id}, 'user edit', join '; ', map "$_: $old->{$_} -> $new->{$_}", @diff)
- if @diff && (auth->uid != $data->{id} || grep /^(perm_|ign_votes|username)/, @diff);
+ if @diff && (auth->uid ne $data->{id} || grep /^(perm_|ign_votes|username)/, @diff);
$ret->();
};
diff --git a/lib/VNWeb/User/List.pm b/lib/VNWeb/User/List.pm
index 4a540085..dae3a6a8 100644
--- a/lib/VNWeb/User/List.pm
+++ b/lib/VNWeb/User/List.pm
@@ -27,19 +27,19 @@ sub listing_ {
td_ class => 'tc2', fmtdate $l->{registered};
td_ class => 'tc3', sub {
txt_ '0' if !$l->{c_vns};
- a_ href => "/u$l->{user_id}/ulist?vnlist=1", $l->{c_vns} if $l->{c_vns};
+ a_ href => "/$l->{user_id}/ulist?vnlist=1", $l->{c_vns} if $l->{c_vns};
};
td_ class => 'tc4', sub {
txt_ '0' if !$l->{c_votes};
- a_ href => "/u$l->{user_id}/ulist?votes=1", $l->{c_votes} if $l->{c_votes};
+ a_ href => "/$l->{user_id}/ulist?votes=1", $l->{c_votes} if $l->{c_votes};
};
td_ class => 'tc5', sub {
txt_ '0' if !$l->{c_wish};
- a_ href => "/u$l->{user_id}/ulist?wishlist=1", $l->{c_wish} if $l->{c_wish};
+ a_ href => "/$l->{user_id}/ulist?wishlist=1", $l->{c_wish} if $l->{c_wish};
};
td_ class => 'tc6', sub {
txt_ '-' if !$l->{c_changes};
- a_ href => "/u$l->{user_id}/hist", $l->{c_changes} if $l->{c_changes};
+ a_ href => "/$l->{user_id}/hist", $l->{c_changes} if $l->{c_changes};
};
td_ class => 'tc7', sub {
txt_ '-' if !$l->{c_tags};
@@ -70,7 +70,7 @@ TUWF::get qr{/u/(?<char>[0a-z]|all)}, sub {
$char eq 'all' ? () : $char eq '0' ? "ascii(username) not between ascii('a') and ascii('z')" : "username like '$char%'",
$opt->{q} ? sql_or(
auth->permUsermod && $opt->{q} =~ /@/ ? sql('id IN(SELECT y FROM user_emailtoid(', \$opt->{q}, ') x(y))') : (),
- $opt->{q} =~ /^u?([0-9]{1,6})$/ ? sql 'id =', \"$1" : (),
+ $opt->{q} =~ /^(u?[0-9]{1,6})$/ ? sql 'id =', \"$1" : (),
sql('username ILIKE', \('%'.sql_like($opt->{q}).'%')),
) : ()
);
@@ -78,7 +78,7 @@ TUWF::get qr{/u/(?<char>[0a-z]|all)}, sub {
my $list = tuwf->dbPagei({ results => 50, page => $opt->{p} },
'SELECT', sql_user(), ',', sql_totime('registered'), 'as registered, c_vns, c_votes, c_wish, c_changes, c_tags, c_imgvotes
FROM users u
- WHERE', sql_and('id > 0', @where),
+ WHERE', sql_and(@where),
'ORDER BY', {
username => 'username',
registered => 'id',
diff --git a/lib/VNWeb/User/Login.pm b/lib/VNWeb/User/Login.pm
index a552c60f..fa679325 100644
--- a/lib/VNWeb/User/Login.pm
+++ b/lib/VNWeb/User/Login.pm
@@ -60,7 +60,7 @@ elm_api UserChangePass => undef, {
TUWF::post qr{/$RE{uid}/logout}, sub {
- return tuwf->resNotFound if !auth || auth->uid != tuwf->capture('id') || (tuwf->reqPost('csrf')||'') ne auth->csrftoken;
+ return tuwf->resNotFound if !auth || auth->uid ne tuwf->capture('id') || (tuwf->reqPost('csrf')||'') ne auth->csrftoken;
auth->logout;
tuwf->resRedirect('/', 'post');
};
diff --git a/lib/VNWeb/User/Notifications.pm b/lib/VNWeb/User/Notifications.pm
index 1f1d964f..2e6bc7d4 100644
--- a/lib/VNWeb/User/Notifications.pm
+++ b/lib/VNWeb/User/Notifications.pm
@@ -23,7 +23,7 @@ sub settings_ {
my $u = tuwf->dbRowi('SELECT notify_dbedit, notify_post, notify_comment, notify_announce FROM users WHERE id =', \$id);
h1_ 'Settings';
- form_ action => "/u$id/notify_options", method => 'POST', sub {
+ form_ action => "/$id/notify_options", method => 'POST', sub {
input_ type => 'hidden', class => 'hidden', name => 'csrf', value => auth->csrftoken;
p_ sub {
label_ sub {
@@ -55,7 +55,7 @@ sub settings_ {
sub listing_ {
my($id, $opt, $count, $list) = @_;
- my sub url { "/u$id/notifies?r=$opt->{r}&p=$_" }
+ my sub url { "/$id/notifies?r=$opt->{r}&p=$_" }
my sub tbl_ {
thead_ sub { tr_ sub {
@@ -101,7 +101,7 @@ sub listing_ {
} for @$list;
}
- form_ action => "/u$id/notify_update", method => 'POST', sub {
+ form_ action => "/$id/notify_update", method => 'POST', sub {
input_ type => 'hidden', class => 'hidden', name => 'url', value => do { local $_ = $opt->{p}; url };
paginate_ \&url, $opt->{p}, [$count, 25], 't';
div_ class => 'mainbox browse notifies', sub {
@@ -113,12 +113,12 @@ sub listing_ {
# Redirect so that elm/Subscribe.elm can link to this page without knowing our uid.
-TUWF::get qr{/u/notifies}, sub { auth ? tuwf->resRedirect('/u'.auth->uid.'/notifies') : tuwf->resNotFound };
+TUWF::get qr{/u/notifies}, sub { auth ? tuwf->resRedirect('/'.auth->uid.'/notifies') : tuwf->resNotFound };
TUWF::get qr{/$RE{uid}/notifies}, sub {
my $id = tuwf->capture('id');
- return tuwf->resNotFound if !auth || $id != auth->uid;
+ return tuwf->resNotFound if !auth || $id ne auth->uid;
my $opt = tuwf->validate(get =>
p => { page => 1 },
@@ -158,7 +158,7 @@ TUWF::get qr{/$RE{uid}/notifies}, sub {
TUWF::post qr{/$RE{uid}/notify_options}, sub {
my $id = tuwf->capture('id');
- return tuwf->resNotFound if !auth || $id != auth->uid;
+ return tuwf->resNotFound if !auth || $id ne auth->uid;
my $frm = tuwf->validate(post =>
csrf => {},
@@ -175,16 +175,16 @@ TUWF::post qr{/$RE{uid}/notify_options}, sub {
notify_post => $frm->{post},
notify_comment => $frm->{comment},
}, 'WHERE id =', \$id);
- tuwf->resRedirect("/u$id/notifies", 'post');
+ tuwf->resRedirect("/$id/notifies", 'post');
};
TUWF::post qr{/$RE{uid}/notify_update}, sub {
my $id = tuwf->capture('id');
- return tuwf->resNotFound if !auth || $id != auth->uid;
+ return tuwf->resNotFound if !auth || $id ne auth->uid;
my $frm = tuwf->validate(post =>
- url => { regex => qr{^/u$id/notifies} },
+ url => { regex => qr{^/$id/notifies} },
notifysel => { required => 0, default => [], type => 'array', scalar => 1, values => { id => 1 } },
markread => { anybool => 1 },
remove => { anybool => 1 },
@@ -203,7 +203,7 @@ TUWF::post qr{/$RE{uid}/notify_update}, sub {
# (but that's subject to change in the future, so let's keep this around)
TUWF::get qr{/$RE{uid}/notify/$RE{num}/(?<lid>[a-z0-9\.]+)}, sub {
my $id = tuwf->capture('id');
- return tuwf->resNotFound if !auth || $id != auth->uid;
+ return tuwf->resNotFound if !auth || $id ne auth->uid;
tuwf->dbExeci('UPDATE notifications SET read = NOW() WHERE read IS NULL AND uid =', \$id, ' AND id =', \tuwf->capture('num'));
tuwf->resRedirect('/'.tuwf->capture('lid'), 'temp');
};
diff --git a/lib/VNWeb/User/Page.pm b/lib/VNWeb/User/Page.pm
index f225bd76..b110a444 100644
--- a/lib/VNWeb/User/Page.pm
+++ b/lib/VNWeb/User/Page.pm
@@ -22,7 +22,7 @@ sub _info_table_ {
td_ class => 'key', 'Username';
td_ sub {
txt_ ucfirst $u->{user_name};
- txt_ ' ('; a_ href => "/u$u->{id}", "u$u->{id}";
+ txt_ ' ('; a_ href => "/$u->{id}", $u->{id};
txt_ ')';
debug_ $u;
sup if !($u->{user_uniname_can} && $u->{user_uniname});
@@ -35,7 +35,7 @@ sub _info_table_ {
tr_ sub {
td_ 'Edits';
td_ !$u->{c_changes} ? '-' : sub {
- a_ href => "/u$u->{id}/hist", $u->{c_changes}
+ a_ href => "/$u->{id}/hist", $u->{c_changes}
};
};
tr_ sub {
@@ -44,7 +44,7 @@ sub _info_table_ {
td_ 'Votes';
td_ !$num ? '-' : sub {
txt_ sprintf '%d vote%s, %.2f average. ', $num, $num == 1 ? '' : 's', $sum/$num/10;
- a_ href => "/u$u->{id}/ulist?votes=1", 'Browse votes »';
+ a_ href => "/$u->{id}/ulist?votes=1", 'Browse votes »';
}
};
tr_ sub {
@@ -62,7 +62,7 @@ sub _info_table_ {
txt_ sprintf '%d release%s of %d visual novel%s. ',
$rel, $rel == 1 ? '' : 's',
$vns, $vns == 1 ? '' : 's';
- a_ href => "/u$u->{id}/ulist?vnlist=1", 'Browse list »';
+ a_ href => "/$u->{id}/ulist?vnlist=1", 'Browse list »';
};
};
tr_ sub {
@@ -99,7 +99,7 @@ sub _info_table_ {
txt_ sprintf '%d post%s, %d new thread%s. ',
$stats->{posts}, $stats->{posts} == 1 ? '' : 's',
$stats->{threads}, $stats->{threads} == 1 ? '' : 's';
- a_ href => "/u$u->{id}/posts", 'Browse posts »';
+ a_ href => "/$u->{id}/posts", 'Browse posts »';
};
};
}
@@ -140,11 +140,11 @@ sub _votestats_ {
table_ class => 'recentvotes stripe', sub {
thead_ sub { tr_ sub { td_ colspan => 3, sub {
txt_ 'Recent votes';
- b_ sub { txt_ ' ('; a_ href => "/u$u->{id}/ulist?votes=1", 'show all'; txt_ ')' };
+ b_ sub { txt_ ' ('; a_ href => "/$u->{id}/ulist?votes=1", 'show all'; txt_ ')' };
} } };
tr_ sub {
my $v = $_;
- td_ sub { a_ href => "/v$v->{id}", title => $v->{original}||$v->{title}, shorten $v->{title}, 30 };
+ td_ sub { a_ href => "/$v->{id}", title => $v->{original}||$v->{title}, shorten $v->{title}, 30 };
td_ fmtvote $v->{vote};
td_ fmtdate $v->{date};
} for @$recent;
@@ -164,7 +164,7 @@ TUWF::get qr{/$RE{uid}}, sub {
);
return tuwf->resNotFound if !$u->{id};
- my $own = (auth && auth->uid == $u->{id}) || auth->permUsermod;
+ my $own = (auth && auth->uid eq $u->{id}) || auth->permUsermod;
$u->{votes} = tuwf->dbAlli('
SELECT (uv.vote::numeric/10)::int AS idx, COUNT(uv.vote) as votes, SUM(uv.vote) AS total
@@ -177,7 +177,7 @@ TUWF::get qr{/$RE{uid}}, sub {
');
my $title = user_displayname($u)."'s profile";
- framework_ title => $title, type => 'u', dbobj => $u,
+ framework_ title => $title, dbobj => $u,
sub {
div_ class => 'mainbox userpage', sub {
h1_ $title;
@@ -190,8 +190,8 @@ TUWF::get qr{/$RE{uid}}, sub {
} if grep $_->{votes} > 0, $u->{votes}->@*;
if($u->{c_changes}) {
- h1_ class => 'boxtitle', sub { a_ href => "/u$u->{id}/hist", 'Recent changes' };
- VNWeb::Misc::History::tablebox_ u => $u->{id}, {p=>1}, nopage => 1, results => 10;
+ h1_ class => 'boxtitle', sub { a_ href => "/$u->{id}/hist", 'Recent changes' };
+ VNWeb::Misc::History::tablebox_ $u->{id}, {p=>1}, nopage => 1, results => 10;
}
};
};
diff --git a/lib/VNWeb/User/PassReset.pm b/lib/VNWeb/User/PassReset.pm
index 39f1d6ea..8d40295a 100644
--- a/lib/VNWeb/User/PassReset.pm
+++ b/lib/VNWeb/User/PassReset.pm
@@ -29,7 +29,7 @@ elm_api UserPassReset => undef, {
."Now don't forget your password again! :-)"
."\n\n"
."vndb.org",
- $name, tuwf->reqBaseURI()."/u$id/setpass/$token";
+ $name, tuwf->reqBaseURI()."/$id/setpass/$token";
tuwf->mail($body,
To => $data->{email},
diff --git a/lib/VNWeb/User/PassSet.pm b/lib/VNWeb/User/PassSet.pm
index 4b5d3fc1..2428f8e1 100644
--- a/lib/VNWeb/User/PassSet.pm
+++ b/lib/VNWeb/User/PassSet.pm
@@ -3,7 +3,7 @@ package VNWeb::User::PassSet;
use VNWeb::Prelude;
my $FORM = {
- uid => { id => 1 },
+ uid => { vndbid => 'u' },
token => { regex => qr/[a-f0-9]{40}/ },
password => { _when => 'in', password => 1 },
};
diff --git a/lib/VNWeb/User/Register.pm b/lib/VNWeb/User/Register.pm
index c956111c..89e34846 100644
--- a/lib/VNWeb/User/Register.pm
+++ b/lib/VNWeb/User/Register.pm
@@ -46,7 +46,7 @@ elm_api UserRegister => undef, {
."If you don't remember creating an account on VNDB.org recently, please ignore this e-mail."
."\n\n"
."vndb.org",
- $data->{username}, tuwf->reqBaseURI()."/u$id/setpass/$token";
+ $data->{username}, tuwf->reqBaseURI()."/$id/setpass/$token";
tuwf->mail($body,
To => $data->{email},
diff --git a/lib/VNWeb/VN/Edit.pm b/lib/VNWeb/VN/Edit.pm
index ec0445ed..5e50861f 100644
--- a/lib/VNWeb/VN/Edit.pm
+++ b/lib/VNWeb/VN/Edit.pm
@@ -6,7 +6,7 @@ use VNWeb::Releases::Lib;
my $FORM = {
- id => { required => 0, id => 1 },
+ id => { required => 0, vndbid => 'v' },
title => { maxlength => 250 },
original => { required => 0, default => '', maxlength => 250 },
alias => { required => 0, default => '', maxlength => 500 },
@@ -16,7 +16,7 @@ my $FORM = {
l_wikidata => { required => 0, uint => 1, max => (1<<31)-1 },
l_renai => { required => 0, default => '', maxlength => 100 },
relations => { sort_keys => 'vid', aoh => {
- vid => { id => 1 },
+ vid => { vndbid => 'v' },
relation => { enum => \%VN_RELATION },
official => { anybool => 1 },
title => { _when => 'out' },
@@ -33,22 +33,22 @@ my $FORM = {
aid => { id => 1 },
role => { enum => \%CREDIT_TYPE },
note => { required => 0, default => '', maxlength => 250 },
- id => { _when => 'out', id => 1 },
+ id => { _when => 'out', vndbid => 's' },
name => { _when => 'out' },
original => { _when => 'out', required => 0, default => '' },
} },
seiyuu => { sort_keys => ['aid','cid'], aoh => {
aid => { id => 1 },
- cid => { id => 1 },
+ cid => { vndbid => 'c' },
note => { required => 0, default => '', maxlength => 250 },
# Staff info
- id => { _when => 'out', id => 1 },
+ id => { _when => 'out', vndbid => 's' },
name => { _when => 'out' },
original => { _when => 'out', required => 0, default => '' },
} },
screenshots=> { sort_keys => 'scr', aoh => {
scr => { vndbid => 'sf' },
- rid => { required => 0, id => 1 },
+ rid => { required => 0, vndbid => 'r' },
info => { _when => 'out', type => 'hash', keys => $VNWeb::Elm::apis{ImageResult}[0]{aoh} },
} },
hidden => { anybool => 1 },
@@ -58,7 +58,7 @@ my $FORM = {
editsum => { _when => 'in out', editsum => 1 },
releases => { _when => 'out', $VNWeb::Elm::apis{Releases}[0]->%* },
chars => { _when => 'out', aoh => {
- id => { id => 1 },
+ id => { vndbid => 'c' },
name => {},
original => { required => 0, default => '' },
} },
@@ -70,11 +70,11 @@ my $FORM_CMP = form_compile cmp => $FORM;
TUWF::get qr{/$RE{vrev}/edit} => sub {
- my $e = db_entry v => tuwf->capture('id'), tuwf->capture('rev') or return tuwf->resNotFound;
+ my $e = db_entry tuwf->captures('id', 'rev') or return tuwf->resNotFound;
return tuwf->resDenied if !can_edit v => $e;
$e->{authmod} = auth->permDbmod;
- $e->{editsum} = $e->{chrev} == $e->{maxrev} ? '' : "Reverted to revision v$e->{id}.$e->{chrev}";
+ $e->{editsum} = $e->{chrev} == $e->{maxrev} ? '' : "Reverted to revision $e->{id}.$e->{chrev}";
if($e->{image}) {
$e->{image_info} = { id => $e->{image} };
@@ -103,7 +103,7 @@ TUWF::get qr{/$RE{vrev}/edit} => sub {
ORDER BY name, id'
);
- framework_ title => "Edit $e->{title}", type => 'v', dbobj => $e, tab => 'edit',
+ framework_ title => "Edit $e->{title}", dbobj => $e, tab => 'edit',
sub {
editmsg_ v => $e, "Edit $e->{title}";
elm_ VNEdit => $FORM_OUT, $e;
@@ -125,7 +125,7 @@ TUWF::get qr{/v/add}, sub {
elm_api VNEdit => $FORM_OUT, $FORM_IN, sub {
my $data = shift;
my $new = !$data->{id};
- my $e = $new ? { id => 0 } : db_entry v => $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 v => $e;
if(!auth->permDbmod) {
@@ -143,7 +143,7 @@ elm_api VNEdit => $FORM_OUT, $FORM_IN, sub {
$data->{relations} = [] if $data->{hidden};
validate_dbid 'SELECT id FROM vn WHERE id IN', map $_->{vid}, $data->{relations}->@*;
- die "Relation with self" if grep $_->{vid} == $e->{id}, $data->{relations}->@*;
+ die "Relation with self" if grep $_->{vid} eq $e->{id}, $data->{relations}->@*;
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.
@@ -166,9 +166,9 @@ elm_api VNEdit => $FORM_OUT, $FORM_IN, sub {
$_->{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;
- update_reverse($id, $rev, $e, $data);
- elm_Redirect "/v$id.$rev";
+ my $ch = db_edit v => $e->{id}, $data;
+ update_reverse($ch->{nitemid}, $ch->{nrev}, $e, $data);
+ elm_Redirect "/$ch->{nitemid}.$ch->{nrev}";
};
@@ -194,13 +194,13 @@ sub update_reverse {
}
for my $i (keys %upd) {
- my $v = db_entry v => $i;
+ my $v = db_entry $i;
$v->{relations} = [
$upd{$i} ? $upd{$i} : (),
- grep $_->{vid} != $id, $v->{relations}->@*
+ grep $_->{vid} ne $id, $v->{relations}->@*
];
- $v->{editsum} = "Reverse relation update caused by revision v$id.$rev";
- db_edit v => $i, $v, 1;
+ $v->{editsum} = "Reverse relation update caused by revision $id.$rev";
+ db_edit v => $i, $v, 'u1';
}
}
diff --git a/lib/VNWeb/VN/Graph.pm b/lib/VNWeb/VN/Graph.pm
index e00f656e..a9227108 100644
--- a/lib/VNWeb/VN/Graph.pm
+++ b/lib/VNWeb/VN/Graph.pm
@@ -34,26 +34,26 @@ TUWF::get qr{/$RE{vid}/rg}, sub {
my @lines;
my $params = "?num=$num&unoff=$unoff";
- for my $n (sort { $a->{id} <=> $b->{id} } values %$nodes) {
+ for my $n (sort { idcmp $a->{id}, $b->{id} } values %$nodes) {
my $title = val_escape shorten $n->{title}, 27;
my $tooltip = val_escape $n->{title};
my $date = rdate $n->{c_released};
my $lang = $n->{lang}||'N/A';
my $nodeid = $n->{distance} == 0 ? 'id = "graph_current", ' : '';
push @lines,
- qq|n$n->{id} [ $nodeid URL = "/v$n->{id}", tooltip = "$tooltip", label=<|.
+ qq|n$n->{id} [ $nodeid URL = "/$n->{id}", tooltip = "$tooltip", label=<|.
qq|<TABLE CELLSPACING="0" CELLPADDING="2" BORDER="0" CELLBORDER="1" BGCOLOR="#222222">|.
qq|<TR><TD COLSPAN="2" ALIGN="CENTER" CELLPADDING="3"><FONT POINT-SIZE="9"> $title </FONT></TD></TR>|.
qq|<TR><TD> $date </TD><TD> $lang </TD></TR>|.
qq|</TABLE>> ]|;
- push @lines, node_more $n->{id}, "/v$n->{id}/rg$params", scalar grep !$nodes->{$_}, $n->{rels}->@*;
+ push @lines, node_more $n->{id}, "/$n->{id}/rg$params", scalar grep !$nodes->{$_}, $n->{rels}->@*;
}
$rel = [ grep $nodes->{$_->{id0}} && $nodes->{$_->{id1}}, @$rel ];
my $dot = gen_dot \@lines, $nodes, $rel, \%VN_RELATION;
- framework_ title => "Relations for $v->{title}", type => 'v', dbobj => $v, tab => 'rg',
+ framework_ title => "Relations for $v->{title}", dbobj => $v, tab => 'rg',
sub {
div_ class => 'mainbox', style => 'float: left; min-width: 100%', sub {
h1_ "Relations for $v->{title}";
@@ -78,7 +78,7 @@ TUWF::get qr{/$RE{vid}/rg}, sub {
if($_ == min $num, $total_nodes) {
txt_ $_ ;
} else {
- a_ href => "/v$id/rg?num=$_", $_;
+ a_ href => "/$id/rg?num=$_", $_;
}
}, grep($_ < $total_nodes, 10, 15, 25, 50, 75, 100, 150, 250, 500, 750, 1000), $total_nodes;
}
diff --git a/lib/VNWeb/VN/List.pm b/lib/VNWeb/VN/List.pm
index 4949e139..928ac0bb 100644
--- a/lib/VNWeb/VN/List.pm
+++ b/lib/VNWeb/VN/List.pm
@@ -27,7 +27,7 @@ sub listing_ {
} };
tr_ sub {
td_ class => 'tc_s',sub { tagscore_ $_->{tagscore} } if $tagscore;
- td_ class => $tagscore ? 'tc_t' : 'tc1', sub { a_ href => "/v$_->{id}", title => $_->{original}||$_->{title}, $_->{title} };
+ td_ class => $tagscore ? 'tc_t' : 'tc1', sub { a_ href => "/$_->{id}", title => $_->{original}||$_->{title}, $_->{title} };
td_ class => 'tc7', sub {
b_ class => $_->{userlist_obtained} == $_->{userlist_all} ? 'done' : 'todo', sprintf '%d/%d', $_->{userlist_obtained}, $_->{userlist_all} if $_->{userlist_all};
abbr_ title => join(', ', $_->{vnlist_labels}->@*), scalar $_->{vnlist_labels}->@* if $_->{vnlist_labels} && $_->{vnlist_labels}->@*;
@@ -134,7 +134,7 @@ TUWF::get qr{/v(?:/(?<char>all|[a-z0]))?}, sub {
) : [];
} || (($count, $list) = (undef, []));
- return tuwf->resRedirect("/v$list->[0]{id}") if $count && $count == 1 && $opt->{q} && !defined $opt->{ch};
+ return tuwf->resRedirect("/$list->[0]{id}") if $count && $count == 1 && $opt->{q} && !defined $opt->{ch};
enrich_userlist $list;
$time = time - $time;
diff --git a/lib/VNWeb/VN/Page.pm b/lib/VNWeb/VN/Page.pm
index ff1708df..ba413fb3 100644
--- a/lib/VNWeb/VN/Page.pm
+++ b/lib/VNWeb/VN/Page.pm
@@ -55,10 +55,10 @@ sub enrich_item {
enrich_merge aid => 'SELECT id AS sid, aid, name, original FROM staff_alias WHERE aid IN', $v->{staff}, $v->{seiyuu};
enrich_merge cid => 'SELECT id AS cid, name AS char_name, original AS char_original FROM chars WHERE id IN', $v->{seiyuu};
- $v->{relations} = [ sort { $a->{vid} <=> $b->{vid} } $v->{relations}->@* ];
+ $v->{relations} = [ sort { idcmp($a->{vid}, $b->{vid}) } $v->{relations}->@* ];
$v->{anime} = [ sort { $a->{aid} <=> $b->{aid} } $v->{anime}->@* ];
$v->{staff} = [ sort { $a->{aid} <=> $b->{aid} || $a->{role} cmp $b->{role} } $v->{staff}->@* ];
- $v->{seiyuu} = [ sort { $a->{aid} <=> $b->{aid} || $a->{cid} <=> $b->{cid} || $a->{note} cmp $b->{note} } $v->{seiyuu}->@* ];
+ $v->{seiyuu} = [ sort { $a->{aid} <=> $b->{aid} || idcmp($a->{cid}, $b->{cid}) || $a->{note} cmp $b->{note} } $v->{seiyuu}->@* ];
$v->{screenshots} = [ sort { idcmp($a->{scr}{id}, $b->{scr}{id}) } $v->{screenshots}->@* ];
}
@@ -83,7 +83,7 @@ sub canvote {
sub rev_ {
my($v) = @_;
- revision_ v => $v, \&enrich_item,
+ revision_ $v, \&enrich_item,
[ title => 'Title (romaji)' ],
[ original => 'Original title' ],
[ alias => 'Alias' ],
@@ -91,26 +91,26 @@ sub rev_ {
[ desc => 'Description' ],
[ length => 'Length', fmt => \%VN_LENGTH ],
[ staff => 'Credits', fmt => sub {
- a_ href => "/s$_->{sid}", title => $_->{original}||$_->{name}, $_->{name} if $_->{sid};
+ a_ href => "/$_->{sid}", title => $_->{original}||$_->{name}, $_->{name} if $_->{sid};
b_ class => 'grayedout', '[removed alias]' if !$_->{sid};
txt_ " [$CREDIT_TYPE{$_->{role}}]";
txt_ " [$_->{note}]" if $_->{note};
}],
[ seiyuu => 'Seiyuu', fmt => sub {
- a_ href => "/s$_->{sid}", title => $_->{original}||$_->{name}, $_->{name} if $_->{sid};
+ a_ href => "/$_->{sid}", title => $_->{original}||$_->{name}, $_->{name} if $_->{sid};
b_ class => 'grayedout', '[removed alias]' if !$_->{sid};
txt_ ' as ';
- a_ href => "/c$_->{cid}", title => $_->{char_original}||$_->{char_name}, $_->{char_name};
+ a_ href => "/$_->{cid}", title => $_->{char_original}||$_->{char_name}, $_->{char_name};
txt_ " [$_->{note}]" if $_->{note};
}],
[ relations => 'Relations', fmt => sub {
txt_ sprintf '[%s] %s: ', $_->{official} ? 'official' : 'unofficial', $VN_RELATION{$_->{relation}}{txt};
- a_ href => "/v$_->{vid}", title => $_->{original}||$_->{title}, $_->{title};
+ a_ href => "/$_->{vid}", title => $_->{original}||$_->{title}, $_->{title};
}],
[ anime => 'Anime', fmt => sub { a_ href => "https://anidb.net/anime/$_->{aid}", "a$_->{aid}" }],
[ screenshots => 'Screenshots', fmt => sub {
txt_ '[';
- a_ href => "/r$_->{rid}", "r$_->{rid}" if $_->{rid};
+ a_ href => "/$_->{rid}", $_->{rid} if $_->{rid};
txt_ 'no release' if !$_->{rid};
txt_ '] ';
a_ href => imgurl($_->{scr}{id}), 'data-iv' => "$_->{scr}{width}x$_->{scr}{height}::$_->{scr}{sexual}$_->{scr}{violence}$_->{scr}{votecount}", $_->{scr}{id};
@@ -141,7 +141,7 @@ sub infobox_relations_ {
dd_ sub {
join_ \&br_, sub {
b_ class => 'grayedout', '[unofficial] ' if !$_->{official};
- a_ href => "/v$_->{vid}", title => $_->{original}||$_->{title}, shorten $_->{title}, 40;
+ a_ href => "/$_->{vid}", title => $_->{original}||$_->{title}, shorten $_->{title}, 40;
}, $rel{$_}->@*;
}
}
@@ -173,7 +173,7 @@ sub infobox_producers_ {
tr_ sub {
td_ 'Developer';
td_ sub {
- join_ ' & ', sub { a_ href => "/p$_->{id}", title => $_->{original}||$_->{name}, $_->{name}; }, @dev;
+ join_ ' & ', sub { a_ href => "/$_->{id}", title => $_->{original}||$_->{name}, $_->{name}; }, @dev;
};
} if @dev;
@@ -188,7 +188,7 @@ sub infobox_producers_ {
td_ sub {
join_ \&br_, sub {
abbr_ class => "icons lang $_", title => $LANGUAGE{$_}, '';
- join_ ' & ', sub { a_ href => "/p$_->{id}", $_->{official} ? () : (class => 'grayedout'), title => $_->{original}||$_->{name}, $_->{name} }, $lang{$_}->@*;
+ join_ ' & ', sub { a_ href => "/$_->{id}", $_->{official} ? () : (class => 'grayedout'), title => $_->{original}||$_->{name}, $_->{name} }, $lang{$_}->@*;
}, @lang;
}
} if keys %lang;
@@ -338,7 +338,7 @@ sub infobox_useroptions_ {
sub infobox_ {
my($v, $notags) = @_;
div_ class => 'mainbox', sub {
- itemmsg_ v => $v;
+ itemmsg_ $v;
h1_ $v->{title};
h2_ class => 'alttitle', lang_attr($v->{olang}), $v->{original} if $v->{original};
@@ -405,25 +405,25 @@ sub tabs_ {
$tab ||= '';
div_ class => 'maintabs', sub {
ul_ sub {
- li_ class => ($tab eq '' ? ' tabselected' : ''), sub { a_ href => "/v$v->{id}#main", name => 'main', 'main' };
- li_ class => ($tab eq 'tags' ? ' tabselected' : ''), sub { a_ href => "/v$v->{id}/tags#tags", name => 'tags', 'tags' };
- li_ class => ($tab eq 'chars' ? ' tabselected' : ''), sub { a_ href => "/v$v->{id}/chars#chars", name => 'chars', "characters ($chars)" } if $chars;
+ li_ class => ($tab eq '' ? ' tabselected' : ''), sub { a_ href => "/$v->{id}#main", name => 'main', 'main' };
+ li_ class => ($tab eq 'tags' ? ' tabselected' : ''), sub { a_ href => "/$v->{id}/tags#tags", name => 'tags', 'tags' };
+ li_ class => ($tab eq 'chars' ? ' tabselected' : ''), sub { a_ href => "/$v->{id}/chars#chars", name => 'chars', "characters ($chars)" } if $chars;
if($v->{reviews}{mini} > 4 || $tab eq 'minireviews' || $tab eq 'fullreviews') {
- li_ class => ($tab eq 'minireviews'?' tabselected' : ''), sub { a_ href => "/v$v->{id}/minireviews#review", name => 'review', "mini reviews ($v->{reviews}{mini})" } if $v->{reviews}{mini};
- li_ class => ($tab eq 'fullreviews'?' tabselected' : ''), sub { a_ href => "/v$v->{id}/fullreviews#review", name => 'review', "full reviews ($v->{reviews}{full})" } if $v->{reviews}{full};
+ li_ class => ($tab eq 'minireviews'?' tabselected' : ''), sub { a_ href => "/$v->{id}/minireviews#review", name => 'review', "mini reviews ($v->{reviews}{mini})" } if $v->{reviews}{mini};
+ li_ class => ($tab eq 'fullreviews'?' tabselected' : ''), sub { a_ href => "/$v->{id}/fullreviews#review", name => 'review', "full reviews ($v->{reviews}{full})" } if $v->{reviews}{full};
} elsif($v->{reviews}{mini} || $v->{reviews}{full}) {
- li_ class => ($tab =~ /reviews/ ?' tabselected':''), sub { a_ href => "/v$v->{id}/reviews#review", name => 'review', sprintf 'reviews (%d)', $v->{reviews}{total} };
+ li_ class => ($tab =~ /reviews/ ?' tabselected':''), sub { a_ href => "/$v->{id}/reviews#review", name => 'review', sprintf 'reviews (%d)', $v->{reviews}{total} };
}
};
ul_ sub {
if(auth && canvote $v) {
my $id = tuwf->dbVali('SELECT id FROM reviews WHERE vid =', \$v->{id}, 'AND uid =', \auth->uid);
- li_ sub { a_ href => "/v$v->{id}/addreview", 'add review' } if !$id && can_edit w => {};
+ li_ sub { a_ href => "/$v->{id}/addreview", 'add review' } if !$id && can_edit w => {};
li_ sub { a_ href => "/$id/edit", 'edit review' } if $id;
}
if(auth->permEdit) {
- li_ sub { a_ href => "/v$v->{id}/add", 'add release' };
- li_ sub { a_ href => "/v$v->{id}/addchar", 'add character' };
+ li_ sub { a_ href => "/$v->{id}/add", 'add release' };
+ li_ sub { a_ href => "/$v->{id}/addchar", 'add character' };
}
};
}
@@ -436,7 +436,7 @@ sub releases_ {
# TODO: Organize a long list of releases a bit better somehow? Collapsable language sections?
enrich_release $v->{releases};
- $v->{releases} = [ sort { $a->{released} <=> $b->{released} || $a->{id} <=> $b->{id} } $v->{releases}->@* ];
+ $v->{releases} = [ sort { $a->{released} <=> $b->{released} || idcmp($a->{id}, $b->{id}) } $v->{releases}->@* ];
my %lang;
my @lang = grep !$lang{$_}++, map $_->{lang}->@*, $v->{releases}->@*;
@@ -484,7 +484,7 @@ sub staff_ {
xml_string sub {
li_ class => 'vnstaff_head', $CREDIT_TYPE{$_};
li_ sub {
- a_ href => "/s$_->{sid}", title => $_->{original}||$_->{name}, $_->{name};
+ a_ href => "/$_->{sid}", title => $_->{original}||$_->{name}, $_->{name};
b_ title => $_->{note}, class => 'grayedout', $_->{note} if $_->{note};
} for sort { $a->{name} cmp $b->{name} } $roles{$_}->@*;
}
@@ -540,7 +540,7 @@ sub charsum_ {
div_ class => 'mainbox', 'data-mainbox-summarize' => 200, sub {
p_ class => 'mainopts', sub {
- a_ href => "/v$v->{id}/chars#chars", 'Full character list';
+ a_ href => "/$v->{id}/chars#chars", 'Full character list';
};
h1_ 'Character summary';
div_ class => 'charsum_list', sub {
@@ -548,7 +548,7 @@ sub charsum_ {
div_ class => 'name', sub {
span_ sub {
abbr_ class => "icons gen $_->{gender}", title => $GENDER{$_->{gender}}, '' if $_->{gender} ne 'unknown';
- a_ href => "/c$_->{id}", title => $_->{original}||$_->{name}, $_->{name};
+ a_ href => "/$_->{id}", title => $_->{original}||$_->{name}, $_->{name};
};
i_ $CHAR_ROLE{$_->{role}}{txt};
};
@@ -556,7 +556,7 @@ sub charsum_ {
txt_ 'Voiced by';
$_->{seiyuu}->@* > 1 ? br_ : txt_ ' ';
join_ \&br_, sub {
- a_ href => "/s$_->{id}", title => $_->{original}||$_->{name}, $_->{name};
+ a_ href => "/$_->{id}", title => $_->{original}||$_->{name}, $_->{name};
b_ class => 'grayedout', $_->{note} if $_->{note};
}, $_->{seiyuu}->@*;
} if $_->{seiyuu}->@*;
@@ -614,12 +614,12 @@ sub stats_ {
txt_ 'Recent votes';
b_ sub {
txt_ '(';
- a_ href => "/v$v->{id}/votes", 'show all';
+ a_ href => "/$v->{id}/votes", 'show all';
txt_ ')';
}
} } };
tfoot_ sub { tr_ sub { td_ colspan => 3, sub {
- a_ href => "/v$v->{id}/reviews#review", sprintf'%d review%s »', $v->{reviews}{total}, $v->{reviews}{total}==1?'':'s';
+ a_ href => "/$v->{id}/reviews#review", sprintf'%d review%s »', $v->{reviews}{total}, $v->{reviews}{total}==1?'':'s';
} } } if $v->{reviews}{total};
tr_ sub {
td_ sub {
@@ -692,7 +692,7 @@ sub screenshots_ {
p_ class => 'rel', sub {
abbr_ class => "icons lang $_", title => $LANGUAGE{$_}, '' for $r->{languages}->@*;
abbr_ class => "icons $_", title => $PLATFORM{$_}, '' for $r->{platforms}->@*;
- a_ href => "/r$r->{id}", $r->{title};
+ a_ href => "/$r->{id}", $r->{title};
};
div_ class => 'scr', sub {
a_ href => imgurl($_->{scr}{id}),
@@ -794,12 +794,12 @@ sub tags_ {
TUWF::get qr{/$RE{vrev}}, sub {
- my $v = db_entry v => tuwf->capture('id'), tuwf->capture('rev');
+ my $v = db_entry tuwf->captures('id', 'rev');
return tuwf->resNotFound if !$v;
enrich_item $v, 1;
- framework_ title => $v->{title}, index => !tuwf->capture('rev'), type => 'v', dbobj => $v, hiddenmsg => 1, js => 1, og => og($v),
+ framework_ title => $v->{title}, index => !tuwf->capture('rev'), dbobj => $v, hiddenmsg => 1, js => 1, og => og($v),
sub {
rev_ $v if tuwf->capture('rev');
infobox_ $v;
@@ -814,12 +814,12 @@ TUWF::get qr{/$RE{vrev}}, sub {
TUWF::get qr{/$RE{vid}/tags}, sub {
- my $v = db_entry v => tuwf->capture('id');
+ my $v = db_entry tuwf->capture('id');
return tuwf->resNotFound if !$v;
enrich_vn $v;
- framework_ title => $v->{title}, index => 1, type => 'v', dbobj => $v, hiddenmsg => 1,
+ framework_ title => $v->{title}, index => 1, dbobj => $v, hiddenmsg => 1,
sub {
infobox_ $v, 1;
tabs_ $v, 'tags';
diff --git a/lib/VNWeb/VN/Tagmod.pm b/lib/VNWeb/VN/Tagmod.pm
index c6af98c4..26abcfd7 100644
--- a/lib/VNWeb/VN/Tagmod.pm
+++ b/lib/VNWeb/VN/Tagmod.pm
@@ -4,7 +4,7 @@ use VNWeb::Prelude;
my $FORM = {
- id => { id => 1 },
+ id => { vndbid => 'v' },
title => { _when => 'out' },
tags => { sort_keys => 'id', aoh => {
id => { id => 1 },
@@ -96,7 +96,7 @@ TUWF::get qr{/$RE{vid}/tagmod}, sub {
$_->{othnotes} = join "\n", map user_displayname($_).': '.$_->{notes}, $_->{othnotes}->@*;
}
- framework_ title => "Edit tags for $v->{title}", type => 'v', dbobj => $v, tab => 'tagmod', sub {
+ framework_ title => "Edit tags for $v->{title}", dbobj => $v, tab => 'tagmod', sub {
elm_ 'Tagmod' => $FORM_OUT, { id => $v->{id}, title => $v->{title}, tags => $tags, mod => auth->permTagmod };
};
};
diff --git a/lib/VNWeb/VN/Votes.pm b/lib/VNWeb/VN/Votes.pm
index c286cb78..a5bce3f7 100644
--- a/lib/VNWeb/VN/Votes.pm
+++ b/lib/VNWeb/VN/Votes.pm
@@ -56,7 +56,7 @@ TUWF::get qr{/$RE{vid}/votes}, sub {
{ a => 'ASC', d => 'DESC' }->{$opt->{o}}
);
- framework_ title => "Votes for $v->{title}", type => 'v', dbobj => $v, sub {
+ framework_ title => "Votes for $v->{title}", dbobj => $v, sub {
div_ class => 'mainbox', sub {
h1_ "Votes for $v->{title}";
p_ 'No votes to list. :(' if !@$lst;
diff --git a/lib/VNWeb/Validation.pm b/lib/VNWeb/Validation.pm
index ec271841..cf95734c 100644
--- a/lib/VNWeb/Validation.pm
+++ b/lib/VNWeb/Validation.pm
@@ -214,7 +214,7 @@ sub validate_dbid {
sub can_edit {
my($type, $entry) = @_;
- return auth->permUsermod || auth->permDbmod || auth->permImgmod || auth->permBoardmod || auth->permTagmod || (auth && $entry->{id} == auth->uid) if $type eq 'u';
+ return auth->permUsermod || auth->permDbmod || auth->permImgmod || auth->permBoardmod || auth->permTagmod || (auth && $entry->{id} eq auth->uid) if $type eq 'u';
return auth->permDbmod if $type eq 'd';
if($type eq 't') {
@@ -229,14 +229,14 @@ sub can_edit {
} else {
die "Can't do authorization test when hidden/date/user_id fields aren't present"
if !exists $entry->{hidden} || !exists $entry->{date} || !exists $entry->{user_id};
- return auth && $entry->{user_id} == auth->uid && !$entry->{hidden} && $entry->{date} > time-config->{board_edit_time};
+ return auth && $entry->{user_id} eq auth->uid && !$entry->{hidden} && $entry->{date} > time-config->{board_edit_time};
}
}
if($type eq 'w') {
return 1 if auth->permBoardmod;
return auth->permReview if !$entry->{id};
- return auth && auth->uid == $entry->{user_id};
+ return auth && auth->uid eq $entry->{user_id};
}
if($type eq 'g' || $type eq 'i') {