123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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="X-UA-Compatible" content="IE=Edge" />
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <title>Plugins &#8212; searx 0.12.0 documentation</title>
  8. <link rel="stylesheet" href="../_static/style.css" type="text/css" />
  9. <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
  10. <script type="text/javascript" src="../_static/documentation_options.js"></script>
  11. <script type="text/javascript" src="../_static/jquery.js"></script>
  12. <script type="text/javascript" src="../_static/underscore.js"></script>
  13. <script type="text/javascript" src="../_static/doctools.js"></script>
  14. <link rel="index" title="Index" href="../genindex.html" />
  15. <link rel="search" title="Search" href="../search.html" />
  16. <link rel="next" title="Translation" href="translation.html" />
  17. <link rel="prev" title="Search API" href="search_api.html" />
  18. <link media="only screen and (max-device-width: 480px)" href="../_static/small_flask.css" type= "text/css" rel="stylesheet" />
  19. <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">
  20. </head><body>
  21. <div class="document">
  22. <div class="documentwrapper">
  23. <div class="bodywrapper">
  24. <div class="body" role="main">
  25. <div class="section" id="plugins">
  26. <h1>Plugins<a class="headerlink" href="#plugins" title="Permalink to this headline">¶</a></h1>
  27. <p>Plugins can extend or replace functionality of various components of
  28. searx.</p>
  29. <div class="section" id="example-plugin">
  30. <h2>Example plugin<a class="headerlink" href="#example-plugin" title="Permalink to this headline">¶</a></h2>
  31. <div class="code python highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">name</span> <span class="o">=</span> <span class="s1">&#39;Example plugin&#39;</span>
  32. <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>
  33. <span class="n">default_on</span> <span class="o">=</span> <span class="kc">False</span> <span class="c1"># disabled by default</span>
  34. <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>
  35. <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>
  36. <span class="c1"># attach callback to the post search hook</span>
  37. <span class="c1"># request: flask request object</span>
  38. <span class="c1"># ctx: the whole local context of the post search hook</span>
  39. <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>
  40. <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>
  41. <span class="k">return</span> <span class="kc">True</span>
  42. </pre></div>
  43. </div>
  44. </div>
  45. <div class="section" id="plugin-entry-points">
  46. <h2>Plugin entry points<a class="headerlink" href="#plugin-entry-points" title="Permalink to this headline">¶</a></h2>
  47. <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>
  48. <div class="section" id="pre-search-hook">
  49. <h3>Pre search hook<a class="headerlink" href="#pre-search-hook" title="Permalink to this headline">¶</a></h3>
  50. <p>Runs BEFORE the search request. Function to implement: <code class="docutils literal notranslate"><span class="pre">pre_search</span></code></p>
  51. </div>
  52. <div class="section" id="post-search-hook">
  53. <h3>Post search hook<a class="headerlink" href="#post-search-hook" title="Permalink to this headline">¶</a></h3>
  54. <p>Runs AFTER the search request. Function to implement: <code class="docutils literal notranslate"><span class="pre">post_search</span></code></p>
  55. </div>
  56. <div class="section" id="result-hook">
  57. <h3>Result hook<a class="headerlink" href="#result-hook" title="Permalink to this headline">¶</a></h3>
  58. <p>Runs when a new result is added to the result list. Function to implement: <code class="docutils literal notranslate"><span class="pre">on_result</span></code></p>
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  66. <div class="sphinxsidebarwrapper">
  67. <h3><a href="../index.html">Table Of Contents</a></h3>
  68. <ul>
  69. <li><a class="reference internal" href="#">Plugins</a><ul>
  70. <li><a class="reference internal" href="#example-plugin">Example plugin</a></li>
  71. <li><a class="reference internal" href="#plugin-entry-points">Plugin entry points</a><ul>
  72. <li><a class="reference internal" href="#pre-search-hook">Pre search hook</a></li>
  73. <li><a class="reference internal" href="#post-search-hook">Post search hook</a></li>
  74. <li><a class="reference internal" href="#result-hook">Result hook</a></li>
  75. </ul>
  76. </li>
  77. </ul>
  78. </li>
  79. </ul>
  80. <div class="sidebar_container body">
  81. <h1>Searx</h1>
  82. <ul>
  83. <li><a href="../index.html">Home</a></li>
  84. <li><a href="https://github.com/asciimoo/searx">Source</a></li>
  85. <li><a href="../blog/blog.html">Blog</a></li>
  86. <li><a href="https://github.com/asciimoo/searx/wiki">Wiki</a></li>
  87. <li><a href="https://github.com/asciimoo/searx/wiki/Searx-instances">Public instances</a></li>
  88. </ul>
  89. <hr />
  90. <ul>
  91. <li><a href="https://twitter.com/Searx_engine">Twitter</a></li>
  92. </ul>
  93. </div>
  94. <div role="note" aria-label="source link">
  95. <h3>This Page</h3>
  96. <ul class="this-page-menu">
  97. <li><a href="../_sources/dev/plugins.rst.txt"
  98. rel="nofollow">Show Source</a></li>
  99. </ul>
  100. </div>
  101. <div id="searchbox" style="display: none" role="search">
  102. <h3>Quick search</h3>
  103. <div class="searchformwrapper">
  104. <form class="search" action="../search.html" method="get">
  105. <input type="text" name="q" />
  106. <input type="submit" value="Go" />
  107. <input type="hidden" name="check_keywords" value="yes" />
  108. <input type="hidden" name="area" value="default" />
  109. </form>
  110. </div>
  111. </div>
  112. <script type="text/javascript">$('#searchbox').show(0);</script>
  113. </div>
  114. </div>
  115. <div class="clearer"></div>
  116. </div>
  117. <div class="footer">
  118. &copy; Copyright 2015-2017, Adam Tauber.
  119. </div>
  120. </body>
  121. </html>