diff --git a/blog/feed.xml b/blog/feed.xml index 503bd8b..29a3532 100644 --- a/blog/feed.xml +++ b/blog/feed.xml @@ -5,7 +5,7 @@ askiiart.net blog The feed for askiiart.net but just the blog, I guess https://askiiart.net/blog/ - Thu, 02 Jan 2025 03:17:03 +0000 + Tue, 07 Jan 2025 15:30:31 +0000 300 https://askiiart.net/til/300.html @@ -26,6 +26,10 @@ Another new PGP key https://askiiart.net/til/another-new-pgp-key.html + + This page is portable + https://askiiart.net/til/this-page-is-portable.html + \ No newline at end of file diff --git a/blog/this-page-is-actually-portable.html b/blog/this-page-is-actually-portable.html new file mode 100644 index 0000000..9a8effb --- /dev/null +++ b/blog/this-page-is-actually-portable.html @@ -0,0 +1,85 @@ + + + + + This page is portable + + + + +

This page is portable

+

This page, even with its images, fonts, and javascript, is + completely portable, and will work offline with no other + files.

+
+

This is essentially a showcase and writeup about One + Webpage, Under God, a program I made to make a page + completely portable and independent of any other files. It + doesn't handle everything, but does perfectly on a simple static + site like my own, with images, fonts, and javascript, it works + perfectly.

+
let hello = "hiiiiiiiiii";
+// Check out this fancy code block without using any other files
+
+ I can even have this picture of a turtle in here + +
+

Okay but how

+

Really, this page should be titled "All hail the Data URI + Scheme and whoever came up with it, that's how this entire + program works. If you're unaware, a data URI looks like + this:

+
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA
+

To break this down:

+ +

If it's text data, then it can use percent-encoding instead, + though I couldn't get this to work, so I just encoded everything + in base64 instead.

+

Fonts

+

The rest of all this is really simple - we just replace the + link to the asset with a data URI. Fonts, however, are more + complicated. They're linked in the CSS, not the HTML, which + leads to this mess - fonts encoded in base64, inside of + CSS which is then itself encoded in base64.

+
@font-face {
+        /* from https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/FiraCode */
+        font-family: "FiraCode";
+        src: 'FiraCode', url('data:font/woff2;base64,d09GMgABAA...76Ufr9TLXi4DgAA');
+}
+

This also led to me being reminded how huge my fonts are; + because of them my site's homepage comes out to nearly 2 MiB + even without prism.js, which contains a duplicate + FiraCode Nerd Font, which is of course also hardcoded in.

+
+

One last thing: Relative links are very not portable + of course, so I just tacked on this bit to the end to fix + that

+
links = soup.find_all('link')
+for item in links:
+    if 'stylesheet' not in item.attrs['rel'] and 'icon' not in item.attrs['rel']:
+        item.attrs['href'] = absolute_url(item.attrs['href'], domain_thing)
+

Oh also, this page is actually not portable - aside + from the johnvertisement iframe at the bottom, I didn't make it + portable regardless because it's 3+ MiB, and I didn't want to + put that kind of load on my internet connection for no reason. + If it weren't for my upload speed suddenly sexdecupling (16x) + for some reason, it would take more than a second to load. The + actually portable version is here

+ + + + + + \ No newline at end of file diff --git a/blog/this-page-is-portable.html b/blog/this-page-is-portable.html new file mode 100644 index 0000000..650d7bb --- /dev/null +++ b/blog/this-page-is-portable.html @@ -0,0 +1,95 @@ + + + + + + This page is portable + + + + +

This page is portable

+

This page, even with its images, fonts, and javascript, is + completely portable, and will work offline with no other + files.

+
+

This is essentially a showcase and writeup about One + Webpage, Under God, a program I made to make a page + completely portable and independent of any other files. It + doesn't handle everything, but does perfectly on a simple static + site like my own, with images, fonts, and javascript, it works + perfectly.

+
let hello = "hiiiiiiiiii";
+// Check out this fancy code block without using any other files
+
+ I can even have this picture of a turtle in here + +
+

Okay but how

+

Really, this page should be titled "All hail the Data URI + Scheme and whoever came up with it, that's how this entire + program works. If you're unaware, a data URI looks like + this:

+
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA
+

To break this down:

+ +

If it's text data, then it can use percent-encoding instead, + though I couldn't get this to work, so I just encoded everything + in base64 instead.

+

Fonts

+

The rest of all this is really simple - we just replace the + link to the asset with a data URI. Fonts, however, are more + complicated. They're linked in the CSS, not the HTML, which + leads to this mess - fonts encoded in base64, inside of + CSS which is then itself encoded in base64.

+
@font-face {
+        /* from https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/FiraCode */
+        font-family: "FiraCode";
+        src: 'FiraCode', url('data:font/woff2;base64,d09GMgABAA...76Ufr9TLXi4DgAA');
+}
+

This also led to me being reminded how huge my fonts are; + because of them my site's homepage comes out to nearly 2 MiB + even without prism.js, which contains a duplicate + FiraCode Nerd Font, which is of course also hardcoded in.

+
+

One last thing: Relative links are very not portable + of course, so I just tacked on this bit to the end to fix + that

+
links = soup.find_all('link')
+for item in links:
+    if 'stylesheet' not in item.attrs['rel'] and 'icon' not in item.attrs['rel']:
+        item.attrs['href'] = absolute_url(item.attrs['href'], domain_thing)
+

Oh also, this page is actually not portable - aside + from the johnvertisement iframe at the bottom, I didn't make it + portable regardless because it's 3+ MiB, and I didn't want to + put that kind of load on my internet connection for no reason. + If it weren't for my upload speed suddenly sexdecupling (16x) + for some reason, it would take more than a second to load. The + actually portable version is here

