diff --git a/core/modules/filters/is/tag.js b/core/modules/filters/is/tag.js new file mode 100644 index 000000000..d614029c4 --- /dev/null +++ b/core/modules/filters/is/tag.js @@ -0,0 +1,37 @@ +/*\ +title: $:/core/modules/filters/is/tag.js +type: application/javascript +module-type: isfilteroperator + +Filter function for [is[tag]] + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +Export our filter function +*/ +exports.tag = function(source,prefix,options) { + var results = [], + tagMap = options.wiki.getTagMap(); + if(prefix === "!") { + source(function(tiddler,title) { + if(!$tw.utils.hop(tagMap,title)) { + results.push(title); + } + }); + } else { + source(function(tiddler,title) { + if($tw.utils.hop(tagMap,title)) { + results.push(title); + } + }); + } + return results; +}; + +})(); diff --git a/editions/tw5.com/tiddlers/filters/FilterOperator is.tid b/editions/tw5.com/tiddlers/filters/FilterOperator is.tid index 65d48676b..74865d495 100644 --- a/editions/tw5.com/tiddlers/filters/FilterOperator is.tid +++ b/editions/tw5.com/tiddlers/filters/FilterOperator is.tid @@ -1,5 +1,5 @@ created: 20140410103123179 -modified: 20140410103123179 +modified: 20140418103123179 tags: filters commonfilters title: FilterOperator: is type: text/vnd.tiddlywiki @@ -13,6 +13,7 @@ The ''is'' filter operator selects tiddlers from the current list according to t * `[is[shadow]]` - tiddlers that are ShadowTiddlers * `[is[system]]` - tiddlers that are SystemTiddlers * `[is[tiddler]]` - tiddlers that are not MissingTiddlers +* `[is[tag]]` - tiddlers that are being used as tags For example: @@ -20,6 +21,8 @@ For example: |`[tag[task]is[shadow]]` |Returns ShadowTiddlers tagged `task` | |`[tag[task]!is[system]]` |Returns non-SystemTiddlers tagged `task` | |`[is[shadow]]` |Returns ShadowTiddlers that have been overridden by a 'real' tiddler | +|`[!is[shadow]]` |Returns ordinary tiddlers that are not shadow tiddlers | +|`[!is[tag]]` |Returns all tiddlers that are not being used as tags | |`[is[missing]]` |Returns an empty list (see note below) | Note that the ''is'' filter operator strictly filters the current list by choosing whether or not to include each one in the output. It never adds tiddlers to the results that are not already listed. This means that when used at the start of a run of filter operators the ''is'' operator will be choosing from the currently existing tiddlers, and so will never return missing tiddlers, or shadow tiddlers that haven't been overridden.