zig-play icon indicating copy to clipboard operation
zig-play copied to clipboard

Loading and saving programs from the playground

Open jarble opened this issue 4 years ago • 3 comments

There's currently no way to share links to programs in the Zig playground. But there should be a way to save a link to a program in a query string, like this:

https://zig-play.dev/?source_code_goes_here

I would use encodeURIComponent to convert the source code to a query string, and then use decodeURIcomponent to convert it back to source code.

jarble avatar Jul 24 '21 18:07 jarble

Thanks for opening this issue. I wanted to do this eventually but thought about resorting to using auxiliary storage to do so. This seems like a much simpler way since it would eliminate the need for that. I'd be happy to review a patch if you're willing to write one.

gsquire avatar Jul 24 '21 18:07 gsquire

I thought it would be simpler to load and save the programs in a query string or fragment identifier, since it would only require client-side JavaScript without "auxiliary storage" on the server side.

But the query string has a very short size limit, so auxiliary storage might still be better.

jarble avatar Jul 25 '21 13:07 jarble

Ah yeah, I forgot to think about the query string length limit. I'll try and sketch out a plan for this though. Something using an S3 like storage system and some internal caching should perform well.

gsquire avatar Jul 28 '21 05:07 gsquire