Live data from Hacker News

Itty Bitty: Sites contained within their own links

itty.bitty.site

81–90 of 111 posts

Re: Itty Bitty: Sites contained within their own links

#81
So if one must think about it in terms of client/server (my mind works like this), since the website data is contained in the URI itself, then the server/site where you clicked on the URL from, can perhaps we thought of as the "web server" per se. Just a way for me to think about it. This is pretty crazy though, neat stuff.

Re: Itty Bitty: Sites contained within their own links

#82
post #72
post #71

Earlier quoted context omitted.

My mind immediately went to stuff like tickets. Can't say how many times I've gotten stuck having my ticket checked at a concert or on a train simply because there's no connectivity and the page is no longer in cache on my phone. If all the data is in the URI then it could work as an option for entirely static data. I'd say this is useful for almost anything that fits in a one page PDF.

How does that solve the no connectivity problem? You’d still need the site (with rendering scripts) cached.

Browsers have offline capabilities that are currently massively underutilized. You can store the LZMA scripts in IndexDB perhaps?

Re: Itty Bitty: Sites contained within their own links

#83
post #30

So from Content Lengths [0]... You've tested on Chrome, and IE, but not Firefox? [0] https://itty.bitty.site/#Content_Lengths/XQAAAAIXAwAAAAAAAAA...

Firefox's is very useful for testing image data URIs. You can paste the whole thing into the address bar and it will render the image.

Re: Itty Bitty: Sites contained within their own links

#87
I strongly suggest to not use this. Instead, create URIs that contain arbitrary content with the data URI scheme: https://en.wikipedia.org/wiki/Data_URI_scheme

The data URI scheme is standard and widely supported, does not rely on the host bitty.site being reachable and does not need JavaScript. One can even create data URIs with a small shell script that is given a filename argument:

  #!/bin/sh -eu
  printf 'data:%s;base64,%s' "$(file -bi "$1"|tr -d ' ')" "$(base64 -w 0 "$1")"

Re: Itty Bitty: Sites contained within their own links

#88
post #72
post #71

Earlier quoted context omitted.

My mind immediately went to stuff like tickets. Can't say how many times I've gotten stuck having my ticket checked at a concert or on a train simply because there's no connectivity and the page is no longer in cache on my phone. If all the data is in the URI then it could work as an option for entirely static data. I'd say this is useful for almost anything that fits in a one page PDF.

How does that solve the no connectivity problem? You’d still need the site (with rendering scripts) cached.

If you want the whole UI around rendering the content, sure, but you don't need that – it's just an iframe that sets a `data:` URI anyway. The link can just as well be the data URI itself. It'd be a very long link for any non trivial content, but it works just fine without any connectivity.

Seeing as tickets are typically sent in HTML emails anyway the scary looking URI can just be hidden behind a nice anchor tag or something anyway. When the recipient clicks the link, the page will open in a browser and render just fine without any connectivity. Graphics can be embedded in the same way, using `data:` URIs as image tag sources, or in embedded css.

Here's an example, turn off your connection and try this in your browser's address bar:

  data:text/html;charset=utf-8;base64,PG1ldGEgY2hhcnNldD0idXRmLTgiPjxtZXRhIG5hbWU9InZpZXdwb3J0IiBjb250ZW50PSJ3aWR0aD1kZXZpY2Utd2lkdGgiPjxiYXNlIHRhcmdldD0iX3RvcCI+PHN0eWxlIHR5cGU9InRleHQvY3NzIj5ib2R5e21hcmdpbjowIGF1dG87cGFkZGluZzoxMnZtaW4gMTB2bWluO21heC13aWR0aDozNWVtO2xpbmUtaGVpZ2h0OjEuNWVtO2ZvbnQtZmFtaWx5OiAtYXBwbGUtc3lzdGVtLEJsaW5rTWFjU3lzdGVtRm9udCxzYW5zLXNlcmlmO3dvcmQtd3JhcDogYnJlYWstd29yZDt9PC9zdHlsZT4gSGVsbG8sIEx4ciBmcm9tIEhOIQ==
EDIT: Created another, more complex, example but it's unfortunately too long for HN comments. You can see it here:

https://gist.github.com/mstade/597f7da82841b1c27c63c8b383538...

Just copy and paste the raw contents of that file into the address bar and it should render the page.

Re: Itty Bitty: Sites contained within their own links

#89
post #72

Earlier quoted context omitted.

How does that solve the no connectivity problem? You’d still need the site (with rendering scripts) cached.

Browsers have offline capabilities that are currently massively underutilized. You can store the LZMA scripts in IndexDB perhaps?

Unfortunately that comes with a bootstrapping problem: what if the first time you hit the link is when you aren't connected? If everything is embedded in the data URI and the link is in fact the data itself then it doesn't matter.

Re: Itty Bitty: Sites contained within their own links

#90
Data URL's do this without relying on the server.

E.g. this one cribbed from StackOverflow:

data:text/plain;base64,SGVsbG8sIHdvcmxkISBJJ20gZG93bmxvYWRlZCB2aWEgImRhdGE6dGV4dC9wbGFpbjsuLi4iIFVSTCB1c2luZyA8YSBkb3dubG9hZD0iZmlsZV9uYW1lIi4uLj4uDQpNeSBiaXJ0aHBsYWNlOiBodHRwOi8vc3RhY2tvdmVyZmxvdy5jb20vcXVlc3Rpb25zLzY0Njg1MTcvDQoNCk1vcmUgYWJvdXQ6DQpodHRwOi8vd3d3LnczLm9yZy9UUi9odG1sL2xpbmtzLmh0bWwjYXR0ci1oeXBlcmxpbmstZG93bmxvYWQNCmh0dHA6Ly93d3cudzMub3JnL1RSL2h0bWwvbGlua3MuaHRtbCNkb3dubG9hZGluZy1yZXNvdXJjZXMNCg0KQnJvd3NlciBzdXBwb3J0OiBodHRwOi8vY2FuaXVzZS5jb20vZG93bmxvYWQ=

Post reply on HN