From 0ec2224757dd07f009246ec9ea97cd859d077e72 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 18 Dec 2013 21:11:00 +0000 Subject: [PATCH] Fallback to a default tiddlywiki.info file if it does not exist We fallback to settings suitable for the server version, to help people get up and running quickly. --- boot/boot.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/boot/boot.js b/boot/boot.js index ebc25b603..a5c96cf07 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -1159,7 +1159,6 @@ metadata files. */ $tw.boot.excludeRegExp = /^\.DS_Store$|^.*\.meta$|^\..*\.swp$|^\._.*$|^\.git$|^\.hg$|^\.lock-wscript$|^\.svn$|^\.wafpickle-.*$|^CVS$|^npm-debug\.log$/; - /* Load all the tiddlers recursively from a directory, including honouring `tiddlywiki.files` files for drawing in external files. Returns an array of {filepath:,type:,tiddlers: [{..fields...}],hasMetaFile:}. Note that no file information is returned for externally loaded tiddlers, just the `tiddlers` property. */ @@ -1255,6 +1254,20 @@ $tw.loadPluginFolder = function(filepath,excludeRegExp) { } }; +/* +Fallback tiddlywiki.info content +*/ +$tw.boot.defaultWikiInfo = { + "plugins": [ + "tiddlywiki/tiddlyweb", + "tiddlywiki/filesystem" + ], + "themes": [ + "tiddlywiki/vanilla", + "tiddlywiki/snowwhite" + ] +}; + /* path: path of wiki directory parentPaths: array of parent paths that we mustn't recurse into @@ -1262,13 +1275,14 @@ parentPaths: array of parent paths that we mustn't recurse into $tw.loadWikiTiddlers = function(wikiPath,parentPaths) { parentPaths = parentPaths || []; var wikiInfoPath = path.resolve(wikiPath,$tw.config.wikiInfo), - wikiInfo = {}, + wikiInfo, pluginFields; // Bail if we don't have a wiki info file - if(!fs.existsSync(wikiInfoPath)) { - $tw.utils.error("Missing tiddlywiki.info file at " + wikiPath); + if(fs.existsSync(wikiInfoPath)) { + wikiInfo = JSON.parse(fs.readFileSync(wikiInfoPath,"utf8")); + } else { + wikiInfo = $tw.boot.defaultWikiInfo; } - wikiInfo = JSON.parse(fs.readFileSync(wikiInfoPath,"utf8")); // Load any parent wikis if(wikiInfo.includeWikis) { parentPaths = parentPaths.slice(0);