diff --git a/core/boot.js b/core/boot.js index 97b292945..c1648fa71 100644 --- a/core/boot.js +++ b/core/boot.js @@ -86,7 +86,8 @@ $tw.modules.types = $tw.modules.types || {}; // hashmap by module type of array $tw.config = $tw.config || {}; // Constants -$tw.config.bootModuleSubDir = $tw.config.bootModuleSubDir || "./modules"; +$tw.config.pluginsPath = "../plugins/"; +$tw.config.wikiInfo = $tw.config.wikiInfo || "./tiddlywiki.info"; $tw.config.wikiPluginsSubDir = $tw.config.wikiPluginsSubDir || "./plugins"; $tw.config.wikiShadowsSubDir = $tw.config.wikiShadowsSubDir || "./wiki"; $tw.config.wikiTiddlersSubDir = $tw.config.wikiTiddlersSubDir || "./tiddlers"; @@ -724,11 +725,11 @@ $tw.loadTiddlersFromFile = function(filepath,fields) { var ext = path.extname(filepath), extensionInfo = $tw.config.fileExtensionInfo[ext], typeInfo = extensionInfo ? $tw.config.contentTypeInfo[extensionInfo.type] : null, - data = fs.readFileSync(filepath).toString(typeInfo ? typeInfo.encoding : "utf8"), + data = fs.readFileSync(filepath,typeInfo ? typeInfo.encoding : "utf8"), tiddlers = $tw.wiki.deserializeTiddlers(ext,data,fields), metafile = filepath + ".meta"; if(ext !== ".json" && tiddlers.length === 1 && fs.existsSync(metafile)) { - var metadata = fs.readFileSync(metafile).toString("utf8"); + var metadata = fs.readFileSync(metafile,"utf8"); if(metadata) { tiddlers = [$tw.utils.parseFields(metadata,tiddlers[0])]; } @@ -750,11 +751,11 @@ $tw.loadTiddlersFromPath = function(filepath,excludeRegExp) { // Look for a tiddlywiki.files file if(files.indexOf("tiddlywiki.files") !== -1) { // If so, process the files it describes - filesInfo = JSON.parse(fs.readFileSync(filepath + "/tiddlywiki.files").toString("utf8")); + filesInfo = JSON.parse(fs.readFileSync(filepath + "/tiddlywiki.files","utf8")); for(p=0; p titlePrefix.length) { - bundleInfo.tiddlers[bundleTiddlers[t].title.substr(titlePrefix.length)] = bundleTiddlers[t]; - } else { - throw "The bundle '" + bundleInfo.title + "' cannot contain a tiddler titled '" + bundleTiddlers[t].title + "'"; + excludeRegExp = excludeRegExp || /^\.DS_Store$|.meta$/; + var stat, files, bundleInfo = {tiddlers: []}, bundleTiddlers = [], f, file, titlePrefix, t; + if(fs.existsSync(filepath)) { + stat = fs.statSync(filepath); + if(stat.isDirectory()) { + files = fs.readdirSync(filepath); + // Read the plugin information + bundleInfo = JSON.parse(fs.readFileSync(filepath + "/plugin.bundle","utf8")); + // Read the bundle files + for(f=0; f titlePrefix.length) { + bundleInfo.tiddlers[bundleTiddlers[t].title.substr(titlePrefix.length)] = bundleTiddlers[t]; + } else { + console.log("Error extracting plugin bundle: The bundle '" + bundleInfo.title + "' cannot contain a tiddler titled '" + bundleTiddlers[t].title + "'"); + } + } } } // Save the bundle tiddler @@ -883,6 +891,15 @@ if($tw.browser) { for(t=0; t