1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-26 19:47:20 +00:00

Make it possible to disable plugins

This commit is contained in:
Jermolene 2014-08-15 21:10:40 +01:00
parent 04e049df97
commit 32a7ee2683
5 changed files with 70 additions and 17 deletions

View File

@ -967,19 +967,22 @@ $tw.Wiki = function(options) {
this.registerPluginTiddlers = function(pluginType,titles) { this.registerPluginTiddlers = function(pluginType,titles) {
var self = this, var self = this,
registeredTitles = [], registeredTitles = [],
checkTiddler = function(tiddler) { checkTiddler = function(tiddler,title) {
if(tiddler && tiddler.fields.type === "application/json" && tiddler.fields["plugin-type"] === pluginType) { if(tiddler && tiddler.fields.type === "application/json" && tiddler.fields["plugin-type"] === pluginType) {
var disablingTiddler = self.getTiddler("$:/config/Plugins/Disabled/" + title);
if(title === "$:/core" || !disablingTiddler || (disablingTiddler.fields.text || "").trim() !== "yes") {
pluginTiddlers.push(tiddler); pluginTiddlers.push(tiddler);
registeredTitles.push(tiddler.fields.title); registeredTitles.push(tiddler.fields.title);
} }
}
}; };
if(titles) { if(titles) {
$tw.utils.each(titles,function(title) { $tw.utils.each(titles,function(title) {
checkTiddler(self.getTiddler(title)); checkTiddler(self.getTiddler(title),title);
}); });
} else { } else {
this.each(function(tiddler,title) { this.each(function(tiddler,title) {
checkTiddler(tiddler); checkTiddler(tiddler,title);
}); });
} }
return registeredTitles; return registeredTitles;

View File

@ -64,7 +64,12 @@ Basics/Title/Prompt: Title of this ~TiddlyWiki:
Basics/Username/Prompt: Username for signing edits: Basics/Username/Prompt: Username for signing edits:
Basics/Version/Prompt: ~TiddlyWiki version: Basics/Version/Prompt: ~TiddlyWiki version:
Plugins/Caption: Plugins 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/Empty/Hint: None
Plugins/Enable/Caption: enable
Plugins/Enable/Hint: Enable this plugin when reloading page
Plugins/Language/Prompt: Languages Plugins/Language/Prompt: Languages
Plugins/Plugin/Prompt: Plugins Plugins/Plugin/Prompt: Plugins
Plugins/Theme/Prompt: Themes Plugins/Theme/Prompt: Themes

View File

@ -12,11 +12,10 @@ $(popup-state)$-$(pluginInfoType)$
\define plugin-icon-title() \define plugin-icon-title()
$(currentTiddler)$/icon $(currentTiddler)$/icon
\end \end
\define plugin-table(type) \define plugin-disable-title()
<$set name="qualified-state" value=<<qualify "$:/state/plugin-info">>> $:/config/Plugins/Disabled/$(currentTiddler)$
<$list filter="[!has[draft.of]plugin-type[$type$]sort[description]]" emptyMessage=<<lingo "Empty/Hint">>> \end
<$set name="popup-state" value=<<popup-state-macro>>> \define plugin-table-body(type,disabledMessage)
<$link to={{!!title}} class="tw-plugin-info">
<div class="tw-plugin-info-chunk"> <div class="tw-plugin-info-chunk">
<$reveal type="nomatch" state=<<popup-state>> text="yes"> <$reveal type="nomatch" state=<<popup-state>> text="yes">
<$button class="btn-invisible btn-dropdown" set=<<popup-state>> setTo="yes"> <$button class="btn-invisible btn-dropdown" set=<<popup-state>> setTo="yes">
@ -36,7 +35,7 @@ $(currentTiddler)$/icon
</div> </div>
<div class="tw-plugin-info-chunk"> <div class="tw-plugin-info-chunk">
<div> <div>
''<$view field="description"><$view field="title"/></$view>'' ''<$view field="description"><$view field="title"/></$view>'' $disabledMessage$
</div> </div>
<div> <div>
<$view field="title"/> <$view field="title"/>
@ -45,18 +44,44 @@ $(currentTiddler)$/icon
<$view field="version"/> <$view field="version"/>
</div> </div>
</div> </div>
\end
\define plugin-table(type)
<$set name="qualified-state" value=<<qualify "$:/state/plugin-info">>>
<$list filter="[!has[draft.of]plugin-type[$type$]sort[description]]" emptyMessage=<<lingo "Empty/Hint">>>
<$set name="popup-state" value=<<popup-state-macro>>>
<$reveal type="nomatch" state=<<plugin-disable-title>> text="yes">
<$link to={{!!title}} class="tw-plugin-info">
<<plugin-table-body type:"$type$">>
</$link> </$link>
</$reveal>
<$reveal type="match" state=<<plugin-disable-title>> text="yes">
<$link to={{!!title}} class="tw-plugin-info tw-plugin-info-disabled">
<<plugin-table-body type:"$type$" disabledMessage:"<$macrocall $name='lingo' title='Disabled/Status'/>">>
</$link>
</$reveal>
<$reveal type="match" text="yes" state=<<popup-state>>> <$reveal type="match" text="yes" state=<<popup-state>>>
<$reveal type="nomatch" text="" state="!!list">
<div class="tw-plugin-info-dropdown"> <div class="tw-plugin-info-dropdown">
<$macrocall $name="tabs" state=<<tabs-state-macro>> tabsList={{!!list}} default="readme" template="$:/core/ui/PluginInfo"/> <$list filter="[all[current]] -[[$:/core]]">
<div style="float:right;">
<$reveal type="nomatch" state=<<plugin-disable-title>> text="yes">
<$button set=<<plugin-disable-title>> setTo="yes" title={{$:/language/ControlPanel/Plugins/Disable/Hint}} aria-label={{$:/language/ControlPanel/Plugins/Disable/Caption}}>
<<lingo Disable/Caption>>
</$button>
</$reveal>
<$reveal type="match" state=<<plugin-disable-title>> text="yes">
<$button set=<<plugin-disable-title>> setTo="no" title={{$:/language/ControlPanel/Plugins/Enable/Hint}} aria-label={{$:/language/ControlPanel/Plugins/Enable/Caption}}>
<<lingo Enable/Caption>>
</$button>
</$reveal>
</div> </div>
</$list>
<$reveal type="nomatch" text="" state="!!list">
<$macrocall $name="tabs" state=<<tabs-state-macro>> tabsList={{!!list}} default="readme" template="$:/core/ui/PluginInfo"/>
</$reveal> </$reveal>
<$reveal type="match" text="" state="!!list"> <$reveal type="match" text="" state="!!list">
<div class="tw-plugin-info-dropdown">
No information provided No information provided
</div>
</$reveal> </$reveal>
</div>
</$reveal> </$reveal>
</$set> </$set>
</$list> </$list>

View File

@ -1,5 +1,5 @@
created: 20130826122000000 created: 20130826122000000
modified: 20140807094840608 modified: 20140815094840608
tags: mechanism tags: mechanism
title: PluginMechanism title: PluginMechanism
type: text/vnd.tiddlywiki 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. 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 ! 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]]. Plugin authors are encouraged to provide special information and documentation tiddlers that TiddlyWiki can include as plugin information tabs in the [[control panel|$:/ControlPanel]].

View File

@ -1251,6 +1251,16 @@ canvas.tw-edit-bitmapeditor {
padding: 8px; 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 { a.tw-tiddlylink.tw-plugin-info:hover {
text-decoration: none; text-decoration: none;
background-color: <<colour primary>>; background-color: <<colour primary>>;
@ -1273,7 +1283,7 @@ a.tw-tiddlylink.tw-plugin-info:hover {
.tw-plugin-info-dropdown { .tw-plugin-info-dropdown {
border: 1px solid <<colour muted-foreground>>; border: 1px solid <<colour muted-foreground>>;
padding: 1em; padding: 1em 1em 0 1em;
margin-top: -1em; margin-top: -1em;
} }