From 47cdf5513391742c3410bb80b36107ab17b0476d Mon Sep 17 00:00:00 2001 From: Jermolene Date: Tue, 3 Apr 2018 17:48:01 +0100 Subject: [PATCH] Add new subtiddlerfields filter operator --- core/modules/filters/subtiddlerfields.js | 31 +++++++++++++++++++ .../subtiddlerfields Operator (Examples).tid | 8 +++++ .../filters/subtiddlerfields Operator.tid | 13 ++++++++ 3 files changed, 52 insertions(+) create mode 100644 core/modules/filters/subtiddlerfields.js create mode 100644 editions/tw5.com/tiddlers/filters/examples/subtiddlerfields Operator (Examples).tid create mode 100644 editions/tw5.com/tiddlers/filters/subtiddlerfields Operator.tid diff --git a/core/modules/filters/subtiddlerfields.js b/core/modules/filters/subtiddlerfields.js new file mode 100644 index 000000000..681dd243d --- /dev/null +++ b/core/modules/filters/subtiddlerfields.js @@ -0,0 +1,31 @@ +/*\ +title: $:/core/modules/filters/subtiddlerfields.js +type: application/javascript +module-type: filteroperator + +Filter operator for returning the names of the fields on the selected subtiddlers of the plugin named in the operand + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +Export our filter function +*/ +exports.subtiddlerfields = function(source,operator,options) { + var results = []; + source(function(tiddler,title) { + var subtiddler = options.wiki.getSubTiddler(operator.operand,title); + if(subtiddler) { + for(var fieldName in subtiddler.fields) { + $tw.utils.pushTop(results,fieldName); + } + } + }); + return results; +}; + +})(); diff --git a/editions/tw5.com/tiddlers/filters/examples/subtiddlerfields Operator (Examples).tid b/editions/tw5.com/tiddlers/filters/examples/subtiddlerfields Operator (Examples).tid new file mode 100644 index 000000000..5c7e4697c --- /dev/null +++ b/editions/tw5.com/tiddlers/filters/examples/subtiddlerfields Operator (Examples).tid @@ -0,0 +1,8 @@ +created: 20180403164143915 +modified: 20180403164257147 +tags: [[plugintiddlers Operator]] [[Operator Examples]] +title: subtiddlerfields Operator (Examples) +type: text/vnd.tiddlywiki + +<<.operator-example 1 "[[$:/core/copyright.txt]subtiddlerfields[$:/core]]">> + diff --git a/editions/tw5.com/tiddlers/filters/subtiddlerfields Operator.tid b/editions/tw5.com/tiddlers/filters/subtiddlerfields Operator.tid new file mode 100644 index 000000000..786bd887b --- /dev/null +++ b/editions/tw5.com/tiddlers/filters/subtiddlerfields Operator.tid @@ -0,0 +1,13 @@ +caption: subtiddlerfields +created: 20180403164138703 +modified: 20180403164644231 +op-input: a [[selection|Title Selection]] of tiddler titles +op-output: all field names present in the selected tiddlers within the plugin named <<.place P>> +op-parameter: the title of a plugin +op-parameter-name: P +op-purpose: select all fields present in the selected tiddlers within a plugin +tags: [[Filter Operators]] [[Special Operators]] +title: subtiddlerfields Operator +type: text/vnd.tiddlywiki + +<<.operator-examples "subtiddlerfields">>