Open bigtimebuddy opened 5 years ago
I can put something like this together for playground this weekend. Thanks @bigtimebuddy!
Actually I just realized, you can hit the API to create a new playground just like the app does normally.
I don't have good docs, but here is the handler: https://github.com/englercj/playground/blob/master/server/src/routes/playgrounds.ts#L122
Just make a POST to https://pixiplayground.com/api/playground
with JSON data. Something like:
{
"name": "",
"description": "",
"contents": "",
"author": "",
"pixiVersion": "",
"isPublic": true,
"externaljs": [
{ "url": "" },
{ "url": "" }
]
}
Where pixiVersion
is the URL to your generated file, and the externaljs
array is the list of scripts to load (they will be loaded in order). Only contents
and pixiVersion
are required.
The API call will return a resolved playground data JSON object which includes the generated slug that you can use to craft the URL the user should navigate to, which is https://pixiplayground.com/#/edit/<slug>
.
Does this work?
What is pixiVersion? The semver? If I provide a version does try to load that bundle?
pixiVersion
can be:
"release"
which is the latest build on S3 from the release branch"v5.0.0-rc3"
for example, which will pull the S3 build for that tag.The value here will be loaded first before externaljs
.
cc @englercj
Here's an example of JSFiddle POST API for auto-filling: https://docs.jsfiddle.net/api/display-a-fiddle-from-post
Basically, there are two pieces of information that I post to JSFiddle and CodePen: a snippet of JS code that bootstraps all the plugins, and a list of external resources that are loaded in a specific order. I also set an initial title/description.
This could probably work with PixiPlayground as Settings > Custom URL > External Scripts. And contents to populate the code area.