From 42c67cfeb732fccb10b8ab574c84090dc2471352 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Fri, 14 Mar 2014 15:23:28 +0000 Subject: [PATCH] Add tiddler info "advanced" panel --- core/language/en-GB/TiddlerInfo.multids | 9 ++++ core/modules/filters/plugintiddlers.js | 47 +++++++++++++++++++++ core/modules/filters/shadowsource.js | 40 ++++++++++++++++++ core/ui/TiddlerInfo/Advanced.tid | 8 ++++ core/ui/TiddlerInfo/Advanced/PluginInfo.tid | 20 +++++++++ core/ui/TiddlerInfo/Advanced/ShadowInfo.tid | 35 +++++++++++++++ core/wiki/tags/TiddlerInfoAdvanced.tid | 2 + 7 files changed, 161 insertions(+) create mode 100644 core/modules/filters/plugintiddlers.js create mode 100644 core/modules/filters/shadowsource.js create mode 100644 core/ui/TiddlerInfo/Advanced.tid create mode 100644 core/ui/TiddlerInfo/Advanced/PluginInfo.tid create mode 100644 core/ui/TiddlerInfo/Advanced/ShadowInfo.tid create mode 100644 core/wiki/tags/TiddlerInfoAdvanced.tid diff --git a/core/language/en-GB/TiddlerInfo.multids b/core/language/en-GB/TiddlerInfo.multids index 741f900fe..341cd9ffc 100644 --- a/core/language/en-GB/TiddlerInfo.multids +++ b/core/language/en-GB/TiddlerInfo.multids @@ -1,5 +1,14 @@ title: $:/language/TiddlerInfo/ +Advanced/Caption: Advanced +Advanced/PluginInfo/Empty/Hint: none +Advanced/PluginInfo/Heading: Plugin Details +Advanced/PluginInfo/Hint: This plugin contains the following shadow tiddlers: +Advanced/ShadowInfo/Heading: Shadow Status +Advanced/ShadowInfo/NotShadow/Hint: The tiddler <$link to=<>><$text text=<>/> is not a shadow tiddler +Advanced/ShadowInfo/Shadow/Hint: The tiddler <$link to=<>><$text text=<>/> is a shadow tiddler +Advanced/ShadowInfo/Shadow/Source: It is defined in the plugin <$link to=<>><$text text=<>/> +Advanced/ShadowInfo/OverriddenShadow/Hint: It is overridden by an ordinary tiddler Fields/Caption: Fields List/Caption: List List/Empty: This tiddler does not have a list diff --git a/core/modules/filters/plugintiddlers.js b/core/modules/filters/plugintiddlers.js new file mode 100644 index 000000000..48f39ae22 --- /dev/null +++ b/core/modules/filters/plugintiddlers.js @@ -0,0 +1,47 @@ +/*\ +title: $:/core/modules/filters/plugintiddlers.js +type: application/javascript +module-type: filteroperator + +Filter operator for returning the titles of the shadow tiddlers within a plugin + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +Export our filter function +*/ +exports.plugintiddlers = function(source,operator,options) { + var results = [], + pushShadows; + switch(operator.operand) { + default: + pushShadows = function(title) { + var pluginInfo = options.wiki.pluginInfo[title]; + if(pluginInfo) { + $tw.utils.each(pluginInfo.tiddlers,function(fields,title) { + results.push(title); + }); + } + }; + break; + } + // Iterate through the source tiddlers + if($tw.utils.isArray(source)) { + $tw.utils.each(source,function(title) { + pushShadows(title); + }); + } else { + $tw.utils.each(source,function(element,title) { + pushShadows(title); + }); + } + results.sort(); + return results; +}; + +})(); diff --git a/core/modules/filters/shadowsource.js b/core/modules/filters/shadowsource.js new file mode 100644 index 000000000..e1d7d36d2 --- /dev/null +++ b/core/modules/filters/shadowsource.js @@ -0,0 +1,40 @@ +/*\ +title: $:/core/modules/filters/shadowsource.js +type: application/javascript +module-type: filteroperator + +Filter operator for returning the source plugins for shadow tiddlers + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +Export our filter function +*/ +exports.shadowsource = function(source,operator,options) { + var results = [], + pushShadowSource = function(title) { + var shadowInfo = options.wiki.shadowTiddlers[title]; + if(shadowInfo) { + $tw.utils.pushTop(results,shadowInfo.source); + } + }; + // Iterate through the source tiddlers + if($tw.utils.isArray(source)) { + $tw.utils.each(source,function(title) { + pushShadowSource(title); + }); + } else { + $tw.utils.each(source,function(element,title) { + pushShadowSource(title); + }); + } + results.sort(); + return results; +}; + +})(); diff --git a/core/ui/TiddlerInfo/Advanced.tid b/core/ui/TiddlerInfo/Advanced.tid new file mode 100644 index 000000000..50955086c --- /dev/null +++ b/core/ui/TiddlerInfo/Advanced.tid @@ -0,0 +1,8 @@ +title: $:/core/ui/TiddlerInfo/Advanced +tags: $:/tags/TiddlerInfo +caption: {{$:/language/TiddlerInfo/Advanced/Caption}} + +<$list filter="[is[shadow]!has[draft.of]tag[$:/tags/TiddlerInfo/Advanced]] [!is[shadow]!has[draft.of]tag[$:/tags/TiddlerInfo/Advanced]] +[tag[$:/tags/TiddlerInfo/Advanced]]" variable="listItem"> +<$transclude tiddler=<>/> + + diff --git a/core/ui/TiddlerInfo/Advanced/PluginInfo.tid b/core/ui/TiddlerInfo/Advanced/PluginInfo.tid new file mode 100644 index 000000000..1bc68066a --- /dev/null +++ b/core/ui/TiddlerInfo/Advanced/PluginInfo.tid @@ -0,0 +1,20 @@ +title: $:/core/ui/TiddlerInfo/Advanced/PluginInfo +tags: $:/tags/TiddlerInfo/Advanced + +\define lingo-base() $:/language/TiddlerInfo/Advanced/PluginInfo/ +<$list filter="[is[current]has[plugin-type]]"> + +! <> + +<> +
    +<$list filter="[is[current]plugintiddlers[]sort[title]]" emptyMessage=<>> +
  • +<$link to={{!!title}}> +<$view field="title"/> + +
  • + +
+ + diff --git a/core/ui/TiddlerInfo/Advanced/ShadowInfo.tid b/core/ui/TiddlerInfo/Advanced/ShadowInfo.tid new file mode 100644 index 000000000..f084769a7 --- /dev/null +++ b/core/ui/TiddlerInfo/Advanced/ShadowInfo.tid @@ -0,0 +1,35 @@ +title: $:/core/ui/TiddlerInfo/Advanced/ShadowInfo +tags: $:/tags/TiddlerInfo/Advanced + +\define lingo-base() $:/language/TiddlerInfo/Advanced/ShadowInfo/ +<$set name="infoTiddler" value=<>> + +! <> + +<$list filter="[is[current]!is[shadow]]"> + +<> + + + +<$list filter="[is[current]is[shadow]]"> + +<> + +<$list filter="[is[current]shadowsource[]]"> + +<$set name="pluginTiddler" value=<>> +<> + + + + +<$list filter="[is[current]is[shadow]is[tiddler]]"> + +<> + + + + + + diff --git a/core/wiki/tags/TiddlerInfoAdvanced.tid b/core/wiki/tags/TiddlerInfoAdvanced.tid new file mode 100644 index 000000000..3b400464e --- /dev/null +++ b/core/wiki/tags/TiddlerInfoAdvanced.tid @@ -0,0 +1,2 @@ +title: $:/tags/TiddlerInfo/Advanced +list: [[$:/core/ui/TiddlerInfo/Advanced/ShadowInfo]] [[$:/core/ui/TiddlerInfo/Advanced/PluginInfo]] \ No newline at end of file