on 013139b help sign in
searx/docs/dev/plugins.rst
45 lines 1.2 kB history raw
1Plugins
2-------
4Plugins can extend or replace functionality of various components of
5searx.
7Example plugin
8~~~~~~~~~~~~~~
10.. code:: python
12 name = 'Example plugin'
13 description = 'This plugin extends the suggestions with the word "example"'
14 default_on = False # disable by default
16 js_dependencies = tuple() # optional, list of static js files
17 css_dependencies = tuple() # optional, list of static css files
20 # attach callback to the post search hook
21 # request: flask request object
22 # ctx: the whole local context of the post search hook
23 def post_search(request, ctx):
24 ctx['search'].suggestions.add('example')
25 return True
27Plugin entry points
28~~~~~~~~~~~~~~~~~~~
30Entry points (hooks) define when a plugin runs. Right now only three hooks are implemented. So feel free to implement a hook if it fits the behaviour of your plugin.
32Pre search hook
33```````````````
35Runs BEFORE the search request. Function to implement: ``pre_search``
37Post search hook
38````````````````
40Runs AFTER the search request. Function to implement: ``post_search``
42Result hook
43```````````
45Runs when a new result is added to the result list. Function to implement: ``on_result``