diff --git a/core/modules/filters/indexes.js b/core/modules/filters/indexes.js new file mode 100644 index 000000000..362d16c73 --- /dev/null +++ b/core/modules/filters/indexes.js @@ -0,0 +1,43 @@ +/*\ +title: $:/core/modules/filters/indexes.js +type: application/javascript +module-type: filteroperator + +Filter operator for returning the indexes of a data tiddler + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +Export our filter function +*/ +exports.indexes = function(source,operator,options) { + var self = this, + results = []; + // Function to check an individual title + function checkTiddler(title) { + // Return the fields on the specified tiddler + var data = options.wiki.getTiddlerData(title,{}); + if(data) { + $tw.utils.pushTop(results,Object.keys(data)); + } + } + // 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); + }); + } + results.sort(); + return results; +}; + +})(); diff --git a/editions/tw5.com/tiddlers/concepts/TiddlerFilters.tid b/editions/tw5.com/tiddlers/concepts/TiddlerFilters.tid index d3cdd1346..cbfb54e18 100644 --- a/editions/tw5.com/tiddlers/concepts/TiddlerFilters.tid +++ b/editions/tw5.com/tiddlers/concepts/TiddlerFilters.tid @@ -1,5 +1,5 @@ created: 20130827080000000 -modified: 20140210141253282 +modified: 20140220091253282 tags: concepts title: TiddlerFilters type: text/vnd.tiddlywiki @@ -67,8 +67,8 @@ A filter string consists of one or more runs of filter operators that each look * ''bf'': another synonym for ''rest'' * ''butlast'': selects all but the last tiddler of the list (or all but the last n if the operand is n) * ''bl'': another synonym for ''butlast'' -* ''nth'': selects the n-th tiddler of the list. Defaults to n = 1. - +* ''nth'': selects the n-th tiddler of the list. Defaults to n = 1 +* ''indexes'': selects the names of the indexes within a [[DataTiddler|DataTiddlers]] An operator can be negated with by preceding it with `!`, for example `[!tag[Tommy]]` selects the tiddlers that are not tagged with `Tommy`.