From 22b836e4ac5982d20d9aa04d4d15c6c602e91d02 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Wed, 6 Jun 2012 13:21:20 +0100 Subject: [PATCH] Added 'isShadow' flag for system tiddlers Shadow tiddlers are omitted from lists by default --- core/boot.js | 56 ++++++++------------ core/modules/filters.js | 18 +++---- core/modules/startup.js | 2 +- core/modules/wiki.js | 18 +++++-- core/templates/tiddlywiki5.template.html.tid | 8 +-- 5 files changed, 48 insertions(+), 54 deletions(-) diff --git a/core/boot.js b/core/boot.js index 2f4d74022..832ad2c19 100644 --- a/core/boot.js +++ b/core/boot.js @@ -321,16 +321,19 @@ $tw.Wiki = function() { this.tiddlers = {}; }; -$tw.Wiki.prototype.addTiddler = function(tiddler) { +$tw.Wiki.prototype.addTiddler = function(tiddler,isShadow) { if(!(tiddler instanceof $tw.Tiddler)) { tiddler = new $tw.Tiddler(tiddler); } - this.tiddlers[tiddler.fields.title] = tiddler; + if(isShadow) { + tiddler.isShadow = true; + } + this.tiddlers[tiddler.fields.title] = tiddler; }; -$tw.Wiki.prototype.addTiddlers = function(tiddlers) { +$tw.Wiki.prototype.addTiddlers = function(tiddlers,isShadow) { for(var t=0; t=0; r--) {if(" + op + "this.getTiddler(subResults[r]).isShadow) {subResults.splice(r,1);}}" } else { throw "Unknown operand for 'is' filter operator"; } diff --git a/core/modules/startup.js b/core/modules/startup.js index 037dac2e5..5001c3d08 100644 --- a/core/modules/startup.js +++ b/core/modules/startup.js @@ -40,7 +40,7 @@ exports.startup = function() { $tw.version = $tw.utils.extractVersionInfo(); // Load up the shadow tiddlers in the root of the core directory (we couldn't do before because we didn't have the serializers installed) if(!$tw.browser) { - $tw.loadTiddlersFromFolder($tw.boot.bootPath,"$:/core",/^\.DS_Store$|.meta$|^modules$/); + $tw.loadTiddlersFromFolder($tw.boot.bootPath,"$:/core",/^\.DS_Store$|.meta$|^modules$/,true); } // Set up the wiki store $tw.wiki.initMacros(); diff --git a/core/modules/wiki.js b/core/modules/wiki.js index c707f97c2..08acae6e1 100644 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -103,11 +103,14 @@ exports.tiddlerExists = function(title) { return !!this.tiddlers[title]; }; -exports.addTiddler = function(tiddler) { +exports.addTiddler = function(tiddler,isShadow) { // Check if we're passed a fields hashmap instead of a tiddler if(!(tiddler instanceof $tw.Tiddler)) { tiddler = new $tw.Tiddler(tiddler); } + if(isShadow) { + tiddler.isShadow = true; + } var title = tiddler.fields.title; this.tiddlers[title] = tiddler; this.clearCache(title); @@ -136,7 +139,9 @@ exports.getTiddlers = function(sortField,excludeTag) { sortField = sortField || "title"; var tiddlers = [], t, titles = []; for(t in this.tiddlers) { - tiddlers.push(this.tiddlers[t]); + if(!this.tiddlers[t].isShadow) { + tiddlers.push(this.tiddlers[t]); + } } tiddlers.sort(function(a,b) { var aa = a.fields[sortField] || 0, @@ -206,7 +211,14 @@ exports.getOrphanTitles = function() { }; exports.getShadowTitles = function() { - return []; + var titles = []; + for(var title in this.tiddlers) { + if(this.tiddlers[title].isShadow) { + titles.push(title); + } + } + titles.sort(); + return titles; }; // Return the named cache object for a tiddler. If the cache doesn't exist then the initializer function is invoked to create it diff --git a/core/templates/tiddlywiki5.template.html.tid b/core/templates/tiddlywiki5.template.html.tid index b995d070c..6551e42f8 100644 --- a/core/templates/tiddlywiki5.template.html.tid +++ b/core/templates/tiddlywiki5.template.html.tid @@ -17,7 +17,7 @@ type: text/x-tiddlywiki-html <<include "$:/wiki/title" text/plain>>
-<> +<>
<> @@ -31,11 +31,11 @@ type: text/x-tiddlywiki-html