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

Allow arbitrary fields in plugin.info files

Fixes #642
This commit is contained in:
Jermolene 2014-06-18 08:52:31 +01:00
parent d2d0b09235
commit e6b783154f

View File

@ -1462,23 +1462,24 @@ $tw.loadPluginFolder = function(filepath,excludeRegExp) {
if(!("version" in pluginInfo)) { if(!("version" in pluginInfo)) {
pluginInfo.version = $tw.packageInfo.version; pluginInfo.version = $tw.packageInfo.version;
} }
// Save the plugin tiddler // Use "plugin" as the plugin-type if we don't have one
if(pluginInfo) { if(!("plugin-type" in pluginInfo)) {
return { pluginInfo["plugin-type"] = "plugin";
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;
} }
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;
} }
}; };