diff options
author | Markus Heiser <markus.heiser@darmarIT.de> | 2020-01-28 10:59:03 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-28 10:59:03 +0000 |
commit | e64ff38217a1ba49afd4bb1c595121d94cbb2e33 (patch) | |
tree | d8461b0392143da9d8ec9ae598b8a12c50914104 /docs/dev/plugins.rst | |
parent | 0e7b6c9a032d67bf5cbdcfc062d8466c18a62abd (diff) | |
parent | bda189565589b0065152f5a9fba4565404f9bd9a (diff) | |
download | searxng-e64ff38217a1ba49afd4bb1c595121d94cbb2e33.tar.gz searxng-e64ff38217a1ba49afd4bb1c595121d94cbb2e33.zip |
Merge branch 'master' into fix-infinite-scroll
Diffstat (limited to 'docs/dev/plugins.rst')
-rw-r--r-- | docs/dev/plugins.rst | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/docs/dev/plugins.rst b/docs/dev/plugins.rst new file mode 100644 index 000000000..2bf44f181 --- /dev/null +++ b/docs/dev/plugins.rst @@ -0,0 +1,54 @@ +.. _dev plugin: + +======= +Plugins +======= + +.. sidebar:: Further reading .. + + - :ref:`plugins generic` + +Plugins can extend or replace functionality of various components of searx. + +Example plugin +============== + +.. code:: python + + name = 'Example plugin' + description = 'This plugin extends the suggestions with the word "example"' + default_on = False # disabled by default + + js_dependencies = tuple() # optional, list of static js files + css_dependencies = tuple() # optional, list of static css files + + + # attach callback to the post search hook + # request: flask request object + # ctx: the whole local context of the post search hook + def post_search(request, ctx): + ctx['search'].suggestions.add('example') + return True + +Plugin entry points +=================== + +Entry 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. + +Pre search hook +--------------- + +Runs BEFORE the search request. Function to implement: ``pre_search`` + +Post search hook +---------------- + +Runs AFTER the search request. Function to implement: ``post_search`` + +Result hook +----------- + +Runs when a new result is added to the result list. Function to implement: +``on_result`` |