diff options
author | Adam Tauber <asciimoo@gmail.com> | 2015-04-12 19:24:01 +0200 |
---|---|---|
committer | Adam Tauber <asciimoo@gmail.com> | 2015-04-12 19:24:01 +0200 |
commit | dd84814b68369e36d6be20bae707848a051a025a (patch) | |
tree | ce614f51091235ee9cceec9fbd3728cef2ebca31 /searx/plugins | |
parent | f59daa4a4b92ae3c6cbe2482a14f50810a15a644 (diff) | |
download | searxng-dd84814b68369e36d6be20bae707848a051a025a.tar.gz searxng-dd84814b68369e36d6be20bae707848a051a025a.zip |
[enh] plugins: client side dependency support
Diffstat (limited to 'searx/plugins')
-rw-r--r-- | searx/plugins/__init__.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/searx/plugins/__init__.py b/searx/plugins/__init__.py index 1cc232560..f3cf1bf2b 100644 --- a/searx/plugins/__init__.py +++ b/searx/plugins/__init__.py @@ -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) |