NO FUSS NO MUSS

This commit is contained in:
disu1950 2024-07-04 07:45:38 +02:00
parent 1f7d32ed2c
commit a70623ab46
Signed by: disu1950
GPG Key ID: C501A0B4E515C516
4 changed files with 1735 additions and 0 deletions

1654
assets/deflate.js Normal file

File diff suppressed because it is too large Load Diff

52
assets/encode.js Normal file
View File

@ -0,0 +1,52 @@
/** Functions from https://plantuml.com/code-javascript-synchronous
*/
function encode64(data) {
r = "";
for (i=0; i<data.length; i+=3) {
if (i+2==data.length) {
r +=append3bytes(data.charCodeAt(i), data.charCodeAt(i+1), 0);
} else if (i+1==data.length) {
r += append3bytes(data.charCodeAt(i), 0, 0);
} else {
r += append3bytes(data.charCodeAt(i), data.charCodeAt(i+1),
data.charCodeAt(i+2));
}
}
return r;
}
function append3bytes(b1, b2, b3) {
c1 = b1 >> 2;
c2 = ((b1 & 0x3) << 4) | (b2 >> 4);
c3 = ((b2 & 0xF) << 2) | (b3 >> 6);
c4 = b3 & 0x3F;
r = "";
r += encode6bit(c1 & 0x3F);
r += encode6bit(c2 & 0x3F);
r += encode6bit(c3 & 0x3F);
r += encode6bit(c4 & 0x3F);
return r;
}
function encode6bit(b) {
if (b < 10) {
return String.fromCharCode(48 + b);
}
b -= 10;
if (b < 26) {
return String.fromCharCode(65 + b);
}
b -= 26;
if (b < 26) {
return String.fromCharCode(97 + b);
}
b -= 26;
if (b == 0) {
return '-';
}
if (b == 1) {
return '_';
}
return '?';
}

View File

@ -0,0 +1,17 @@
/* Copyright (C) 2020 David Svantesson
* MIT License
*
*/
function parsePlantumlCodeBlocks(plantumlServer = "http://www.plantuml.com/plantuml", htmlClass = "language-plantuml") {
var codeBlocks = document.getElementsByClassName(htmlClass);
for (var block_i = 0; block_i < codeBlocks.length; block_i++) {
block_string = codeBlocks[block_i].innerText
//UTF8
block_string = unescape(encodeURIComponent(block_string));
codeBlocks[block_i].innerHTML = "<img src=\"" + plantumlServer + "/img/" + encode64(zip_deflate(block_string, 9)) + "\">";
}
}

12
footer.tmpl Normal file
View File

@ -0,0 +1,12 @@
<script>
$(async () => {
if (!$('.language-plantuml').length) return;
await Promise.all([
$.getScript('https://gitea.dmz.rs/disu1950/android-toolz/assets/deflate.js'),
$.getScript('https://gitea.dmz.rs/disu1950/android-toolz/assets/encode.js'),
$.getScript('https://gitea.dmz.rs/disu1950/android-toolz/assets/plantuml_codeblock_parse.js'),
]);
// Replace call with address to your plantuml server
parsePlantumlCodeBlocks("https://www.plantuml.com/plantuml");
});
</script>