1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-11-14 14:27:16 +00:00

Extended tiddlywiki.files to allow optionally saving changes to a tiddler back to the original file location (#4914)

This commit is contained in:
saqimtiaz
2020-10-26 18:36:50 +01:00
committed by GitHub
parent 3153c588ec
commit 83f976ea54
2 changed files with 8 additions and 3 deletions

View File

@@ -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<files.length; t++) {
var filename = files[t];
if(filename !== "tiddlywiki.files" && !metaRegExp.test(filename) && fileRegExp.test(filename)) {
processFile(dirPath + path.sep + filename,dirSpec.isTiddlerFile,dirSpec.fields);
processFile(dirPath + path.sep + filename,dirSpec.isTiddlerFile,dirSpec.fields,dirSpec.isEditableFile);
}
}
}