plugins.html 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>Plugins &#8212; searx 0.12.0 documentation</title>
  7. <link rel="stylesheet" href="../_static/style.css" type="text/css" />
  8. <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: '../',
  12. VERSION: '0.12.0',
  13. COLLAPSE_INDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true,
  16. SOURCELINK_SUFFIX: '.txt'
  17. };
  18. </script>
  19. <script type="text/javascript" src="../_static/jquery.js"></script>
  20. <script type="text/javascript" src="../_static/underscore.js"></script>
  21. <script type="text/javascript" src="../_static/doctools.js"></script>
  22. <link rel="index" title="Index" href="../genindex.html" />
  23. <link rel="search" title="Search" href="../search.html" />
  24. <link rel="next" title="Translation" href="translation.html" />
  25. <link rel="prev" title="Search API" href="search_api.html" />
  26. <link media="only screen and (max-device-width: 480px)" href="../_static/small_flask.css" type= "text/css" rel="stylesheet" />
  27. <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">
  28. </head>
  29. <body>
  30. <div class="document">
  31. <div class="documentwrapper">
  32. <div class="bodywrapper">
  33. <div class="body" role="main">
  34. <div class="section" id="plugins">
  35. <h1>Plugins<a class="headerlink" href="#plugins" title="Permalink to this headline">¶</a></h1>
  36. <p>Plugins can extend or replace functionality of various components of
  37. searx.</p>
  38. <div class="section" id="example-plugin">
  39. <h2>Example plugin<a class="headerlink" href="#example-plugin" title="Permalink to this headline">¶</a></h2>
  40. <div class="code python highlight-default"><div class="highlight"><pre><span></span><span class="n">name</span> <span class="o">=</span> <span class="s1">&#39;Example plugin&#39;</span>
  41. <span class="n">description</span> <span class="o">=</span> <span class="s1">&#39;This plugin extends the suggestions with the word &quot;example&quot;&#39;</span>
  42. <span class="n">default_on</span> <span class="o">=</span> <span class="kc">False</span> <span class="c1"># disabled by default</span>
  43. <span class="n">js_dependencies</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">()</span> <span class="c1"># optional, list of static js files</span>
  44. <span class="n">css_dependencies</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">()</span> <span class="c1"># optional, list of static css files</span>
  45. <span class="c1"># attach callback to the post search hook</span>
  46. <span class="c1"># request: flask request object</span>
  47. <span class="c1"># ctx: the whole local context of the post search hook</span>
  48. <span class="k">def</span> <span class="nf">post_search</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">ctx</span><span class="p">):</span>
  49. <span class="n">ctx</span><span class="p">[</span><span class="s1">&#39;search&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">suggestions</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s1">&#39;example&#39;</span><span class="p">)</span>
  50. <span class="k">return</span> <span class="kc">True</span>
  51. </pre></div>
  52. </div>
  53. </div>
  54. <div class="section" id="plugin-entry-points">
  55. <h2>Plugin entry points<a class="headerlink" href="#plugin-entry-points" title="Permalink to this headline">¶</a></h2>
  56. <p>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.</p>
  57. <div class="section" id="pre-search-hook">
  58. <h3>Pre search hook<a class="headerlink" href="#pre-search-hook" title="Permalink to this headline">¶</a></h3>
  59. <p>Runs BEFORE the search request. Function to implement: <code class="docutils literal"><span class="pre">pre_search</span></code></p>
  60. </div>
  61. <div class="section" id="post-search-hook">
  62. <h3>Post search hook<a class="headerlink" href="#post-search-hook" title="Permalink to this headline">¶</a></h3>
  63. <p>Runs AFTER the search request. Function to implement: <code class="docutils literal"><span class="pre">post_search</span></code></p>
  64. </div>
  65. <div class="section" id="result-hook">
  66. <h3>Result hook<a class="headerlink" href="#result-hook" title="Permalink to this headline">¶</a></h3>
  67. <p>Runs when a new result is added to the result list. Function to implement: <code class="docutils literal"><span class="pre">on_result</span></code></p>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  75. <div class="sphinxsidebarwrapper"><div class="sidebar_container body">
  76. <h1>Searx</h1>
  77. <ul>
  78. <li><a href="../index.html">Home</a></li>
  79. <li><a href="https://github.com/asciimoo/searx">Source</a></li>
  80. <li><a href="../blog/blog.html">Blog</a></li>
  81. <li><a href="https://github.com/asciimoo/searx/wiki">Wiki</a></li>
  82. <li><a href="https://github.com/asciimoo/searx/wiki/Searx-instances">Public instances</a></li>
  83. </ul>
  84. <hr />
  85. <ul>
  86. <li><a href="https://twitter.com/Searx_engine">Twitter</a></li>
  87. <li><a href="https://flattr.com/submit/auto?user_id=asciimoo&url=https://github.com/asciimoo/searx&title=searx&language=&tags=github&category=software">Flattr</a></li>
  88. <li><a href="https://gratipay.com/searx">Gratipay</a></li>
  89. </ul>
  90. </div>
  91. </div>
  92. </div>
  93. <div class="clearer"></div>
  94. </div>
  95. <div class="footer">
  96. &copy; Copyright 2015-2017, Adam Tauber.
  97. </div>
  98. </body>
  99. </html>