plugins.html 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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/replace functionality of various components inside
  35. searx.</p>
  36. <div class="section" id="example-plugin-py">
  37. <h2>example_plugin.py<a class="headerlink" href="#example-plugin-py" 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="currently-implemented-plugin-entry-points-a-k-a-hooks">
  53. <h2>Currently implemented plugin entry points (a.k.a hooks)<a class="headerlink" href="#currently-implemented-plugin-entry-points-a-k-a-hooks" title="Permalink to this headline">¶</a></h2>
  54. <ul class="simple">
  55. <li>Pre search hook (<code class="docutils literal"><span class="pre">pre_search</span></code>)</li>
  56. <li>Post search hook (<code class="docutils literal"><span class="pre">post_search</span></code>)</li>
  57. <li>Result hook (<code class="docutils literal"><span class="pre">on_result</span></code>) (is called if a new result is added (see
  58. https_rewrite plugin))</li>
  59. </ul>
  60. <p>Feel free to add more hooks to the code if it is required by a plugin.</p>
  61. </div>
  62. <div class="section" id="todo">
  63. <h2>TODO<a class="headerlink" href="#todo" title="Permalink to this headline">¶</a></h2>
  64. <ul class="simple">
  65. <li>Better documentation</li>
  66. <li>More hooks</li>
  67. <li>search hook (is called while searx is requesting results (for
  68. example: things like math-solver), the different hooks are running
  69. parallel)</li>
  70. </ul>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  77. <div class="sphinxsidebarwrapper"><div class="sidebar_container body">
  78. <h1>Searx</h1>
  79. <ul>
  80. <li><a href="../index.html">Home</a></li>
  81. <li><a href="https://github.com/asciimoo/searx">Source</a></li>
  82. <li><a href="https://github.com/asciimoo/searx/wiki">Wiki</a></li>
  83. <li><a href="https://github.com/asciimoo/searx/wiki/Searx-instances">Public instances</a></li>
  84. </ul>
  85. <hr />
  86. <ul>
  87. <li><a href="https://twitter.com/Searx_engine">Twitter</a></li>
  88. <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>
  89. <li><a href="https://gratipay.com/searx">Gratipay</a></li>
  90. </ul>
  91. </div>
  92. </div>
  93. </div>
  94. <div class="clearer"></div>
  95. </div>
  96. <div class="footer">
  97. &copy; Copyright 2015-2016, Adam Tauber.
  98. </div>
  99. </body>
  100. </html>