plugins.rst 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. =======
  2. Plugins
  3. =======
  4. Plugins can extend or replace functionality of various components of 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
  22. implemented. So feel free to implement a hook if it fits the behaviour of your
  23. plugin.
  24. Pre search hook
  25. ---------------
  26. Runs BEFORE the search request. Function to implement: ``pre_search``
  27. Post search hook
  28. ----------------
  29. Runs AFTER the search request. Function to implement: ``post_search``
  30. Result hook
  31. -----------
  32. Runs when a new result is added to the result list. Function to implement:
  33. ``on_result``