nullboard
nullboard copied to clipboard
Shareable boards (via links?)
Lovely project. A few years ago I made something that has a small overlap with this one, and implemented a fun feature where I could share a board just through a link. Basic idea was every few seconds, I would update the fragment url with an encoded version of the data. That way I could copy the link, send it to someone, and they would effectively have a local 'fork' of the board.
The relevant ~25 lines of logic code can be found here https://github.com/jedahan/saltpeanuts/blob/master/app.js#L1-L45 , but the gist is:
const data = (() => {
const hash = rison.decode_object(decodeURI(window.location.hash.substring(1)));
if (hash.updated > 0) { return hash; }
const local = rison.decode_object(localStorage.getItem('saltpeanuts') || '');
if (local.updated > 0) { return local; }
return {
updated: new Date(),
blocks: [ 'study japanese', 'email', 'mozilla/nsf', 'click me!', 'elusive index 4' ],
schedule: {
monday: [1, 0, 0, 4],
tuesday: [4, 4, 4, 4],
wednesday: [],
thursday: [],
friday: [],
},
};
})();
window.setInterval(function() {
data.updated = new Date();
const datastring = rison.encode_object(data);
localStorage.setItem('saltpeanuts', datastring);
window.location.hash = datastring;
}, 2000 );
I used rison to encode the data in human-readable, url-safe format, but you can use whatever format you prefer or write your own encode/decoder if importing the ~500 line rison.js is too heavy.
A potentially lighter-weight and 'more standards compliant' encoding scheme may be selectors/states from https://w3c.github.io/web-annotation/selector-note/converter/ and https://w3c.github.io/web-annotation/selector-note/