plugins.txt 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. Plugins
  2. -------
  3. Plugins can extend or replace functionality of various components of
  4. searx.
  5. Example plugin
  6. ~~~~~~~~~~~~~~
  7. .. code:: python
  8. name = 'Example plugin'
  9. description = 'This plugin extends the suggestions with the word "example"'
  10. default_on = False # disabled by default
  11. js_dependencies = tuple() # optional, list of static js files
  12. css_dependencies = tuple() # optional, list of static css files
  13. # attach callback to the post search hook
  14. # request: flask request object
  15. # ctx: the whole local context of the post search hook
  16. def post_search(request, ctx):
  17. ctx['search'].suggestions.add('example')
  18. return True
  19. Plugin entry points
  20. ~~~~~~~~~~~~~~~~~~~
  21. 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.
  22. Pre search hook
  23. ```````````````
  24. Runs BEFORE the search request. Function to implement: ``pre_search``
  25. Post search hook
  26. ````````````````
  27. Runs AFTER the search request. Function to implement: ``post_search``
  28. Result hook
  29. ```````````
  30. Runs when a new result is added to the result list. Function to implement: ``on_result``