-
Notifications
You must be signed in to change notification settings - Fork 33
Description
Our playground's share link button currently encodes the entire code in base64 and include it in the URL we generate. This works for small code, but for large shaders the generated URL would be too long and quickly exceed the limit of URL length in many browsers.
We should allow the playground to load source from an URL that is provided from the ?file=...
option, and add UI to load external URLs.
The load demo drop down can have an item called "From URL...", and when that is selected, we popup a diaglog box asking the user to paste in the url.
We should introduce a new status called contentSource
to track where the source is coming from. contentSource
can be in three states:
demo
, which means the current text box is showing a predefined demo.user-code
, which means the current text box contains user defined/modified code.url
, which means the current text box is showing content loaded from an URL.
By default, contentSource
is user-code
, and when the user loads from an URL, we set it to url, to indicate we are now sourcing from a external file (this state is reset to user-code
once the user makes any modifications).
Depending on the state of contentSource
, sharing link can return url in different formats.
When contentSource
is url
, clicking the share link button should not encode the content, but encode the url in a "?file="
option.
When contentSource
is demo
, sharing link should return "?demo=..."
in the url.
When contentSource
is user_code
, sharing link should encode the source and return "?code=..."
.