1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-07-01 09:33:03 +00:00

Add storyviews list filter and use it in view switcher

This commit is contained in:
Jermolene 2014-03-24 22:17:45 +00:00
parent 26fd460670
commit 20f6383528
3 changed files with 35 additions and 3 deletions

View File

@ -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;
};
})();

View File

@ -3,7 +3,7 @@ title: $:/snippets/viewswitcher
\define lingo-base() $:/language/ControlPanel/Appearance/StoryView/ \define lingo-base() $:/language/ControlPanel/Appearance/StoryView/
<<lingo Prompt>> {{$:/view}} <<lingo Prompt>> {{$:/view}}
<$linkcatcher to="$:/view"><$list filter="classic zoomin pop"><div><$reveal state="$:/view" type="match" text={{!!title}}>&bull;</$reveal><$reveal state="$:/view" type="nomatch" text={{!!title}}>&nbsp;</$reveal> <$link to={{!!title}}><$view field="title"/></$link> <$linkcatcher to="$:/view"><$list filter="[storyviews[]]"><div><$reveal state="$:/view" type="match" text={{!!title}}>&bull;</$reveal><$reveal state="$:/view" type="nomatch" text={{!!title}}>&nbsp;</$reveal> <$link to={{!!title}}><$view field="title"/></$link>
</div> </div>
</$list> </$list>
</$linkcatcher> </$linkcatcher>

View File

@ -1,6 +1,7 @@
title: FilterOperators
created: 20140303091312363 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. 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'' * ''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]] * ''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: The operands available with the `is` operator are: