From 32a7ee2683ace619599f0ab73028307ca33f4e4c Mon Sep 17 00:00:00 2001 From: Jermolene Date: Fri, 15 Aug 2014 21:10:40 +0100 Subject: [PATCH] Make it possible to disable plugins --- boot/boot.js | 13 +++--- core/language/en-GB/ControlPanel.multids | 5 +++ core/ui/ControlPanel/Plugins.tid | 45 ++++++++++++++----- .../tiddlers/mechanisms/PluginMechanism.tid | 12 ++++- themes/tiddlywiki/vanilla/base.tid | 12 ++++- 5 files changed, 70 insertions(+), 17 deletions(-) diff --git a/boot/boot.js b/boot/boot.js index 5cfc5409b..d417f3ae1 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -967,19 +967,22 @@ $tw.Wiki = function(options) { this.registerPluginTiddlers = function(pluginType,titles) { var self = this, registeredTitles = [], - checkTiddler = function(tiddler) { + checkTiddler = function(tiddler,title) { if(tiddler && tiddler.fields.type === "application/json" && tiddler.fields["plugin-type"] === pluginType) { - pluginTiddlers.push(tiddler); - registeredTitles.push(tiddler.fields.title); + var disablingTiddler = self.getTiddler("$:/config/Plugins/Disabled/" + title); + if(title === "$:/core" || !disablingTiddler || (disablingTiddler.fields.text || "").trim() !== "yes") { + pluginTiddlers.push(tiddler); + registeredTitles.push(tiddler.fields.title); + } } }; if(titles) { $tw.utils.each(titles,function(title) { - checkTiddler(self.getTiddler(title)); + checkTiddler(self.getTiddler(title),title); }); } else { this.each(function(tiddler,title) { - checkTiddler(tiddler); + checkTiddler(tiddler,title); }); } return registeredTitles; diff --git a/core/language/en-GB/ControlPanel.multids b/core/language/en-GB/ControlPanel.multids index 911b2633f..e35f38f1b 100644 --- a/core/language/en-GB/ControlPanel.multids +++ b/core/language/en-GB/ControlPanel.multids @@ -64,7 +64,12 @@ Basics/Title/Prompt: Title of this ~TiddlyWiki: Basics/Username/Prompt: Username for signing edits: Basics/Version/Prompt: ~TiddlyWiki version: Plugins/Caption: Plugins +Plugins/Disable/Caption: disable +Plugins/Disable/Hint: Disable this plugin when reloading page +Plugins/Disabled/Status: (disabled) Plugins/Empty/Hint: None +Plugins/Enable/Caption: enable +Plugins/Enable/Hint: Enable this plugin when reloading page Plugins/Language/Prompt: Languages Plugins/Plugin/Prompt: Plugins Plugins/Theme/Prompt: Themes diff --git a/core/ui/ControlPanel/Plugins.tid b/core/ui/ControlPanel/Plugins.tid index dfb8ad6f4..a476a9290 100644 --- a/core/ui/ControlPanel/Plugins.tid +++ b/core/ui/ControlPanel/Plugins.tid @@ -12,11 +12,10 @@ $(popup-state)$-$(pluginInfoType)$ \define plugin-icon-title() $(currentTiddler)$/icon \end -\define plugin-table(type) -<$set name="qualified-state" value=<>> -<$list filter="[!has[draft.of]plugin-type[$type$]sort[description]]" emptyMessage=<>> -<$set name="popup-state" value=<>> -<$link to={{!!title}} class="tw-plugin-info"> +\define plugin-disable-title() +$:/config/Plugins/Disabled/$(currentTiddler)$ +\end +\define plugin-table-body(type,disabledMessage)
<$reveal type="nomatch" state=<> text="yes"> <$button class="btn-invisible btn-dropdown" set=<> setTo="yes"> @@ -36,7 +35,7 @@ $(currentTiddler)$/icon
-''<$view field="description"><$view field="title"/>'' +''<$view field="description"><$view field="title"/>'' $disabledMessage$
<$view field="title"/> @@ -45,18 +44,44 @@ $(currentTiddler)$/icon <$view field="version"/>
+\end +\define plugin-table(type) +<$set name="qualified-state" value=<>> +<$list filter="[!has[draft.of]plugin-type[$type$]sort[description]]" emptyMessage=<>> +<$set name="popup-state" value=<>> +<$reveal type="nomatch" state=<> text="yes"> +<$link to={{!!title}} class="tw-plugin-info"> +<> + +<$reveal type="match" state=<> text="yes"> +<$link to={{!!title}} class="tw-plugin-info tw-plugin-info-disabled"> +<">> + + <$reveal type="match" text="yes" state=<>> -<$reveal type="nomatch" text="" state="!!list">
-<$macrocall $name="tabs" state=<> tabsList={{!!list}} default="readme" template="$:/core/ui/PluginInfo"/> +<$list filter="[all[current]] -[[$:/core]]"> +
+<$reveal type="nomatch" state=<> text="yes"> +<$button set=<> setTo="yes" title={{$:/language/ControlPanel/Plugins/Disable/Hint}} aria-label={{$:/language/ControlPanel/Plugins/Disable/Caption}}> +<> + + +<$reveal type="match" state=<> text="yes"> +<$button set=<> setTo="no" title={{$:/language/ControlPanel/Plugins/Enable/Hint}} aria-label={{$:/language/ControlPanel/Plugins/Enable/Caption}}> +<> + +
+ +<$reveal type="nomatch" text="" state="!!list"> +<$macrocall $name="tabs" state=<> tabsList={{!!list}} default="readme" template="$:/core/ui/PluginInfo"/> <$reveal type="match" text="" state="!!list"> -
No information provided -
+
diff --git a/editions/tw5.com/tiddlers/mechanisms/PluginMechanism.tid b/editions/tw5.com/tiddlers/mechanisms/PluginMechanism.tid index c329f2adf..d271885e8 100644 --- a/editions/tw5.com/tiddlers/mechanisms/PluginMechanism.tid +++ b/editions/tw5.com/tiddlers/mechanisms/PluginMechanism.tid @@ -1,5 +1,5 @@ created: 20130826122000000 -modified: 20140807094840608 +modified: 20140815094840608 tags: mechanism title: PluginMechanism type: text/vnd.tiddlywiki @@ -87,6 +87,16 @@ The wiki object keeps track of all of the currently loaded plugins. If a request In the browser, any constituent tiddlers that are JavaScript modules (ie shadow tiddlers of content type `application/javascript` and possessing the field `module-type`) are executed during startup processing. +!! Disabling Plugins + +Plugins can be disabled by creating a tiddler titled `$:/config/Plugins/Disabled/` concatenated with the plugin title, and setting its text to `yes`. + +For example, to disable the plugin `$:/plugins/tiddlywiki/highlight`, the title would be: + +``` +$:/config/Plugins/Disabled/$:/plugins/tiddlywiki/highlight +``` + ! Information Tiddlers for Plugins Plugin authors are encouraged to provide special information and documentation tiddlers that TiddlyWiki can include as plugin information tabs in the [[control panel|$:/ControlPanel]]. diff --git a/themes/tiddlywiki/vanilla/base.tid b/themes/tiddlywiki/vanilla/base.tid index 6203bd19e..8094731b1 100644 --- a/themes/tiddlywiki/vanilla/base.tid +++ b/themes/tiddlywiki/vanilla/base.tid @@ -1251,6 +1251,16 @@ canvas.tw-edit-bitmapeditor { padding: 8px; } +.tw-plugin-info-disabled { + background: -webkit-repeating-linear-gradient(45deg, #ff0, #ff0 10px, #eee 10px, #eee 20px); + background: repeating-linear-gradient(45deg, #ff0, #ff0 10px, #eee 10px, #eee 20px); +} + +.tw-plugin-info-disabled:hover { + background: -webkit-repeating-linear-gradient(45deg, #aa0, #aa0 10px, #888 10px, #888 20px); + background: repeating-linear-gradient(45deg, #aa0, #aa0 10px, #888 10px, #888 20px); +} + a.tw-tiddlylink.tw-plugin-info:hover { text-decoration: none; background-color: <>; @@ -1273,7 +1283,7 @@ a.tw-tiddlylink.tw-plugin-info:hover { .tw-plugin-info-dropdown { border: 1px solid <>; - padding: 1em; + padding: 1em 1em 0 1em; margin-top: -1em; }