1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-02-03 04:39:10 +00:00

Load the non-shadow tiddlers into the correct wiki store

This commit is contained in:
Jeremy Ruston 2012-05-05 14:48:15 +01:00
parent 06c655a51f
commit 75f11a0c8d

View File

@ -528,7 +528,8 @@ $tw.boot.wikiPath = process.cwd();
/*
Load the tiddlers contained in a particular file (and optionally the accompanying .meta file)
*/
$tw.plugins.loadTiddlersFromFile = function(file,fields) {
$tw.plugins.loadTiddlersFromFile = function(file,fields,wiki) {
wiki = wiki || $tw.wiki;
var ext = path.extname(file),
extensionInfo = $tw.config.fileExtensions[ext],
data = fs.readFileSync(file).toString(extensionInfo ? extensionInfo.encoding : "utf8"),
@ -540,15 +541,16 @@ $tw.plugins.loadTiddlersFromFile = function(file,fields) {
tiddlers = [$tw.utils.parseFields(metadata,tiddlers[0])];
}
}
$tw.wiki.shadows.addTiddlers(tiddlers);
wiki.addTiddlers(tiddlers);
};
/*
Load all the plugins from the plugins directory
*/
$tw.plugins.loadPluginsFromFolder = function(filepath,basetitle,excludeRegExp) {
$tw.plugins.loadPluginsFromFolder = function(filepath,basetitle,excludeRegExp,wiki) {
basetitle = basetitle || "$:/plugins";
excludeRegExp = excludeRegExp || /^\.DS_Store$|.meta$/;
wiki = wiki || $tw.wiki.shadows;
if(path.existsSync(filepath)) {
var stat = fs.statSync(filepath);
if(stat.isDirectory()) {
@ -558,19 +560,19 @@ $tw.plugins.loadPluginsFromFolder = function(filepath,basetitle,excludeRegExp) {
// If so, process the files it describes
var pluginInfo = JSON.parse(fs.readFileSync(filepath + "/tiddlywiki.plugin").toString("utf8"));
for(var p=0; p<pluginInfo.tiddlers.length; p++) {
$tw.plugins.loadTiddlersFromFile(path.resolve(filepath,pluginInfo.tiddlers[p].file),pluginInfo.tiddlers[p].fields);
$tw.plugins.loadTiddlersFromFile(path.resolve(filepath,pluginInfo.tiddlers[p].file),pluginInfo.tiddlers[p].fields,wiki);
}
} else {
// If not, read all the files in the directory
for(var f=0; f<files.length; f++) {
var file = files[f];
if(!excludeRegExp.test(file)) {
$tw.plugins.loadPluginsFromFolder(filepath + "/" + file,basetitle + "/" + file,excludeRegExp);
$tw.plugins.loadPluginsFromFolder(filepath + "/" + file,basetitle + "/" + file,excludeRegExp,wiki);
}
}
}
} else if(stat.isFile()) {
$tw.plugins.loadTiddlersFromFile(filepath,{title: basetitle});
$tw.plugins.loadTiddlersFromFile(filepath,{title: basetitle},wiki);
}
}
};
@ -620,7 +622,7 @@ $tw.plugins.loadPluginsFromFolder(path.resolve($tw.boot.wikiPath,$tw.config.wiki
// Load shadow tiddlers from wiki shadows directory
$tw.plugins.loadPluginsFromFolder(path.resolve($tw.boot.wikiPath,"./shadows"));
// Load tiddlers from wiki tiddlers directory
$tw.plugins.loadPluginsFromFolder(path.resolve($tw.boot.wikiPath,"./tiddlers"));
$tw.plugins.loadPluginsFromFolder(path.resolve($tw.boot.wikiPath,"./tiddlers"),null,null,$tw.wiki);
// End of if(!$tw.isBrowser)
}