From aae56f20af35e7be6f3839a8c727e3f43174efe9 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sun, 8 Feb 2015 19:40:15 +0000 Subject: [PATCH] Display warning banner when plugins are modified Fixes #1455 @aelocson have I got the docs right for the new filter? --- core/language/en-GB/Misc.multids | 1 + core/modules/filters/haschanged.js | 36 +++++++++++++++++++ core/ui/PageTemplate/pluginreloadwarning.tid | 22 ++++++++++++ .../tw5.com/tiddlers/filters/haschanged.tid | 15 ++++++++ themes/tiddlywiki/vanilla/base.tid | 15 ++++++++ 5 files changed, 89 insertions(+) create mode 100644 core/modules/filters/haschanged.js create mode 100644 core/ui/PageTemplate/pluginreloadwarning.tid create mode 100644 editions/tw5.com/tiddlers/filters/haschanged.tid diff --git a/core/language/en-GB/Misc.multids b/core/language/en-GB/Misc.multids index 819d77ec4..449aa1230 100644 --- a/core/language/en-GB/Misc.multids +++ b/core/language/en-GB/Misc.multids @@ -14,6 +14,7 @@ Encryption/ConfirmClearPassword: Do you wish to clear the password? This will re Encryption/PromptSetPassword: Set a new password for this TiddlyWiki InvalidFieldName: Illegal characters in field name "<$text text=<>/>". Fields can only contain lowercase letters, digits and the characters underscore (`_`), hyphen (`-`) and period (`.`) MissingTiddler/Hint: Missing tiddler "<$text text=<>/>" - click {{$:/core/images/edit-button}} to create +PluginReloadWarning: Please save {{$:/core/ui/Buttons/save-wiki}} and reload {{$:/core/ui/Buttons/refresh}} to allow changes to plugins to take effect RecentChanges/DateFormat: DDth MMM YYYY SystemTiddler/Tooltip: This is a system tiddler TagManager/Colour/Heading: Colour diff --git a/core/modules/filters/haschanged.js b/core/modules/filters/haschanged.js new file mode 100644 index 000000000..4c63b7758 --- /dev/null +++ b/core/modules/filters/haschanged.js @@ -0,0 +1,36 @@ +/*\ +title: $:/core/modules/filters/haschanged.js +type: application/javascript +module-type: filteroperator + +Filter operator returns tiddlers from the list that have a non-zero changecount. + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +Export our filter function +*/ +exports.haschanged = function(source,operator,options) { + var results = []; + if(operator.prefix === "!") { + source(function(tiddler,title) { + if(options.wiki.getChangeCount(title) === 0) { + results.push(title); + } + }); + } else { + source(function(tiddler,title) { + if(options.wiki.getChangeCount(title) > 0) { + results.push(title); + } + }); + } + return results; +}; + +})(); diff --git a/core/ui/PageTemplate/pluginreloadwarning.tid b/core/ui/PageTemplate/pluginreloadwarning.tid new file mode 100644 index 000000000..f7b6309ad --- /dev/null +++ b/core/ui/PageTemplate/pluginreloadwarning.tid @@ -0,0 +1,22 @@ +title: $:/core/ui/PageTemplate/pluginreloadwarning +tags: $:/tags/PageTemplate + +\define lingo-base() $:/language/ + +<$list filter="[has[plugin-type]haschanged[]limit[1]]"> + +<$reveal type="nomatch" state="$:/temp/HidePluginWarning" text="yes"> + +
+ +<$set name="tv-config-toolbar-class" value=""> + +<> <$button set="$:/temp/HidePluginWarning" setTo="yes" class="tc-btn-invisible">{{$:/core/images/close-button}} + + + +
+ + + + diff --git a/editions/tw5.com/tiddlers/filters/haschanged.tid b/editions/tw5.com/tiddlers/filters/haschanged.tid new file mode 100644 index 000000000..25dfd515e --- /dev/null +++ b/editions/tw5.com/tiddlers/filters/haschanged.tid @@ -0,0 +1,15 @@ +created: 20150208191821000 +modified: 20150208191821000 +tags: [[Filter Operators]] [[Negatable Operators]] +title: haschanged Operator +type: text/vnd.tiddlywiki +caption: haschanged +op-purpose: returns input titles where the corresponding tiddlers have changed since startup +op-input: a [[selection of titles|Title Selection]] +op-parameter: none +op-output: those input tiddlers that have not changed since startup +op-neg-output: those input tiddlers that have changed since startup + +Each input title is processed in turn, and is returned if any of its fields have changed since startup (or, with negation, if it has not changed). + +<<.operator-examples "haschanged">> diff --git a/themes/tiddlywiki/vanilla/base.tid b/themes/tiddlywiki/vanilla/base.tid index 2e26e1148..b31d9a9aa 100644 --- a/themes/tiddlywiki/vanilla/base.tid +++ b/themes/tiddlywiki/vanilla/base.tid @@ -241,6 +241,21 @@ a.tc-tiddlylink-external:hover { content: "<>"; } +/* +** Plugin reload warning +*/ + +.tc-plugin-reload-warning { + z-index: 1000; + display: block; + position: fixed; + top: 0; + left: 0; + right: 0; + background: <>; + text-align: center; +} + /* ** Buttons */