mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-11-09 20:12:59 +00:00
Fix filesystem regression (#5176)
* $:/config/OriginalTiddlerPaths if no filters match * fixed & docs updated * tested with tiddlywiki.files & tw.com edition * typos * originalpath to options, propigate isEditableFile * syntax cleanup
This commit is contained in:
38
boot/boot.js
38
boot/boot.js
@@ -1894,7 +1894,7 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) {
|
||||
});
|
||||
});
|
||||
if(isEditableFile) {
|
||||
tiddlers.push({filepath: pathname, hasMetaFile: !!metadata && !isTiddlerFile, tiddlers: fileTiddlers});
|
||||
tiddlers.push({filepath: pathname, hasMetaFile: !!metadata && !isTiddlerFile, isEditableFile: true, tiddlers: fileTiddlers});
|
||||
} else {
|
||||
tiddlers.push({tiddlers: fileTiddlers});
|
||||
}
|
||||
@@ -2074,6 +2074,11 @@ $tw.loadWikiTiddlers = function(wikiPath,options) {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
// Save the path to the tiddlers folder for the filesystemadaptor
|
||||
var config = wikiInfo.config || {};
|
||||
if($tw.boot.wikiPath == wikiPath) {
|
||||
$tw.boot.wikiTiddlersPath = path.resolve($tw.boot.wikiPath,config["default-tiddler-location"] || $tw.config.wikiTiddlersSubDir);
|
||||
}
|
||||
// Load any parent wikis
|
||||
if(wikiInfo.includeWikis) {
|
||||
parentPaths = parentPaths.slice(0);
|
||||
@@ -2107,27 +2112,30 @@ $tw.loadWikiTiddlers = function(wikiPath,options) {
|
||||
$tw.boot.files[tiddler.title] = {
|
||||
filepath: tiddlerFile.filepath,
|
||||
type: tiddlerFile.type,
|
||||
hasMetaFile: tiddlerFile.hasMetaFile
|
||||
hasMetaFile: tiddlerFile.hasMetaFile,
|
||||
isEditableFile: config["retain-original-tiddler-path"] || tiddlerFile.isEditableFile || tiddlerFile.filepath.indexOf($tw.boot.wikiTiddlersPath) !== 0
|
||||
};
|
||||
});
|
||||
}
|
||||
$tw.wiki.addTiddlers(tiddlerFile.tiddlers);
|
||||
});
|
||||
// Save the original tiddler file locations if requested
|
||||
var config = wikiInfo.config || {};
|
||||
if(config["retain-original-tiddler-path"]) {
|
||||
var output = {}, relativePath;
|
||||
if ($tw.boot.wikiPath == wikiPath) {
|
||||
// Save the original tiddler file locations if requested
|
||||
var output = {}, relativePath, fileInfo;
|
||||
for(var title in $tw.boot.files) {
|
||||
relativePath = path.relative(resolvedWikiPath,$tw.boot.files[title].filepath);
|
||||
output[title] =
|
||||
path.sep === "/" ?
|
||||
relativePath :
|
||||
relativePath.split(path.sep).join("/");
|
||||
fileInfo = $tw.boot.files[title];
|
||||
if(fileInfo.isEditableFile) {
|
||||
relativePath = path.relative($tw.boot.wikiTiddlersPath,fileInfo.filepath);
|
||||
output[title] =
|
||||
path.sep === "/" ?
|
||||
relativePath :
|
||||
relativePath.split(path.sep).join("/");
|
||||
}
|
||||
}
|
||||
if(Object.keys(output).length > 0){
|
||||
$tw.wiki.addTiddler({title: "$:/config/OriginalTiddlerPaths", type: "application/json", text: JSON.stringify(output)});
|
||||
}
|
||||
$tw.wiki.addTiddler({title: "$:/config/OriginalTiddlerPaths", type: "application/json", text: JSON.stringify(output)});
|
||||
}
|
||||
// Save the path to the tiddlers folder for the filesystemadaptor
|
||||
$tw.boot.wikiTiddlersPath = path.resolve($tw.boot.wikiPath,config["default-tiddler-location"] || $tw.config.wikiTiddlersSubDir);
|
||||
// Load any plugins within the wiki folder
|
||||
var wikiPluginsPath = path.resolve(wikiPath,$tw.config.wikiPluginsSubDir);
|
||||
if(fs.existsSync(wikiPluginsPath)) {
|
||||
@@ -2174,7 +2182,7 @@ $tw.loadTiddlersNode = function() {
|
||||
// Load any extra plugins
|
||||
$tw.utils.each($tw.boot.extraPlugins,function(name) {
|
||||
if(name.charAt(0) === "+") { // Relative path to plugin
|
||||
var pluginFields = $tw.loadPluginFolder(name.substring(1));;
|
||||
var pluginFields = $tw.loadPluginFolder(name.substring(1));
|
||||
if(pluginFields) {
|
||||
$tw.wiki.addTiddler(pluginFields);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user