Hi,
i'm currently extending TW to support YAML-Frontmattered File-Formats (i'm
on node). The implementation itself is clear to me. What i'm struggling
about is, how would i put it best into TW itself? I tried the following
ways without my intented success:
- a plugin implementing a "module-type: tiddlerserializer"=> it seems to
be only used when dropping a "frontmattered" MD-File into my browser and
NOT when a (in my case .md-) file is loaded from the fs in node-env
- a plugin implementing "module-type: startup" => then the tiddlers are
already loaded and i can parse stuff to my liking, CREATE A NEW TIDDLER but
then run into trouble when writing it back to fs, because the filename is
already used (but the original tiddler) and it attaches a "_$COUNTER$"
suffix to the file-name
What works as expected is, when i change the file *boot.js* (what obviously
is no good idea) by defining my own module like this:
$tw.modules.define("$:/boot/tiddlerdeserializer/md","tiddlerdeserializer",{
"text/x-markdown": function(text,fields,type) { MY CODE HERE }});
Is there a way to solve that in a more plugin'ish way?
==== SECOND TOPIC ====
The way back to the fs is implemented in kinda more pluginish way, but also
not satisfactory to my understanding: i use a "module-type: utils-node" and
remember the current "saveTiddlerToFile" function like this:
const origSaveTiddlerToFile = $tw.utils.saveTiddlerToFile;
then i overwrite the "saveTiddlerToFile"-Function in there like so:
exports.saveTiddlerToFile = function(tiddler,fileInfo,callback) { MY NEW
CODE HERE};
Within this function i simply check, if the current tiddler is something
i'm interested in (basically by looking at the type "text/-x-markdown") and
do my stuff by directly working with nodes fs/path-modules. Otherwise i
delegate to the "rembered" function by invoking origSaveTiddlerToFile ....
Kinda hack'ish isn't it?
How would i solve that in a more TW/plugin'ish way?
Thanks a lot,
Mirko
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywikidev/f755b31c-8181-4fff-8ebc-2027f0525a15n%40googlegroups.com.