Made get_configurable_plugins work nicely with config.jsons that include multiple plugin entries as a list (#2161)

* Adds support for config.json to have multiple paths to add to the Plugins dropdown in the Admin Panel
* Closes #1370
This commit is contained in:
Dustin Loring
2022-08-08 14:28:48 -04:00
committed by GitHub
parent 471bd48f1c
commit 11a18daf98

View File

@@ -54,11 +54,19 @@ def get_configurable_plugins():
path = os.path.join(plugins_path, dir, "config.json") path = os.path.join(plugins_path, dir, "config.json")
with open(path) as f: with open(path) as f:
plugin_json_data = json.loads(f.read()) plugin_json_data = json.loads(f.read())
p = Plugin( if type(plugin_json_data) is list:
name=plugin_json_data.get("name"), for plugin_json in plugin_json_data:
route=plugin_json_data.get("route"), p = Plugin(
) name=plugin_json.get("name"),
plugins.append(p) route=plugin_json.get("route"),
)
plugins.append(p)
else:
p = Plugin(
name=plugin_json_data.get("name"),
route=plugin_json_data.get("route"),
)
plugins.append(p)
elif os.path.isfile(os.path.join(plugins_path, dir, "config.html")): elif os.path.isfile(os.path.join(plugins_path, dir, "config.html")):
p = Plugin(name=dir, route="/admin/plugins/{}".format(dir)) p = Plugin(name=dir, route="/admin/plugins/{}".format(dir))
plugins.append(p) plugins.append(p)