+ + + + + diff --git a/blog/this-page-is-portable.md b/blog/this-page-is-portable.md new file mode 100644 index 0000000..6bfe7e2 --- /dev/null +++ b/blog/this-page-is-portable.md @@ -0,0 +1,58 @@ +# This page is portable + +This page, even with its images, fonts, and javascript, is completely portable, and will work offline with no other files. + +--- + +This is essentially a showcase and writeup about [One Webpage, Under God](https://git.askiiart.net/askiiart/one-webpage-under-god), a program I made to make a page completely portable and independent of any other files. It doesn't handle everything, but does perfectly on a simple static site like my own, with images, fonts, and javascript, it works perfectly. + +```rs +let hello = "hiiiiiiiiii"; +// Check out this fancy code block without using any other files +``` + +![I can even have this picture of a turtle in here](/assets/askiiart.avif) + +## Okay but how + +Really, this page should be titled "All hail the [Data URI Scheme](https://en.wikipedia.org/wiki/Data_URI_scheme) and whoever came up with it, that's how this entire program works. If you're unaware, a data URI looks like this: + +```txt +data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA +``` + +To break this down: + +- `data:` This is a data URI +- `image/png`: The [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types) of the data +- `;base64` Indicates that this is encoded in base64 (optional, see [MDN docs](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data)) +- `iVBORw0KGgoAAAANSUhEUgAAAA`: base64-encoded data + +If it's text data, then it can use percent-encoding instead, though I couldn't get this to work, so I just encoded everything in base64 instead. + +## Fonts + +The rest of all this is really simple - we just replace the link to the asset with a data URI. Fonts, however, are more complicated. They're linked in the CSS, not the HTML, which leads to *this* mess - fonts encoded in base64, inside of CSS which is then itself encoded in base64. + +```css +@font-face { + /* from https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/FiraCode */ + font-family: "FiraCode"; + src: 'FiraCode', url('data:font/woff2;base64,d09GMgABAA...76Ufr9TLXi4DgAA'); +} +``` + +This also led to me being reminded how huge my fonts are; because of them my site's homepage comes out to nearly 2 MiB even without `prism.js`, which contains a duplicate FiraCode Nerd Font, which is of course also hardcoded in. + +--- + +One last thing: Relative links are very *not* portable of course, so I just tacked on this bit to the end to fix that + +```py +links = soup.find_all('link') +for item in links: + if 'stylesheet' not in item.attrs['rel'] and 'icon' not in item.attrs['rel']: + item.attrs['href'] = absolute_url(item.attrs['href'], domain_thing) +``` + +Oh also, this page is actually *not* portable - aside from the johnvertisement iframe at the bottom, I didn't make it portable regardless because it's 3+ MiB, and I didn't want to put that kind of load on my internet connection for no reason. If it weren't for my upload speed suddenly sexdecupling (16x) for some reason, it would take more than a second to load. The *actually portable* version is [here](/blog/this-page-is-actually-portable.html) diff --git a/feed.xml b/feed.xml index 17bd3bc..982e396 100644 --- a/feed.xml +++ b/feed.xml @@ -5,7 +5,7 @@ askiiart.net The feed for askiiart.net, I guess https://askiiart.net - Thu, 02 Jan 2025 03:17:03 +0000 + Tue, 07 Jan 2025 15:30:31 +0000 300 https://askiiart.net/blog/300.html @@ -26,6 +26,10 @@ Another new PGP key https://askiiart.net/blog/another-new-pgp-key.html + + This page is portable + https://askiiart.net/blog/this-page-is-portable.html + Akkoma in Docker https://askiiart.net/til/akkoma-in-docker.html diff --git a/generate-rss.sh b/generate-rss.sh index 7c16400..ff59587 100755 --- a/generate-rss.sh +++ b/generate-rss.sh @@ -6,7 +6,7 @@ printf "\n\n\n\n askiiart.net\n The feed for askiiart.net, I guess\n https://askiiart.net\n $(TZ='UTC' date --rfc-2822)" >feed.xml find . -path ./error -prune -o -name '*.html' -print | while read -r item; do # Skip template.html, wishlist.html, resume.html, and portfolio.html - if [[ ${item} == "./index.html" || ${item} == "./template.html" || ${item} == "./wishlist.html" || ${item} == "./resume.html" || ${item} == "./portfolio.html" || ${item} == "./opx.html" ]]; then + if [[ ${item} == "./index.html" || ${item} == "./template.html" || ${item} == "./wishlist.html" || ${item} == "./resume.html" || ${item} == "./portfolio.html" || ${item} == "./opx.html" || ${item} == "./blog/this-page-is-actually-portable.html" ]]; then continue fi item="${item%.*}" @@ -32,6 +32,9 @@ cd .. cd ./blog printf "\n\n\n\n askiiart.net blog\n The feed for askiiart.net but just the blog, I guess\n https://askiiart.net/blog/\n $(TZ='UTC' date --rfc-2822)" >feed.xml find . -name "*.html" | while read -r item; do + if [[ ${item} == "./this-page-is-actually-portable.html" ]]; then + continue + fi item="${item%.*}" item="${item#./}" TITLE=$(grep -m 1 -oP '(?<=^# ).*' ${item}.md | cat) diff --git a/sitemap.xml b/sitemap.xml index f0e9bb9..40904f9 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -1,6 +1,7 @@ https://askiiart.net/blog/ https://askiiart.net/blog/300.html +https://askiiart.net/blog/another-new-pgp-key.html https://askiiart.net/blog/foooooonts.html https://askiiart.net/blog/marlin-boot-animations.html https://askiiart.net/blog/new-pgp-key.html