Widdershin / tricycle

Try Cycle.js in your browser, no setup required.
http://widdersh.in/tricycle/
MIT License
25 stars 4 forks source link

allow saving scripts #11

Open alkhe opened 8 years ago

alkhe commented 8 years ago

Kind of like esfiddle, where you can associate a script with a permalink.

This would make it a lot more useful for collaborative prototyping and debugging.

Widdershin commented 8 years ago

I would really love to see this happen. Potentially it could come in the form of a gist backend and Tricycle could remain entirely client side (you can do clientside github oAuth with https://github.com/prose/gatekeeper, I have a proof of concept).

It could also be a backend.

I very much welcome the community's help on this one.

griffinmichl commented 8 years ago

I've been exploring this feature. Seems pretty straightforward so far, but there are a few different approaches. I like the idea of keeping this app entirely client side. I don't think oauth is necessary to achieve that goal. It can be implemented similar to jsfiddle.net, where you just get a public url that takes you back to the same code. The main difference is that, since there's no real backend for tricycle, we need to use a querystring (ex. http://tricycle.com?gist=12345) rather than a permalink (ex. http://jsfiddle.net/12345) to store the location of the corresponding gist.

My current approach is:

(1) When a user clicks save, make a post to '/gists' (2) Change the address bar to include a querystring with gist set to the gist_id (3) When a user provides a gist querystring upon arriving on the page, a get request loads up the contents of that gist

The only thing I don't like about this approach is that it generates very long URLs. I'm going to continue hacking on this, but let me know if you have any different preferences.

EDIT: I forgot that github enforces a very low ratelimit for unauthenticated requests (60/hr), which could definitely influence this design decision