From 83f976ea5485f399b5930b4f82fe93b9ac5b4bb6 Mon Sep 17 00:00:00 2001 From: saqimtiaz Date: Mon, 26 Oct 2020 18:36:50 +0100 Subject: [PATCH] Extended tiddlywiki.files to allow optionally saving changes to a tiddler back to the original file location (#4914) --- boot/boot.js | 10 +++++++--- .../tw5.com/tiddlers/nodejs/tiddlywiki.files_Files.tid | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/boot/boot.js b/boot/boot.js index 969a8c567..456cceb14 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -1824,7 +1824,7 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) { // Read the specification var filesInfo = JSON.parse(fs.readFileSync(filepath + path.sep + "tiddlywiki.files","utf8")); // Helper to process a file - var processFile = function(filename,isTiddlerFile,fields) { + var processFile = function(filename,isTiddlerFile,fields,isEditableFile) { var extInfo = $tw.config.fileExtensionInfo[path.extname(filename)], type = (extInfo || {}).type || fields.type || "text/plain", typeInfo = $tw.config.contentTypeInfo[type] || {}, @@ -1877,7 +1877,11 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) { } }); }); - tiddlers.push({tiddlers: fileTiddlers}); + if(isEditableFile) { + tiddlers.push({filepath: pathname, hasMetaFile: !!metadata && !isTiddlerFile, tiddlers: fileTiddlers}); + } else { + tiddlers.push({tiddlers: fileTiddlers}); + } }; // Process the listed tiddlers $tw.utils.each(filesInfo.tiddlers,function(tidInfo) { @@ -1907,7 +1911,7 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) { for(var t=0; t> ** ''fields'' - (required) an object containing values that override or customise the fields provided in the tiddler file (see above) Fields can be overridden for particular files by creating a file with the same name plus the suffix `.meta` -- see TiddlerFiles.