From e2ea8ff4368d781ac80af114f9a49131a6bc4dcc Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Wed, 6 Jun 2012 12:07:33 +0100 Subject: [PATCH] Refactored shadow tiddlers to not be in a separate store Shortly there will be a flag to mark them --- core/boot.js | 39 ++++++++------------ core/modules/commands/dump.js | 2 +- core/modules/macros/include.js | 4 +- core/modules/wiki.js | 8 +--- core/templates/static.template.html.tid | 8 ++-- core/templates/tiddlywiki5.template.html.tid | 18 ++++----- 6 files changed, 33 insertions(+), 46 deletions(-) diff --git a/core/boot.js b/core/boot.js index baa189ca7..18c1c452e 100644 --- a/core/boot.js +++ b/core/boot.js @@ -208,8 +208,8 @@ $tw.plugins.registerPlugin = function(name,moduleType,moduleExports) { Register all plugin module tiddlers */ $tw.plugins.registerPluginModules = function() { - for(var title in $tw.wiki.shadows.tiddlers) { - var tiddler = $tw.wiki.shadows.getTiddler(title); + for(var title in $tw.wiki.tiddlers) { + var tiddler = $tw.wiki.getTiddler(title); if(tiddler.fields.type === "application/javascript" && tiddler.fields["module-type"] !== undefined) { $tw.plugins.registerPlugin(title,tiddler.fields["module-type"],$tw.modules.execute(title)); } @@ -319,12 +319,9 @@ $tw.Tiddler.fieldPlugins = $tw.plugins.getPluginsByTypeAsHashmap("tiddlerfield") /////////////////////////// Barebones wiki store /* -Construct a wiki store object. Options are: - shadows: optional value to use as the wiki store for shadow tiddlers +Construct a wiki store object */ -$tw.Wiki = function(options) { - options = options || {}; - this.shadows = options.shadows !== undefined ? options.shadows : new $tw.Wiki({shadows: null}); +$tw.Wiki = function() { this.tiddlers = {}; }; @@ -345,8 +342,6 @@ $tw.Wiki.prototype.getTiddler = function(title) { var t = this.tiddlers[title]; if(t instanceof $tw.Tiddler) { return t; - } else if(this.shadows) { - return this.shadows.getTiddler(title); } else { return null; } @@ -511,17 +506,17 @@ $tw.plugins.registerPlugin($tw.config.root + "/kernel/tiddlerdeserializer/dom"," $tw.plugins.applyMethods("tiddlerdeserializer",$tw.Wiki.tiddlerDeserializerPlugins); // Load the JavaScript system tiddlers from the DOM -$tw.wiki.shadows.addTiddlers( +$tw.wiki.addTiddlers( $tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("pluginModules")) ); -$tw.wiki.shadows.addTiddlers( +$tw.wiki.addTiddlers( $tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("bootKernelPrefix")) ); -$tw.wiki.shadows.addTiddlers( +$tw.wiki.addTiddlers( $tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("bootKernel")) ); // Load the stylesheet tiddlers from the DOM -$tw.wiki.shadows.addTiddlers( +$tw.wiki.addTiddlers( $tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("styleArea")) ); // Load the main store tiddlers from the DOM @@ -529,7 +524,7 @@ $tw.wiki.addTiddlers( $tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("storeArea")) ); // Load the shadow tiddlers from the DOM -$tw.wiki.shadows.addTiddlers( +$tw.wiki.addTiddlers( $tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("shadowArea")) ); @@ -551,8 +546,7 @@ $tw.boot.wikiPath = process.cwd(); /* Load the tiddlers contained in a particular file (and optionally the accompanying .meta file) */ -$tw.loadTiddlersFromFile = function(file,fields,wiki) { - wiki = wiki || $tw.wiki; +$tw.loadTiddlersFromFile = function(file,fields) { var ext = path.extname(file), extensionInfo = $tw.config.fileExtensions[ext], data = fs.readFileSync(file).toString(extensionInfo ? extensionInfo.encoding : "utf8"), @@ -564,16 +558,15 @@ $tw.loadTiddlersFromFile = function(file,fields,wiki) { tiddlers = [$tw.utils.parseFields(metadata,tiddlers[0])]; } } - wiki.addTiddlers(tiddlers); + $tw.wiki.addTiddlers(tiddlers); }; /* Load all the plugins from the plugins directory */ -$tw.loadTiddlersFromFolder = function(filepath,basetitle,excludeRegExp,wiki) { +$tw.loadTiddlersFromFolder = function(filepath,basetitle,excludeRegExp) { 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()) { @@ -583,19 +576,19 @@ $tw.loadTiddlersFromFolder = function(filepath,basetitle,excludeRegExp,wiki) { // If so, process the files it describes var pluginInfo = JSON.parse(fs.readFileSync(filepath + "/tiddlywiki.plugin").toString("utf8")); for(var p=0; p ->" /> +>" /> > +<> " /> <<tiddler target:$:/shadows/title>>
-<> +<>
-<> +<> diff --git a/core/templates/tiddlywiki5.template.html.tid b/core/templates/tiddlywiki5.template.html.tid index 031327aea..b995d070c 100644 --- a/core/templates/tiddlywiki5.template.html.tid +++ b/core/templates/tiddlywiki5.template.html.tid @@ -6,32 +6,32 @@ type: text/x-tiddlywiki-html ->" /> +>" /> > +<> " /> <<include "$:/wiki/title" text/plain>>
-<> +<>
-<> +<>