mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-28 11:00:27 +00:00
Dynamic plugins: Change "contains JavaScript" to "requires reload"
We might in the future offer support for certain types of JS module to be hot loaded.
This commit is contained in:
parent
cb3bec65a1
commit
93e01435d1
@ -69,7 +69,7 @@ Command.prototype.execute = function() {
|
||||
// Collect the skinny list data
|
||||
var pluginTiddlers = JSON.parse(tiddler.text),
|
||||
readmeContent = (pluginTiddlers.tiddlers[title + "/readme"] || {}).text,
|
||||
doesContainJavaScript = !!$tw.wiki.doesPluginInfoContainModules(pluginTiddlers),
|
||||
doesRequireReload = !!$tw.wiki.doesPluginInfoRequireReload(pluginTiddlers),
|
||||
iconTiddler = pluginTiddlers.tiddlers[title + "/icon"] || {},
|
||||
iconType = iconTiddler.type,
|
||||
iconText = iconTiddler.text,
|
||||
@ -80,7 +80,7 @@ Command.prototype.execute = function() {
|
||||
skinnyList.push($tw.utils.extend({},tiddler,{
|
||||
text: undefined,
|
||||
readme: readmeContent,
|
||||
"contains-javascript": doesContainJavaScript ? "yes" : "no",
|
||||
"requires-reload": doesRequireReload ? "yes" : "no",
|
||||
icon: iconContent
|
||||
}));
|
||||
});
|
||||
|
@ -28,8 +28,8 @@ exports.startup = function() {
|
||||
requireReloadDueToPluginChange = false;
|
||||
$tw.utils.each(Object.keys(changes),function(title) {
|
||||
var tiddler = $tw.wiki.getTiddler(title),
|
||||
containsModules = $tw.wiki.doesPluginContainModules(title);
|
||||
if(containsModules) {
|
||||
requiresReload = $tw.wiki.doesPluginRequireReload(title);
|
||||
if(requiresReload) {
|
||||
requireReloadDueToPluginChange = true;
|
||||
} else if(tiddler) {
|
||||
var pluginType = tiddler.fields["plugin-type"];
|
||||
|
@ -41,14 +41,14 @@ exports.upgrade = function(wiki,titles,tiddlers) {
|
||||
// Check if we're dealing with a plugin
|
||||
if(incomingTiddler && incomingTiddler["plugin-type"]) {
|
||||
// Check whether the plugin contains JS modules
|
||||
var doesContainJavaScript = $tw.wiki.doesPluginInfoContainModules(JSON.parse(incomingTiddler.text)) ? ($tw.wiki.getTiddlerText("$:/language/ControlPanel/Plugins/PluginWillRequireReload") + " ") : "";
|
||||
messages[title] = doesContainJavaScript;
|
||||
var requiresReload = $tw.wiki.doesPluginInfoRequireReload(JSON.parse(incomingTiddler.text)) ? ($tw.wiki.getTiddlerText("$:/language/ControlPanel/Plugins/PluginWillRequireReload") + " ") : "";
|
||||
messages[title] = requiresReload;
|
||||
if(incomingTiddler.version) {
|
||||
// Upgrade the incoming plugin if it is in the upgrade library
|
||||
var libraryTiddler = getLibraryTiddler(title);
|
||||
if(libraryTiddler && libraryTiddler["plugin-type"] && libraryTiddler.version) {
|
||||
tiddlers[title] = libraryTiddler;
|
||||
messages[title] = doesContainJavaScript + $tw.language.getString("Import/Upgrader/Plugins/Upgraded",{variables: {incoming: incomingTiddler.version, upgraded: libraryTiddler.version}});
|
||||
messages[title] = requiresReload + $tw.language.getString("Import/Upgrader/Plugins/Upgraded",{variables: {incoming: incomingTiddler.version, upgraded: libraryTiddler.version}});
|
||||
return;
|
||||
}
|
||||
// Suppress the incoming plugin if it is older than the currently installed one
|
||||
@ -57,7 +57,7 @@ exports.upgrade = function(wiki,titles,tiddlers) {
|
||||
// Reject the incoming plugin by blanking all its fields
|
||||
if($tw.utils.checkVersions(existingTiddler.fields.version,incomingTiddler.version)) {
|
||||
tiddlers[title] = Object.create(null);
|
||||
messages[title] = doesContainJavaScript + $tw.language.getString("Import/Upgrader/Plugins/Suppressed/Version",{variables: {incoming: incomingTiddler.version, existing: existingTiddler.fields.version}});
|
||||
messages[title] = requiresReload + $tw.language.getString("Import/Upgrader/Plugins/Suppressed/Version",{variables: {incoming: incomingTiddler.version, existing: existingTiddler.fields.version}});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1460,13 +1460,13 @@ exports.invokeUpgraders = function(titles,tiddlers) {
|
||||
return messages;
|
||||
};
|
||||
|
||||
// Determine whether a plugin by title contains JS modules.
|
||||
exports.doesPluginContainModules = function(title) {
|
||||
return this.doesPluginInfoContainModules(this.getPluginInfo(title) || this.getTiddlerDataCached(title));
|
||||
// Determine whether a plugin by title is dynamically loadable
|
||||
exports.doesPluginRequireReload = function(title) {
|
||||
return this.doesPluginInfoRequireReload(this.getPluginInfo(title) || this.getTiddlerDataCached(title));
|
||||
};
|
||||
|
||||
// Determine whether a plugin info structure contains JS modules.
|
||||
exports.doesPluginInfoContainModules = function(pluginInfo) {
|
||||
// Determine whether a plugin info structure is dynamically loadable
|
||||
exports.doesPluginInfoRequireReload = function(pluginInfo) {
|
||||
if(pluginInfo) {
|
||||
var foundModule = false;
|
||||
$tw.utils.each(pluginInfo.tiddlers,function(tiddler) {
|
||||
|
@ -19,7 +19,7 @@ subtitle: {{$:/core/images/download-button}} {{$:/language/ControlPanel/Plugins/
|
||||
</$button>
|
||||
<div>
|
||||
</div>
|
||||
<$reveal stateTitle=<<assetInfo>> stateField="contains-javascript" type="match" text="yes">{{$:/language/ControlPanel/Plugins/PluginWillRequireReload}}</$reveal>
|
||||
<$reveal stateTitle=<<assetInfo>> stateField="requires-reload" type="match" text="yes">{{$:/language/ControlPanel/Plugins/PluginWillRequireReload}}</$reveal>
|
||||
</div>
|
||||
\end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user