summaryrefslogtreecommitdiff
path: root/docs/dev/plugins.rst
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarIT.de>2019-12-24 17:45:13 +0100
committerGitHub <noreply@github.com>2019-12-24 17:45:13 +0100
commitecb054a7a058a1f62a536e5cac88eed8926b107d (patch)
tree925594876f18580732d2c8a438ff8f3bea8d9092 /docs/dev/plugins.rst
parentcc8d4b958e274eb9e154db5c319d2e50da561d61 (diff)
parent5a0a66e9bc34af2b6404231efc7cf02f389bdfcb (diff)
Merge branch 'master' into patch-1
Diffstat (limited to 'docs/dev/plugins.rst')
-rw-r--r--docs/dev/plugins.rst48
1 files changed, 48 insertions, 0 deletions
diff --git a/docs/dev/plugins.rst b/docs/dev/plugins.rst
new file mode 100644
index 000000000..e97bbeb4a
--- /dev/null
+++ b/docs/dev/plugins.rst
@@ -0,0 +1,48 @@
+=======
+Plugins
+=======
+
+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``