summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--elm/DocEdit.elm9
-rw-r--r--elm/StaffEdit/Main.elm14
-rw-r--r--elm/User/Edit.elm2
-rw-r--r--elm/User/Login.elm4
-rw-r--r--elm/User/Register.elm2
-rw-r--r--lib/VNWeb/Discussions/Thread.pm4
-rw-r--r--lib/VNWeb/Docs/Edit.pm8
-rw-r--r--lib/VNWeb/Misc/BBCode.pm2
-rw-r--r--lib/VNWeb/Releases/JS.pm2
-rw-r--r--lib/VNWeb/Staff/Edit.pm8
-rw-r--r--lib/VNWeb/User/Edit.pm2
-rw-r--r--lib/VNWeb/User/Lists.pm14
-rw-r--r--lib/VNWeb/User/Login.pm4
-rw-r--r--lib/VNWeb/User/Register.pm2
14 files changed, 36 insertions, 41 deletions
diff --git a/elm/DocEdit.elm b/elm/DocEdit.elm
index c0ab746c..3fad1f8f 100644
--- a/elm/DocEdit.elm
+++ b/elm/DocEdit.elm
@@ -45,7 +45,8 @@ init d =
encode : Model -> GD.Send
encode model =
- { editsum = model.editsum.editsum.data
+ { id = model.id
+ , editsum = model.editsum.editsum.data
, hidden = model.editsum.hidden
, locked = model.editsum.locked
, title = model.title
@@ -69,10 +70,8 @@ update msg model =
Content m -> let (nm,nc) = TP.update m model.content in ({ model | content = nm }, Cmd.map Content nc)
Submit ->
- let
- path = "/d" ++ String.fromInt model.id ++ "/edit"
- body = GD.encode (encode model)
- in ({ model | state = Api.Loading }, Api.post path body Submitted)
+ let body = GD.encode (encode model)
+ in ({ model | state = Api.Loading }, Api.post "/d/edit.json" body Submitted)
Submitted (GApi.Changed id rev) -> (model, load <| "/d" ++ String.fromInt id ++ "." ++ String.fromInt rev)
Submitted r -> ({ model | state = Api.Error r }, Cmd.none)
diff --git a/elm/StaffEdit/Main.elm b/elm/StaffEdit/Main.elm
index d3e287da..4ea50fd5 100644
--- a/elm/StaffEdit/Main.elm
+++ b/elm/StaffEdit/Main.elm
@@ -57,7 +57,7 @@ init d =
, l_twitter = d.l_twitter
, l_anidb = d.l_anidb
, l_pixiv = d.l_pixiv
- , id = Just d.id
+ , id = d.id
}
@@ -82,7 +82,8 @@ new =
encode : Model -> GSE.Send
encode model =
- { editsum = model.editsum.editsum.data
+ { id = model.id
+ , editsum = model.editsum.editsum.data
, hidden = model.editsum.hidden
, locked = model.editsum.locked
, aid = model.aid
@@ -147,13 +148,8 @@ update msg model =
AliasAdd -> ({ model | alias = model.alias ++ [{ aid = newAid model, name = "", original = "", inuse = False }] }, Cmd.none)
Submit ->
- let
- path =
- case model.id of
- Just id -> "/s" ++ String.fromInt id ++ "/edit"
- Nothing -> "/s/add"
- body = GSE.encode (encode model)
- in ({ model | state = Api.Loading }, Api.post path body Submitted)
+ let body = GSE.encode (encode model)
+ in ({ model | state = Api.Loading }, Api.post "/s/edit.json" body Submitted)
Submitted (GApi.Changed id rev) -> (model, load <| "/s" ++ String.fromInt id ++ "." ++ String.fromInt rev)
Submitted r -> ({ model | state = Api.Error r }, Cmd.none)
diff --git a/elm/User/Edit.elm b/elm/User/Edit.elm
index 1a9b9a55..df1647e4 100644
--- a/elm/User/Edit.elm
+++ b/elm/User/Edit.elm
@@ -124,7 +124,7 @@ update msg model =
Submit ->
if model.cpass && model.pass1 /= model.pass2
then ({ model | passNeq = True }, Cmd.none )
- else ({ model | state = Api.Loading }, Api.post "/u/edit" (GUE.encode model.data) Submitted)
+ else ({ model | state = Api.Loading }, Api.post "/u/edit.json" (GUE.encode model.data) Submitted)
-- TODO: This reload is only necessary for the skin and customcss options to apply, but it's nicer to do that directly from JS.
Submitted GApi.Success -> (model, load <| "/u" ++ String.fromInt model.data.id ++ "/edit")
diff --git a/elm/User/Login.elm b/elm/User/Login.elm
index cc25d132..d28faf6b 100644
--- a/elm/User/Login.elm
+++ b/elm/User/Login.elm
@@ -80,11 +80,11 @@ update msg model =
Submit ->
if not model.insecure
then ( { model | state = Api.Loading }
- , Api.post "/u/login" (encodeLogin model) Submitted )
+ , Api.post "/u/login.json" (encodeLogin model) Submitted )
else if model.newpass1 /= model.newpass2
then ( { model | noteq = True }, Cmd.none )
else ( { model | state = Api.Loading }
- , Api.post "/u/changepass" (encodeChangePass model) Submitted )
+ , Api.post "/u/changepass.json" (encodeChangePass model) Submitted )
Submitted GApi.Success -> (model, load model.ref)
Submitted GApi.InsecurePass -> ({ model | insecure = True, state = if model.insecure then Api.Error GApi.InsecurePass else Api.Normal }, Cmd.none)
diff --git a/elm/User/Register.elm b/elm/User/Register.elm
index add16418..60f5d7d4 100644
--- a/elm/User/Register.elm
+++ b/elm/User/Register.elm
@@ -62,7 +62,7 @@ update msg model =
VNs n -> ({ model | vns = Maybe.withDefault model.vns (String.toInt n) }, Cmd.none)
Submit -> ( { model | state = Api.Loading }
- , Api.post "/u/register" (encodeForm model) Submitted )
+ , Api.post "/u/register.json" (encodeForm model) Submitted )
Submitted GApi.Success -> ({ model | success = True }, Cmd.none)
Submitted e -> ({ model | state = Api.Error e }, Cmd.none)
diff --git a/lib/VNWeb/Discussions/Thread.pm b/lib/VNWeb/Discussions/Thread.pm
index c81e02a9..a5e003af 100644
--- a/lib/VNWeb/Discussions/Thread.pm
+++ b/lib/VNWeb/Discussions/Thread.pm
@@ -181,7 +181,7 @@ TUWF::get qr{/$RE{postid}}, sub {
};
-json_api qr{/t/pollvote.json}, $POLL_IN, sub {
+json_api qr{/t/pollvote\.json}, $POLL_IN, sub {
my($data) = @_;
return elm_Unauth if !auth;
@@ -197,7 +197,7 @@ json_api qr{/t/pollvote.json}, $POLL_IN, sub {
};
-json_api qr{/t/reply.json}, $REPLY_IN, sub {
+json_api qr{/t/reply\.json}, $REPLY_IN, sub {
my($data) = @_;
my $t = tuwf->dbRowi('SELECT id, locked, count FROM threads t WHERE id =', \$data->{tid}, 'AND', sql_visible_threads());
return tuwf->resNotFound if !$t->{id};
diff --git a/lib/VNWeb/Docs/Edit.pm b/lib/VNWeb/Docs/Edit.pm
index 9e90f717..fd3ce958 100644
--- a/lib/VNWeb/Docs/Edit.pm
+++ b/lib/VNWeb/Docs/Edit.pm
@@ -5,13 +5,13 @@ use VNWeb::Docs::Lib;
my $FORM = {
+ id => { id => 1 },
title => { maxlength => 200 },
content => { required => 0, default => '' },
hidden => { anybool => 1 },
locked => { anybool => 1 },
editsum => { _when => 'in out', editsum => 1 },
- id => { _when => 'out', id => 1 },
};
my $FORM_OUT = form_compile out => $FORM;
@@ -34,9 +34,9 @@ TUWF::get qr{/$RE{drev}/edit} => sub {
};
-json_api qr{/$RE{drev}/edit}, $FORM_IN, sub {
+json_api qr{/d/edit\.json}, $FORM_IN, sub {
my $data = shift;
- my $doc = db_entry d => tuwf->capture('id') or return tuwf->resNotFound;
+ my $doc = db_entry d => $data->{id} or return tuwf->resNotFound;
return elm_Unauth if !can_edit d => $doc;
return elm_Unchanged if !form_changed $FORM_CMP, $data, $doc;
@@ -46,7 +46,7 @@ json_api qr{/$RE{drev}/edit}, $FORM_IN, sub {
};
-json_api '/js/markdown.json', {
+json_api qr{/js/markdown\.json}, {
content => { required => 0, default => '' }
}, sub {
return elm_Unauth if !auth->permDbmod;
diff --git a/lib/VNWeb/Misc/BBCode.pm b/lib/VNWeb/Misc/BBCode.pm
index 09501cb8..643ccbc4 100644
--- a/lib/VNWeb/Misc/BBCode.pm
+++ b/lib/VNWeb/Misc/BBCode.pm
@@ -2,7 +2,7 @@ package VNWeb::Misc::BBCode;
use VNWeb::Prelude;
-json_api '/js/bbcode.json', {
+json_api qr{/js/bbcode\.json}, {
content => { required => 0, default => '' }
}, sub {
elm_Content bb2html bb_subst_links shift->{content};
diff --git a/lib/VNWeb/Releases/JS.pm b/lib/VNWeb/Releases/JS.pm
index 0ecc05aa..a258036b 100644
--- a/lib/VNWeb/Releases/JS.pm
+++ b/lib/VNWeb/Releases/JS.pm
@@ -4,7 +4,7 @@ use VNWeb::Prelude;
# Used by UList.Opt to fetch releases from a VN id.
-json_api qr{/r/get.json}, { vid => { id => 1 } }, sub {
+json_api qr{/r/get\.json}, { vid => { id => 1 } }, sub {
my($data) = @_;
my $l = tuwf->dbAlli(
'SELECT r.id, r.title, r.original, r.type AS rtype, r.released
diff --git a/lib/VNWeb/Staff/Edit.pm b/lib/VNWeb/Staff/Edit.pm
index 43ca9c90..f0fc9d7c 100644
--- a/lib/VNWeb/Staff/Edit.pm
+++ b/lib/VNWeb/Staff/Edit.pm
@@ -4,6 +4,7 @@ use VNWeb::Prelude;
my $FORM = {
+ id => { required => 0, id => 1 },
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
@@ -22,7 +23,6 @@ my $FORM = {
hidden => { anybool => 1 },
locked => { anybool => 1 },
- id => { _when => 'out', id => 1 },
authmod => { _when => 'out', anybool => 1 },
editsum => { _when => 'in out', editsum => 1 },
};
@@ -65,10 +65,10 @@ TUWF::get qr{/s/new}, sub {
};
-json_api qr{/(?:$RE{sid}/edit|s/add)}, $FORM_IN, sub {
+json_api qr{/s/edit\.json}, $FORM_IN, sub {
my $data = shift;
- my $new = !tuwf->capture('id');
- my $e = $new ? { id => 0 } : db_entry s => tuwf->capture('id') or return tuwf->resNotFound;
+ my $new = !$data->{id};
+ my $e = $new ? { id => 0 } : db_entry s => $data->{id} or return tuwf->resNotFound;
return elm_Unauth if !can_edit s => $e;
if(!auth->permDbmod) {
diff --git a/lib/VNWeb/User/Edit.pm b/lib/VNWeb/User/Edit.pm
index f934466e..e34ef0ba 100644
--- a/lib/VNWeb/User/Edit.pm
+++ b/lib/VNWeb/User/Edit.pm
@@ -78,7 +78,7 @@ TUWF::get qr{/$RE{uid}/edit}, sub {
};
-json_api qr{/u/edit}, $FORM, sub {
+json_api qr{/u/edit\.json}, $FORM, sub {
my $data = shift;
my $username = tuwf->dbVali('SELECT username FROM users WHERE id =', \$data->{id});
diff --git a/lib/VNWeb/User/Lists.pm b/lib/VNWeb/User/Lists.pm
index eea7eb4f..94071076 100644
--- a/lib/VNWeb/User/Lists.pm
+++ b/lib/VNWeb/User/Lists.pm
@@ -17,7 +17,7 @@ my $LABELS = form_compile any => {
elm_form 'UListManageLabels', undef, $LABELS;
-json_api qr{/u/ulist/labels.json}, $LABELS, sub {
+json_api qr{/u/ulist/labels\.json}, $LABELS, sub {
my($uid, $labels) = ($_[0]{uid}, $_[0]{labels});
return elm_Unauth if !auth || auth->uid != $uid;
@@ -80,7 +80,7 @@ my $VNVOTE = form_compile any => {
elm_form 'UListVoteEdit', undef, $VNVOTE;
-json_api qr{/u/ulist/setvote.json}, $VNVOTE, sub {
+json_api qr{/u/ulist/setvote\.json}, $VNVOTE, sub {
my($data) = @_;
return elm_Unauth if !auth || auth->uid != $data->{uid};
tuwf->dbExeci(
@@ -110,7 +110,7 @@ my $VNLABELS_IN = form_compile in => $VNLABELS;
elm_form 'UListLabelEdit', $VNLABELS_OUT, $VNLABELS_IN;
-json_api qr{/u/ulist/setlabel.json}, $VNLABELS_IN, sub {
+json_api qr{/u/ulist/setlabel\.json}, $VNLABELS_IN, sub {
my($data) = @_;
return elm_Unauth if !auth || auth->uid != $data->{uid};
die "Attempt to set vote label" if $data->{label} == 7;
@@ -141,7 +141,7 @@ my $VNDATE = form_compile any => {
elm_form 'UListDateEdit', undef, $VNDATE;
-json_api qr{/u/ulist/setdate.json}, $VNDATE, sub {
+json_api qr{/u/ulist/setdate\.json}, $VNDATE, sub {
my($data) = @_;
return elm_Unauth if !auth || auth->uid != $data->{uid};
tuwf->dbExeci(
@@ -183,7 +183,7 @@ my $VNNOTES = form_compile any => {
elm_form 'UListVNNotes', undef, $VNNOTES;
-json_api qr{/u/ulist/setnote.json}, $VNNOTES, sub {
+json_api qr{/u/ulist/setnote\.json}, $VNNOTES, sub {
my($data) = @_;
return elm_Unauth if !auth || auth->uid != $data->{uid};
tuwf->dbExeci(
@@ -203,7 +203,7 @@ my $VNDEL = form_compile any => {
elm_form 'UListDel', undef, $VNDEL;
-json_api qr{/u/ulist/del.json}, $VNDEL, sub {
+json_api qr{/u/ulist/del\.json}, $VNDEL, sub {
my($data) = @_;
return elm_Unauth if !auth || auth->uid != $data->{uid};
tuwf->dbExeci('DELETE FROM ulist_vns WHERE uid =', \$data->{uid}, 'AND vid =', \$data->{vid});
@@ -221,7 +221,7 @@ my $RSTATUS = form_compile any => {
elm_form 'UListRStatus', undef, $RSTATUS;
# Adds the release when not in the list.
-json_api qr{/u/ulist/rstatus.json}, $RSTATUS, sub {
+json_api qr{/u/ulist/rstatus\.json}, $RSTATUS, sub {
my($data) = @_;
return elm_Unauth if !auth || auth->uid != $data->{uid};
if($data->{status} == -1) {
diff --git a/lib/VNWeb/User/Login.pm b/lib/VNWeb/User/Login.pm
index 7c93e058..d1069b26 100644
--- a/lib/VNWeb/User/Login.pm
+++ b/lib/VNWeb/User/Login.pm
@@ -15,7 +15,7 @@ TUWF::get '/u/login' => sub {
};
-json_api '/u/login', {
+json_api qr{/u/login\.json}, {
username => { username => 1 },
password => { password => 1 }
}, sub {
@@ -41,7 +41,7 @@ json_api '/u/login', {
};
-json_api '/u/changepass', {
+json_api qr{/u/changepass\.json}, {
username => { username => 1 },
oldpass => { password => 1 },
newpass => { password => 1 },
diff --git a/lib/VNWeb/User/Register.pm b/lib/VNWeb/User/Register.pm
index 5135531b..05a1d433 100644
--- a/lib/VNWeb/User/Register.pm
+++ b/lib/VNWeb/User/Register.pm
@@ -11,7 +11,7 @@ TUWF::get '/u/register', sub {
};
-json_api '/u/register', {
+json_api qr{/u/register\.json}, {
username => { username => 1 },
email => { email => 1 },
vns => { int => 1 },