on f9faafa help sign in
searx/docs/dev/plugins.rst
62 lines 1.5 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
33Register your plugin
34====================
36To enable your plugin register your plugin in
37searx > plugin > __init__.py.
38And at the bottom of the file add your plugin like.
39``plugins.register(name_of_python_file)``
41Plugin entry points
42===================
44Entry points (hooks) define when a plugin runs. Right now only three hooks are
45implemented. So feel free to implement a hook if it fits the behaviour of your
46plugin.
48Pre search hook
49---------------
51Runs BEFORE the search request. Function to implement: ``pre_search``
53Post search hook
54----------------
56Runs AFTER the search request. Function to implement: ``post_search``
58Result hook
59-----------
61Runs when a new result is added to the result list. Function to implement:
62``on_result``