From 20f63835280e03d10fbd38c09d31cf88d002fb1c Mon Sep 17 00:00:00 2001 From: Jermolene Date: Mon, 24 Mar 2014 22:17:45 +0000 Subject: [PATCH] Add storyviews list filter and use it in view switcher --- core/modules/widgets/storyviews.js | 29 +++++++++++++++++++ core/wiki/viewswitcher.tid | 2 +- .../tiddlers/concepts/FilterOperators.tid | 7 +++-- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 core/modules/widgets/storyviews.js diff --git a/core/modules/widgets/storyviews.js b/core/modules/widgets/storyviews.js new file mode 100644 index 000000000..41fffed92 --- /dev/null +++ b/core/modules/widgets/storyviews.js @@ -0,0 +1,29 @@ +/*\ +title: $:/core/modules/filters/storyviews.js +type: application/javascript +module-type: filteroperator + +Filter operator for returning the names of the story views in this wiki + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +Export our filter function +*/ +exports.storyviews = function(source,operator,options) { + var results = [], + storyviews = {}; + $tw.modules.applyMethods("storyview",storyviews); + $tw.utils.each(storyviews,function(info,name) { + results.push(name); + }); + results.sort(); + return results; +}; + +})(); diff --git a/core/wiki/viewswitcher.tid b/core/wiki/viewswitcher.tid index 7e8799fe3..d6ea5ed9b 100644 --- a/core/wiki/viewswitcher.tid +++ b/core/wiki/viewswitcher.tid @@ -3,7 +3,7 @@ title: $:/snippets/viewswitcher \define lingo-base() $:/language/ControlPanel/Appearance/StoryView/ <> {{$:/view}} -<$linkcatcher to="$:/view"><$list filter="classic zoomin pop">
<$reveal state="$:/view" type="match" text={{!!title}}>•<$reveal state="$:/view" type="nomatch" text={{!!title}}>  <$link to={{!!title}}><$view field="title"/> +<$linkcatcher to="$:/view"><$list filter="[storyviews[]]">
<$reveal state="$:/view" type="match" text={{!!title}}>•<$reveal state="$:/view" type="nomatch" text={{!!title}}>  <$link to={{!!title}}><$view field="title"/>
diff --git a/editions/tw5.com/tiddlers/concepts/FilterOperators.tid b/editions/tw5.com/tiddlers/concepts/FilterOperators.tid index 1b3a3f35f..54b9c7b4a 100644 --- a/editions/tw5.com/tiddlers/concepts/FilterOperators.tid +++ b/editions/tw5.com/tiddlers/concepts/FilterOperators.tid @@ -1,6 +1,7 @@ -title: FilterOperators created: 20140303091312363 -modified: 20140303091312363 +modified: 20140324221721972 +title: FilterOperators +type: text/vnd.tiddlywiki The available filter operators are listed here. See TiddlerFilters for an introduction to tiddler filters and how they are used. @@ -39,6 +40,8 @@ The available filter operators are listed here. See TiddlerFilters for an introd * ''bl'': another synonym for ''butlast'' * ''nth'': selects the n-th tiddler of the list. Defaults to n = 1 * ''indexes'': selects the names of the indexes within a [[DataTiddler|DataTiddlers]] +* ''moduletypes'': selects the list of types of all the loaded modules +* ''storyviews'': selects the list of names of loaded storyviews The operands available with the `is` operator are: