mirror of
https://github.com/searxng/searxng.git
synced 2025-07-12 15:59:21 +02:00
[enh] plugins: client side dependency support
This commit is contained in:
parent
f59daa4a4b
commit
dd84814b68
3 changed files with 26 additions and 4 deletions
|
@ -8,6 +8,9 @@ required_attrs = (('name', str),
|
|||
('description', str),
|
||||
('default_on', bool))
|
||||
|
||||
optional_attrs = (('js_dependencies', tuple),
|
||||
('css_dependencies', tuple))
|
||||
|
||||
|
||||
class Plugin():
|
||||
default_on = False
|
||||
|
@ -30,6 +33,9 @@ class PluginStore():
|
|||
if not hasattr(plugin, plugin_attr) or not isinstance(getattr(plugin, plugin_attr), plugin_attr_type):
|
||||
logger.critical('missing attribute "{0}", cannot load plugin: {1}'.format(plugin_attr, plugin))
|
||||
exit(3)
|
||||
for plugin_attr, plugin_attr_type in optional_attrs:
|
||||
if not hasattr(plugin, plugin_attr) or not isinstance(getattr(plugin, plugin_attr), plugin_attr_type):
|
||||
setattr(plugin, plugin_attr, plugin_attr_type())
|
||||
plugin.id = plugin.name.replace(' ', '_')
|
||||
self.plugins.append(plugin)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue