mirror of
https://gitlab.com/octtspacc/OcttKB
synced 2025-06-06 00:29:12 +02:00
OcttKB Cross-Repo Sync (HTML to Raw)
This commit is contained in:
23
Wiki-OcttKB/tiddlers/System/$__Macros_b64TidUriEnc.js
Normal file
23
Wiki-OcttKB/tiddlers/System/$__Macros_b64TidUriEnc.js
Normal file
@ -0,0 +1,23 @@
|
||||
/*\
|
||||
Return the content of a tiddler encoded as [[Base64]] and encapsulated in a data URI.
|
||||
<<b64TidUriEnc "Tiddler Name">>
|
||||
\*/
|
||||
|
||||
(function(){
|
||||
"use strict";
|
||||
exports.name = "b64TidUriEnc";
|
||||
exports.params = [
|
||||
{name: "Name"}
|
||||
];
|
||||
|
||||
exports.run = function(Name) {
|
||||
try {
|
||||
let Tid = $tw.wiki.getTiddler(Name);
|
||||
let Type = Tid.fields.type || "text/vnd.tiddlywiki";
|
||||
let Data = $tw.utils.base64Encode(Tid.fields.text);
|
||||
return "data:" + Type + ";base64," + Data;
|
||||
} catch(e) {
|
||||
return e;
|
||||
};
|
||||
};
|
||||
})();
|
Reference in New Issue
Block a user