-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
Feature RequestProposal for adding a new functionalityProposal for adding a new functionalityPriority:MediumModerately important, should be completed in a fair timeframeModerately important, should be completed in a fair timeframe
Milestone
Description
Nature of issue?
- New feature requestTo pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
New feature details:
Define endpoints so that users can batch upload sketches. This also includes the data structure of the sketches themselves. It's a little complicated right now given recursive file structures of folders and this involves generating ID's for file objects. It would be cool if users didn't have to do that and it happened magically on the backend.
Metadata
Metadata
Assignees
Labels
Feature RequestProposal for adding a new functionalityProposal for adding a new functionalityPriority:MediumModerately important, should be completed in a fair timeframeModerately important, should be completed in a fair timeframe
Type
Projects
Relationships
Development
Select code repository
Activity
Vertmo commentedon Oct 10, 2018
Is the API being worked on right now ? That's seems like a bit of work, so it should probably be split in several parts; I'll start looking into it anyway ^^
catarak commentedon Oct 10, 2018
You're right, this is a huge issue! I think a good first step would be dividing this into smaller issues, figuring out all of the steps that would need to go into this. We can discuss on this issue!
Vertmo commentedon Oct 11, 2018
Ok, so the first thing would be to allow registered users to add API keys via their user settings, and of course store them in the database.
Then we will need to define secure authentification for the API (maybe we should use an already existing library).
We could then define two endpoints :
/<username>/upload
to upload a single sketch/<username>/batch-upload
to upload severalOf course, only would be able to successfully upload a sketch to their account.
OK, that's only my first thoughts. Then we will need to work out the format of the upload request (especially how to upload a whole folder). But I'll need to study the existing code more thoroughly before that !
In the meantime, can you tell me what you think of these first ideas ?
catarak commentedon Oct 11, 2018
The first part is covered in #541!
My starting point for figuring out what API endpoints should be is, surprisingly, a fairly old Rails guide. Therefore, I think the endpoint for uploading a new sketch should be POST
/<username/sketches
. Which is the same as what the editor currently uses. Maybe for multiple sketches, it could be the same endpoint, but the API could check if the data is an array vs a singular project.Also, to list some other stuff I think needs to happen:
files
structure, which is a tree structure. I followed a Mongo Tree Structure Guide to create a data structure in which each file has an array of itschildren
, and thechildren
array contains ONLY the ids, not the full files. Maybe it doesn't make sense to expect users to do this manually. I wonder what is a realistic data structure for users! Maybe just a nested object/array for files, which gets Mongo-ified server-side?Vertmo commentedon Oct 11, 2018
catarak commentedon Oct 11, 2018
Not sure if these reasons make sense, but this is what I was thinking about with respect to separating the front end and the API:
Now that I write this all out, it doesn't seem that important!
I wonder what the best way to handle images and sounds would be! They're stored on S3, so the API would have to handle uploading the files to S3 and then storing the url with the sketch files. Maybe a zip would make sense. Maybe the POST
/<username>/sketches
route can't handle images/sounds, but a separate route can handle zip files. There are a lot of options!Vertmo commentedon Oct 11, 2018
Also ! (and this is kind of unrelated to the issue, but I don't know where to talk about this) I'll be hosting a Hacktoberfest event Saturday, so I'll try to send students this way (and more generally to the processing repositories).
catarak commentedon May 7, 2019
i think a good reference could be @joeyklee's script to upload the ml5 examples to the web editor (https://github.com/processing/p5.js-web-editor/blob/master/server/scripts/examples-ml5.js). maybe the format of the sketches should be similar to how files are stored on github, and then once sent to the API, could be converted using the helper functions (or similar helper functions) that are in that uploader file.
joeyklee commentedon May 7, 2019
@catarak - I'm happy to help in any way on this + very much looking forward to making this happen! Thank you!
andrewn commentedon May 13, 2019
I've started thinking about the shape of the API that supports sketch uploads. #541 covers the authenticaton work to allow access to the API so the comments below assume it exists.
We already have a rich API that has sketch CRUD functionality, so the existing import scripts could be rewritten to use the existing API at
/api
.The existing endpoints could also be extended to allow files to be created in a more friendly way. Specifically, IDs would be generated on the server instead of in the scripts (see #1073 for a proposal). This still means more code, but the ultimate aim could be updating the Editor client web app to use the new API fields.
The downside to this approach is that some of these endpoints would now become a public API and we'd need to be careful making changes to them. As part of this work, I'd like to write tests around whatever code is touched, so this would be a good way of making sure we don't break things going forward. And we'd document the endpoints that are now public.
Alternatively, we can create new endpoints that are the public API. This would reduce the implementation complexity, but would mean more code that would be doing very similar things.
Would be great to hear your thoughts @catarak.
catarak commentedon May 15, 2019
As we talked about, I think the best way to move forward with this is to
Then, we can write tests that will test both the public API and the API for the web editor!
pelikhan commentedon Sep 20, 2021
You could maybe consider an api similar to codesandbox.io (https://codesandbox.io/docs/api). Easy way to generate a new sketch on the fly without having to pre-generate all examples in a script.