diff --git a/core/boot.js b/core/boot.js index eb5f4fabc..8ad54f927 100644 --- a/core/boot.js +++ b/core/boot.js @@ -409,19 +409,16 @@ $tw.Wiki = function() { this.tiddlers = {}; }; -$tw.Wiki.prototype.addTiddler = function(tiddler,isShadow) { +$tw.Wiki.prototype.addTiddler = function(tiddler) { if(!(tiddler instanceof $tw.Tiddler)) { tiddler = new $tw.Tiddler(tiddler); } - if(isShadow) { - tiddler.isShadow = true; - } this.tiddlers[tiddler.fields.title] = tiddler; }; -$tw.Wiki.prototype.addTiddlers = function(tiddlers,isShadow) { +$tw.Wiki.prototype.addTiddlers = function(tiddlers) { for(var t=0; t=0; r--) {if(" + op + "this.getTiddler(subResults[r]).isShadow) {subResults.splice(r,1);}}"; + return "for(r=subResults.length-1; r>=0; r--) {if(" + op + "this.getTiddler(subResults[r]).isShadow()) {subResults.splice(r,1);}}"; default: throw "Unknown operand for 'is' filter operator"; } diff --git a/core/modules/tiddler.js b/core/modules/tiddler.js index 00b27c2e8..31487f2a3 100644 --- a/core/modules/tiddler.js +++ b/core/modules/tiddler.js @@ -20,6 +20,17 @@ exports.hasField = function(field) { return $tw.utils.hop(this.fields,field); }; +exports.isShadow = function() { + if(!$tw.utils.hop(this,"shadowFlag")) { + this.shadowFlag = this.fields.title.indexOf("$:/") === 0; + } + return this.shadowFlag; +}; + +exports.isTemporary = function() { + return this.fields.title.indexOf("$:/temp/") === 0; +}; + exports.getFieldString = function(field) { var value = this.fields[field]; // Check for a missing field diff --git a/core/modules/wiki.js b/core/modules/wiki.js index 05cfc9b91..fa4e34b59 100644 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -43,13 +43,13 @@ exports.getTextReference = function(textRef,defaultText,currTiddlerTitle) { } }; -exports.setTextReference = function(textRef,value,currTiddlerTitle,isShadow) { +exports.setTextReference = function(textRef,value,currTiddlerTitle) { var tr = this.parseTextReference(textRef), title,tiddler,fields; // Check if it is a reference to a tiddler if(tr.title && !tr.field) { tiddler = this.getTiddler(tr.title); - this.addTiddler(new $tw.Tiddler(tiddler,{title: tr.title,text: value}),isShadow); + this.addTiddler(new $tw.Tiddler(tiddler,{title: tr.title,text: value})); // Else check for a field reference } else if(tr.field) { title = tr.title || currTiddlerTitle; @@ -179,7 +179,7 @@ exports.tiddlerExists = function(title) { return !!this.tiddlers[title]; }; -exports.addTiddler = function(tiddler,isShadow) { +exports.addTiddler = function(tiddler) { // Check if we're passed a fields hashmap instead of a tiddler if(!(tiddler instanceof $tw.Tiddler)) { tiddler = new $tw.Tiddler(tiddler); @@ -187,10 +187,6 @@ exports.addTiddler = function(tiddler,isShadow) { // Get the title, and the current tiddler with that title var title = tiddler.fields.title, prevTiddler = this.tiddlers[title]; - // Make it be a shadow if indicated or if it is already a shadow - if(isShadow || (prevTiddler && prevTiddler.isShadow)) { - tiddler.isShadow = true; - } // Save the tiddler this.tiddlers[title] = tiddler; this.clearCache(title); @@ -216,7 +212,7 @@ exports.getTiddlers = function(sortField,excludeTag) { sortField = sortField || "title"; var tiddlers = [], t, titles = []; for(t in this.tiddlers) { - if($tw.utils.hop(this.tiddlers,t) && !this.tiddlers[t].isShadow) { + if($tw.utils.hop(this.tiddlers,t) && !this.tiddlers[t].isShadow()) { tiddlers.push(this.tiddlers[t]); } } @@ -301,7 +297,7 @@ exports.getOrphanTitles = function() { exports.getShadowTitles = function() { var titles = []; for(var title in this.tiddlers) { - if(this.tiddlers[title].isShadow) { + if(this.tiddlers[title].isShadow()) { titles.push(title); } }