From 802fe9beaef9de5e5062eb8ddb0c396844cde0ce Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sun, 24 Nov 2013 20:38:58 +0000 Subject: [PATCH] Add [is[tiddler]] filter operator For selecting all non-shadow tiddlers, whether or not they are system tiddlers --- core/modules/filters/is/tiddler.js | 43 +++++++++++++++++++ .../tiddlers/concepts/TiddlerFilters.tid | 3 +- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 core/modules/filters/is/tiddler.js diff --git a/core/modules/filters/is/tiddler.js b/core/modules/filters/is/tiddler.js new file mode 100644 index 000000000..d40b53d90 --- /dev/null +++ b/core/modules/filters/is/tiddler.js @@ -0,0 +1,43 @@ +/*\ +title: $:/core/modules/filters/is/tiddler.js +type: application/javascript +module-type: isfilteroperator + +Filter function for [is[tiddler]] + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +Export our filter function +*/ +exports.tiddler = function(source,prefix,options) { + var results = []; + // Function to check a tiddler + function checkTiddler(title) { + var match = options.wiki.tiddlerExists(title); + if(prefix === "!") { + match = !match; + } + if(match) { + results.push(title); + } + }; + // Iterate through the source tiddlers + if($tw.utils.isArray(source)) { + $tw.utils.each(source,function(title) { + checkTiddler(title); + }); + } else { + $tw.utils.each(source,function(element,title) { + checkTiddler(title); + }); + } + return results; +}; + +})(); diff --git a/editions/tw5.com/tiddlers/concepts/TiddlerFilters.tid b/editions/tw5.com/tiddlers/concepts/TiddlerFilters.tid index 2976427f4..7e1ad9c00 100644 --- a/editions/tw5.com/tiddlers/concepts/TiddlerFilters.tid +++ b/editions/tw5.com/tiddlers/concepts/TiddlerFilters.tid @@ -1,6 +1,6 @@ created: 201308270800 creator: JeremyRuston -modified: 201309141606 +modified: 201311242006 modifier: JeremyRuston tags: concepts title: TiddlerFilters @@ -63,6 +63,7 @@ The operator defaults to `title` if omitted, so `[[HelloThere]]` is equivalent t The operands available with the `is` operator are: +* ''tiddler'': selects all tiddlers excluding shadows, whether or not they are SystemTiddlers * ''system'': selects all SystemTiddlers * ''shadow'': selects all ShadowTiddlers * ''current'': selects the current ContextTiddler