Open romsson opened 4 years ago
See https://twitter.com/ilyabo/status/1210112298234339328 for example
https://flowmap.blue/
: app1icUMT7Q3V0DOPHBahXJlz7Mz_BYOgLv9InZUHX_5xIE
: link to backend state, that contains the data and some init parameters, I guess (in fact, just the data since it's the google spreadsheet id: https://docs.google.com/spreadsheets/d/1icUMT7Q3V0DOPHBahXJlz7Mz_BYOgLv9InZUHX_5xIE/)?v=49.272478,5.910396,5.91&a=1&b=1&c=0&d=1<=0&col=Sunset&f=24
: interaction parameters that are never saved to the backendSo:
geojson.io allows the user to save the state to a gist (or to a new file in any of your GitHub repositories!):
http://geojson.io/#id=gist:severo/ea0b5a136625e915bf4ecbd828a11da7&map=6/-16.400/-63.550
(see created gist at https://gist.github.com/severo/ea0b5a136625e915bf4ecbd828a11da7 - API reference: https://developer.github.com/v3/gists/)
But obviously, you have to give some rights to the app (too much in the case of geojson.io!)
https://blockbuilder.org/ does the same: it saves the code and data to gists, and requires the user to be authenticated to github and give some rights to the app (it's much less intrusive than geojson!)
The block: https://bl.ocks.org/severo/e85697db4fb9080ef685404aba785616/89a9faab8b5ab358aa342b441bb985b792b81d00 The gist: https://gist.github.com/severo/e85697db4fb9080ef685404aba785616
Beware: the GIST API doesn't allow to upload images nor any other binary data, just text!
In order to save images, we might use the Imgur API. It allows 1.250 uploads per day from the application (for all the app users).
The discussions:
[ ] Media hosting Currently, the user can upload an image, and it only exists in the browser cache. In order to share any state that uses that image, we must "persist" that image to some backend service. Which one? Image hosting is very restricted (for censure/legal reasons), maybe use Imgur? Flickr? or some more generic service: dropbox? google drive? onedrive? local nextclouds? Note also that if we allow video uploading, the problem will become harder, but there are solutions too, like youtube, dailymotion, vimeo (or local peertubes).
Note: it's possible to upload images to gists (see https://gist.github.com/mroderick/1afdd71aa69f6b29601d335751a1a9be), but it requires to use git. Not sure if it's possible through the API (https://blockbuilder.org/ "+" button doesn't allow to add an image: "Sorry, the gist API supports text files only.")
We will only share the "state parameters" in this issue. Data and media hosting are treated in #52.
See the Vega specification editor. It allows to save a whole Vega specification in the URL, for example:
From the editor:
Share
We pack the Vega or Vega-Lite specification and an encoded string in the URL.
We use LZ-based compression algorithm and preserve indentation, newlines, and other whitespace.
Number of charaters in the URL: 865
Code is at https://github.com/vega/editor/blob/master/src/components/header/share-modal/renderer.tsx#L28:
const serializedSpec =
LZString.compressToEncodedURIComponent(this.props.editorString) + (this.state.fullScreen ? '/view' : '');
if (serializedSpec) {
const url = `${document.location.href.split('#')[0]}#/url/${this.props.mode}/${serializedSpec}`;
Uses lz-string. Not sure if it's still maintained, but it's a lot more lightweight (4kB) than pako (786kB).
See a comparison at https://observablehq.com/@severo/hello-lz-string
Create a url that contains positions and image choice. URL should be updated after each interaction so a page refresh re-loads exactly where the points were.
Eventually include/anticipate some more parameters (categories, etc.)
Eventually shorten the url (url limit is 2k chars)
Note (@severo): don't remember the uploaded pictures. See #52 for that feature.