Closed Adrijaned closed 4 years ago
I like this idea, but why use a JSON payload instead of the same form data format that we already use?
And this question led me to realize that this feature is in fact already pretty much available – just POST regular form data to the template page instead:
<form action="http://localhost:5000/template/english-noun/advanced">
<input type="hidden" name="form_representation" value="example">
<input type="hidden" name="form_representation" value="examples">
<button>Go!</button>
</form>
You’ll get a CSRF error, but all the inputs have their values preserved, so you can click “Create” and the lexeme is created. (Well, except that in this case the lexeme would be a duplicate, and apparently there’s a bug that’s making the ”this is not a duplicate” checkbox not show up.) So I think it would actually be enough to add a parameter that hides the CSRF error message. What do you think?
(The bigger question, I think, is how you would use this? Because I don’t think you can make users issue POST requests from wikitext.)
Why JSON and how to use this? When I was making this, what I had in mind, was along the way of just being able to make a plain old static website with some regular JavaScript, and generating the forms through that, were there no other option. And sending it as form data just looks ugly.
Oh, wait, no, I'm dumb. There is a reason why I don't usually attempt at programming website things. As implemented this PR may as well be useless. Doesn't change a bit about the form approach being ugly though. :(
What’s so ugly about the form approach?
You are using essentially a key-value store in the form of form data to transfer a really sequential data, all under the same key furthermore. Although you are using ImmutableOrderedMultiDict
s, and order of form data in request should be the same as in websire per standards, it still seems to me like a likely way for errors to easily slip through. Keep in mind I'm in no way a web developer tho.
To avoid overly long URLs with templates such as czech-adjective, when using the autogeneration capability, adds an option to send those forms using JSON payload.
Example using httpie:
http POST :5000/template/english-noun/ form_representation:='["cat","cats"]'