Open gabejohnson opened 6 years ago
Thanks for reporting this! Maybe the API for creating an anonymous gist changed. I'll try to take a look at this over the weekend.
So Github removed the option to post anonymous gists.
One possible alternative is to use a different service, such as lpaste.
It's not entirely certain what the future of lpaste is - https://www.reddit.com/r/haskell/comments/862k28/looking_for_new_maintainer_of_lpastenet/
Would it be ok to use GitHub OAuth and then create the gist as the editing user?
The following is a result of the PureScript hack session:
If we decide to go down the oauth route to store gists on behalf of users we'll have to:
OAuth application needs to be registed with GitHub in order to receive secret tokens
http://localhost:3000
will suffice for the dev accountBring in the following packages
The flow of code from trypurescript (FE, BE - front-end, back-end) would look like:
User has a previous session
The session info is in the secure cookie
User does not have a previous session
gist
scope)Notes:
the encryption key provided by the clientsession package will have to be persisted across restarts (either in ENV or in a file)
the application oauth clientid and secrettoken will need to be provided as part of the app's startup
https://developer.github.com/apps/building-oauth-apps/authorization-options-for-oauth-apps/
https://developer.github.com/apps/building-oauth-apps/scopes-for-oauth-apps/
https://developer.github.com/apps/managing-oauth-apps/troubleshooting-authorization-request-errors/
We should have a control that sets the visibility (secret
/public
) of the gist (default to secret
).
I've seen the thread before and I'm pretty certain someone is going to pick lpaste up. Also I think it's by far the simplest solution to the problem (a simple UI for sharing a trypurs gist from trypurs).
Would either of these options work:
Unfortunately, both of the above are vulnerable to spam.
I think option 1 is likely to be against GitHub's Terms of Service, or at least liable to get the account we use banned; from their point of view, I'd expect that it's basically the same as anonymous gists. I'm not keen on option 2 either, and yeah, that's because of spam.
What are your thoughts on storing code as a compressed string in the URL?
The typescript web editor does this with lz-string (code link).
const hash = `code/${LZString.compressToEncodedURIComponent(State.inputModel.getValue())}`;
// later
let userCode = LZString.decompressFromEncodedURIComponent(code)
This simplifies things in a few ways:
The downside is that these links are a lot longer than a gist.
You don't want these pasted into Slack not as linked text.
Unfortunately Slack made the insane decision to have Ctrl+Shift+u
be the hotkey for generating links (not Ctrl+k
like virtually every other program: github editor, google docs, etc.), which also happens to be the "Unicode Code Point" shortcut in Ubuntu, and there's no way to change this hotkey in Slack. Another option is the overloaded Ctrl+v
shortcut on highlighted text, but that won't give you link preview until you send the message. Zulip just lets you use the [text](link)
pattern.
Here's an example URL.
Here's what happens if the URL is pasted raw.
Here's an editor prototype with both gist and url-compressed code saving and sharing.
https://milesfrain.github.io/gist-prototype/?gist=66a6389000ac663e8ba6d97381bfe4d0 https://github.com/milesfrain/gist-prototype
This eliminates the need for local storage, and the confusion that happens when folks try to share an edited gist that points to their local session. This new version guarantees that the URL you copy contains an accurate snapshot of your current editor view.
Here's an example of a current TryPureScript link that looks different to me as is does for you: https://try.purescript.org/?gist=429eab1e957e807f9feeddbf4f573dd0&session=f56137be-699b-23c3-f457-6227d3b126b3
Let me know if this is the strategy we want to go with for TryPureScript.
@milesfrain I think that sounds like a neat approach!
This is really cool! I'm on board with this approach. It's a best-of-both-worlds in that if you don't want to bother with a gist or you don't want to authenticate anything then you can use the longer link, and if you want a shorter link for aesthetics or because you want a gist then you can.
I'm happy to consider this approach - I definitely agree that having the same URL have different behaviour based on what happens to be in the user's local storage is not ideal. I'm a little hesitant about having compressed code in the URL, as I'm sure we will see some of those huge URLs floating around, although that's probably an acceptable price to make stuff on Try PS easily shareable.
Fortunately the typical size of a TryPureScript module is pretty small and the URL isn’t that long.
Create all gists through a tryPureScript account
I think option 1 is likely to be against GitHub's Terms of Service, or at least liable to get the account we use banned; from their point of view, I'd expect that it's basically the same as anonymous gists.
FWIW this is the approach that play.rust-lang.org takes and it seems to be okay.
Here's an editor prototype with both gist and url-compressed code saving and sharing.
https://milesfrain.github.io/gist-prototype/?gist=66a6389000ac663e8ba6d97381bfe4d0 https://github.com/milesfrain/gist-prototype
I agree this is a neat approach, is there still interest in implementing this? As noted, TS Playground uses lz-string
for (de)compression and so does Try Reason. Would adding a dependency like that still be within the scope of the project? There is a native Compression Streams API but it doesn't have great browser support at the moment.
I'm personally fine with that. I think it's a nice feature.
When attempting to share, I receive an alert with the message:
This is caused by a failed
POST
:The response payload: