therewasaguy / p5js-webIDE

demo ~
http://p5ide.herokuapp.com/
47 stars 11 forks source link

use html5 history API instead of hash #101

Open therewasaguy opened 8 years ago

therewasaguy commented 8 years ago

we've been using hash to load sketches without refreshing the page like this:

http://p5ide.herokuapp.com/editor#?sketch=568d9514f60b940300d5f2fd

@antiboredom suggests we use HTML History API instead like this http://p5ide.herokuapp.com/editor/sketch/568d9514f60b940300d5f2fd

because

  1. the url looks nicer, and
  2. it may help with #100, to loading files by relative paths in methods like loadJSON('data.json'). If we the server gets a request from http://p5ide.herokuapp.com/editor/sketch/568d9514f60b940300d5f2fd/assets/myimage.jpg we could see that the request is for that particular project, and return the image associated with that project that has that name.

To accomplish this, we can incorporate the vue-router module which we have not started using yet (it may not have been finished when the project began): http://vuejs.github.io/vue-router/en/api/properties.html

therewasaguy commented 8 years ago

As part of this, it might be good to revisit the url structure projects. There are currently a few ways to "view" projects.

I think the last 2 paths would need to include projectID in order to load assets with relative path (https://github.com/therewasaguy/p5js-webIDE/issues/100#issuecomment-170285300)

So maybe these could be the paths: /editor/username/projectID /view/username/projectID /preview/projectID /frameview/projectID

I think it's faster for MongoDB to find projects by ID than by name, though name is obviously friendlier.