123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 &mdash; searx 0.9.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.9.0',
  13. COLLAPSE_INDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true
  16. };
  17. </script>
  18. <script type="text/javascript" src="../_static/jquery.js"></script>
  19. <script type="text/javascript" src="../_static/underscore.js"></script>
  20. <script type="text/javascript" src="../_static/doctools.js"></script>
  21. <link rel="top" title="searx 0.9.0 documentation" href="../index.html" />
  22. <link rel="next" title="Translation" href="translation.html" />
  23. <link rel="prev" title="Search API" href="search_api.html" />
  24. <link media="only screen and (max-device-width: 480px)" href="../_static/small_flask.css" type= "text/css" rel="stylesheet" />
  25. <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">
  26. </head>
  27. <body role="document">
  28. <div class="document">
  29. <div class="documentwrapper">
  30. <div class="bodywrapper">
  31. <div class="body" role="main">
  32. <div class="section" id="plugins">
  33. <h1>Plugins<a class="headerlink" href="#plugins" title="Permalink to this headline">¶</a></h1>
  34. <p>Plugins can extend or replace functionality of various components of
  35. searx.</p>
  36. <div class="section" id="example-plugin">
  37. <h2>Example plugin<a class="headerlink" href="#example-plugin" title="Permalink to this headline">¶</a></h2>
  38. <div class="code python highlight-default"><div class="highlight"><pre><span class="n">name</span> <span class="o">=</span> <span class="s">&#39;Example plugin&#39;</span>
  39. <span class="n">description</span> <span class="o">=</span> <span class="s">&#39;This plugin extends the suggestions with the word &quot;example&quot;&#39;</span>
  40. <span class="n">default_on</span> <span class="o">=</span> <span class="k">False</span> <span class="c"># disable by default</span>
  41. <span class="n">js_dependencies</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">()</span> <span class="c"># optional, list of static js files</span>
  42. <span class="n">css_dependencies</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">()</span> <span class="c"># optional, list of static css files</span>
  43. <span class="c"># attach callback to the post search hook</span>
  44. <span class="c"># request: flask request object</span>
  45. <span class="c"># ctx: the whole local context of the post search hook</span>
  46. <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>
  47. <span class="n">ctx</span><span class="p">[</span><span class="s">&#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="s">&#39;example&#39;</span><span class="p">)</span>
  48. <span class="k">return</span> <span class="k">True</span>
  49. </pre></div>
  50. </div>
  51. </div>
  52. <div class="section" id="plugin-entry-points">
  53. <h2>Plugin entry points<a class="headerlink" href="#plugin-entry-points" title="Permalink to this headline">¶</a></h2>
  54. <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>
  55. <div class="section" id="pre-search-hook">
  56. <h3>Pre search hook<a class="headerlink" href="#pre-search-hook" title="Permalink to this headline">¶</a></h3>
  57. <p>Runs BEFORE the search request. Function to implement: <code class="docutils literal"><span class="pre">pre_search</span></code></p>
  58. </div>
  59. <div class="section" id="post-search-hook">
  60. <h3>Post search hook<a class="headerlink" href="#post-search-hook" title="Permalink to this headline">¶</a></h3>
  61. <p>Runs AFTER the search request. Function to implement: <code class="docutils literal"><span class="pre">post_search</span></code></p>
  62. </div>
  63. <div class="section" id="result-hook">
  64. <h3>Result hook<a class="headerlink" href="#result-hook" title="Permalink to this headline">¶</a></h3>
  65. <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>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  73. <div class="sphinxsidebarwrapper"><div class="sidebar_container body">
  74. <h1>Searx</h1>
  75. <ul>
  76. <li><a href="../index.html">Home</a></li>
  77. <li><a href="https://github.com/asciimoo/searx">Source</a></li>
  78. <li><a href="https://github.com/asciimoo/searx/wiki">Wiki</a></li>
  79. <li><a href="https://github.com/asciimoo/searx/wiki/Searx-instances">Public instances</a></li>
  80. </ul>
  81. <hr />
  82. <ul>
  83. <li><a href="https://twitter.com/Searx_engine">Twitter</a></li>
  84. <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>
  85. <li><a href="https://gratipay.com/searx">Gratipay</a></li>
  86. </ul>
  87. </div>
  88. </div>
  89. </div>
  90. <div class="clearer"></div>
  91. </div>
  92. <div class="footer">
  93. &copy; Copyright 2015-2016, Adam Tauber.
  94. </div>
  95. </body>
  96. </html>