mirror of
https://github.com/arfct/itty-bitty.git
synced 2026-03-11 08:54:33 +00:00
correct svg handling, added basic brotli
This commit is contained in:
parent
0a1dfa5833
commit
77f79f8ea9
5 changed files with 2307 additions and 3 deletions
14
docs/data.js
14
docs/data.js
|
|
@ -45,6 +45,20 @@ function decompressDataURI(dataURI, preamble, callback) {
|
|||
|
||||
function zipToString(data, callback) {
|
||||
var array = base64ToByteArray(data);
|
||||
if (array[0] == 31) { // Handle Brotli
|
||||
var script= document.createElement('script');
|
||||
script.type = "module"
|
||||
script.innerHTML = `import {BrotliDecode} from "./js/brotli/decode.js";console.log("yo");window.brotli = BrotliDecode;`;
|
||||
document.head.appendChild(script);
|
||||
setTimeout(() => {
|
||||
return callback((window.brotli(array)));
|
||||
},100);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
LZMA.decompress(array, function(result, error) {
|
||||
if (!(typeof result === 'string')) result = new Uint8Array(result)
|
||||
if (error) console.error(error);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
<!DOCTYPE html><html xmanifest="manifest.appcache"><meta name="viewport" content="width=device-width, viewport-fit=cover" viewport-fit=cover"><meta name="description" content="itty bitty things can be conveyed in a link.">
|
||||
<!DOCTYPE html><html xmanifest="manifest.appcache"><meta name="viewport" content="width=device-width, viewport-fit=cover"><meta name="description" content="itty bitty things can be conveyed in a link.">
|
||||
<link id="favicon" rel=icon href=''>
|
||||
<script src="/js/lzma/lzma-d-min.js"></script>
|
||||
<script src="/data.js"></script>
|
||||
<script src="/index.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="/index.css">
|
||||
<noscript>To use itty.bitty, please enable JavaScript.</noscript>
|
||||
<div id="toast">itty.bitty is experimental technology that renders linked content from outside sources. <a href="http://toast.bitty.site" target="_blank">Learn more</a>.
|
||||
|
|
|
|||
|
|
@ -68,12 +68,12 @@ window.onhashchange = window.onload = function() {
|
|||
} else {
|
||||
let match = hash.match(dataRE);
|
||||
let type = match?.groups.type;
|
||||
if (validTypes.includes(type)) {
|
||||
if (type == "application/ld+json") {
|
||||
let script = '<script src="' + location.origin + '/render/recipe.js"></script>'
|
||||
script = script + " ".repeat(3 - (script.length % 3))
|
||||
preamble = btoa(script);
|
||||
renderMode = "frame";
|
||||
} else {
|
||||
} else if (!validTypes.includes(type)) {
|
||||
console.log("unknown type, rendering as download")
|
||||
let extension = title.split(".")
|
||||
document.querySelector("#dl-name").innerText = title;
|
||||
|
|
|
|||
2288
docs/js/brotli/decode.js
Normal file
2288
docs/js/brotli/decode.js
Normal file
File diff suppressed because one or more lines are too long
1
docs/js/brotli/decode.min.js
vendored
Normal file
1
docs/js/brotli/decode.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue