From e6b783154f05bbcc476d50a410ce1335b3ca6c99 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 18 Jun 2014 08:52:31 +0100 Subject: [PATCH] Allow arbitrary fields in plugin.info files Fixes #642 --- boot/boot.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/boot/boot.js b/boot/boot.js index fd205b7fc..aa6292e6d 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -1462,23 +1462,24 @@ $tw.loadPluginFolder = function(filepath,excludeRegExp) { if(!("version" in pluginInfo)) { pluginInfo.version = $tw.packageInfo.version; } - // Save the plugin tiddler - if(pluginInfo) { - return { - title: pluginInfo.title, - type: "application/json", - text: JSON.stringify({tiddlers: pluginInfo.tiddlers},null,4), - "plugin-priority": pluginInfo["plugin-priority"], - "name": pluginInfo["name"], - "version": pluginInfo["version"], - "thumbnail": pluginInfo["thumbnail"], - "description": pluginInfo["description"], - "plugin-type": pluginInfo["plugin-type"] || "plugin", - "dependents": $tw.utils.stringifyList(pluginInfo["dependents"] || []) - } - } else { - return null; + // Use "plugin" as the plugin-type if we don't have one + if(!("plugin-type" in pluginInfo)) { + pluginInfo["plugin-type"] = "plugin"; } + pluginInfo.dependents = pluginInfo.dependents || []; + pluginInfo.type = "application/json"; + // Set plugin text + pluginInfo.text = JSON.stringify({tiddlers: pluginInfo.tiddlers},null,4); + delete pluginInfo.tiddlers; + // Deserialise array fields (currently required for the dependents field) + for(var field in pluginInfo) { + if($tw.utils.isArray(pluginInfo[field])) { + pluginInfo[field] = $tw.utils.stringifyList(pluginInfo[field]); + } + } + return pluginInfo; + } else { + return null; } };