on ddab00a help sign in
searx/docs/dev/plugins.rst
69 lines 1.8 kB history raw
1.. _dev plugin:
3=======
4Plugins
5=======
7.. sidebar:: Further reading ..
9 - :ref:`plugins generic`
11Plugins can extend or replace functionality of various components of searx.
13Example plugin
14==============
16.. code:: python
18 name = 'Example plugin'
19 description = 'This plugin extends the suggestions with the word "example"'
20 default_on = False # disabled by default
22 js_dependencies = tuple() # optional, list of static js files
23 css_dependencies = tuple() # optional, list of static css files
26 # attach callback to the post search hook
27 # request: flask request object
28 # ctx: the whole local context of the post search hook
29 def post_search(request, ctx):
30 ctx['search'].suggestions.add('example')
31 return True
33External plugins
34================
36External plugins are standard python modules implementing all the requirements of the standard plugins.
37Plugins can be enabled by adding them to :ref:`settings.yml`'s ``plugins`` section.
38Example external plugin can be found `here <https://github.com/asciimoo/searx_external_plugin_example>`_.
40Register your plugin
41====================
43To enable your plugin register your plugin in
44searx > plugin > __init__.py.
45And at the bottom of the file add your plugin like.
46``plugins.register(name_of_python_file)``
48Plugin entry points
49===================
51Entry points (hooks) define when a plugin runs. Right now only three hooks are
52implemented. So feel free to implement a hook if it fits the behaviour of your
53plugin.
55Pre search hook
56---------------
58Runs BEFORE the search request. Function to implement: ``pre_search``
60Post search hook
61----------------
63Runs AFTER the search request. Function to implement: ``post_search``
65Result hook
66-----------
68Runs when a new result is added to the result list. Function to implement:
69``on_result``