beeminder / road

Beebrain and Visual Graph Editor
http://graph.beeminder.com
Other
13 stars 3 forks source link

Permalinks for graphs for the graph editor #148

Open dreeves opened 4 years ago

dreeves commented 4 years ago

Proposal: make permalinks for editing graphs. Like if Bob selects his bob/cupcakes goal in the graph editor it should change the URL to graph.beeminder.com/bob/cupcakes and if he clicks such a URL it should take him straight to that goal.

Related: #103

dreeves commented 4 years ago

Potentially useful functions:

// Rage = refresh page. Give the part of the URL starting with the first slash.
// If the second parameter is false then it just changes the URL w/o reloading.
function rage(url, reload=true) {
  window.history.pushState({}, null, url)
  if (reload) location.reload()
}

// Return the value for the given key in the querystring, defaulting to def if
// there is no such key.
function getQueryParam(key, def=false) {
  let v = def
  window.location.search.substring(1).split("&").some(function(s) {
    const pair = s.split("=")
    if (pair[0] === key) { v = pair[1]; return true }
    return false
  })
  return v
}
dreeves commented 3 years ago

This would still be great and we'd welcome PRs from any volunteers who can help!

(We're not prioritizing it ourselves because eventually it should be moot, when the graph editor is absorbed into Beeminder-proper. AKA dynagraphs.)

adamwolf commented 3 years ago

does it make sense to have an extra part in the url? graph.beeminder.com/something/bob/cupcakes

[[answer: if that made it easier to implement, that'd be fine; URL-aesthetically I'd say no, but since we intend to make it moot eventually, I'd say it doesn't matter]]