Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistent URLs in REPL #1014

Open
samselikoff opened this issue Sep 29, 2020 · 2 comments
Open

Persistent URLs in REPL #1014

samselikoff opened this issue Sep 29, 2020 · 2 comments

Comments

@samselikoff
Copy link
Contributor

  • When I visit /repl, new repl is created, user is redirected to their unique REPL url /repl/123, and user is given edit token in localStorage.
  • When on a REPL url /repl/123, and user with token starts editing, status bar says "You have unsaved changes." Button in title bar says "Save". When clicked, REPL is updated and message clears.
  • When on a REPL url /repl/123, and user without token starts editing, status bar says "You have unsaved changes." Button in title bar says "Fork and save". When clicked, new REPL is created, user redirected to new URL /repl/456, and message clears.
@samselikoff
Copy link
Contributor Author

We don't want to create a new sandbox on the server whenever someone visits /repl, so we're going to generate the ids on the client and only create one on the server once they hit Save. Therefore the client will always need to send over the ID when creating a sandbox.

@samselikoff
Copy link
Contributor Author

New plan:

  • When I visit /repl, URL stays /repl. User starts typing and sees message "You have unsaved changes."
  • When on a /repl with unsaved changes, user can click Save which uses a clientside generated id (so we can make pretty ids), a clientside generated editing token, and a clientside generated browser_id. It sends this over along with the data and creates a sandbox on server. User is redirected to /repl/abc. User's editing token and browser_id is saved in localStorage.
  • When visiting a REPL url /repl/abc, user fetches sandbox from server with all data except for editing token. (Editing token is hidden from reads). User starts editing and status bar changes to "You have unsaved changes."
    • If user's localStorage.browser_id matches repl.browser_id, Button in title bar says "Save". When clicked, REPL is updated and message clears. (Backend verifies editing token matches).
    • If user doesn't have repl.browser_id (either different or blank), Button in title bar says "Fork and save". When clicked, client generates new REPL data (id, editing token, maybe browser_id if they don't already have one) and creates new REPL on server. User redirected to new URL /repl/def and message clears.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant