searx/dev/plugins.html

172 lines
8.6 KiB
HTML
Raw Normal View History

2019-12-30 18:31:17 +01:00
<!DOCTYPE html>
2015-11-17 23:38:25 +01:00
2020-06-19 11:15:15 +02:00
<html>
2015-11-17 23:38:25 +01:00
<head>
2019-12-30 18:31:17 +01:00
<meta charset="utf-8" />
2020-09-30 10:35:05 +02:00
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
2019-12-30 18:31:17 +01:00
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Plugins &#8212; Searx Documentation (Searx-1.0.0.tex)</title>
2015-11-17 23:38:25 +01:00
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/searx.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="../_static/tabs.css" />
2020-02-15 10:08:58 +01:00
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
2016-11-04 21:56:14 +01:00
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
2015-11-17 23:38:25 +01:00
<link rel="next" title="Translation" href="translation.html" />
<link rel="prev" title="Search API" href="search_api.html" />
2019-12-30 18:31:17 +01:00
<script>DOCUMENTATION_OPTIONS.URL_ROOT = '../';</script>
2015-11-17 23:38:25 +01:00
2019-12-30 18:31:17 +01:00
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
2019-12-30 18:31:17 +01:00
<li class="right" >
<a href="translation.html" title="Translation"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="search_api.html" title="Search API"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">Searx Documentation (Searx-1.0.0.tex)</a> &#187;</li>
2020-09-30 10:35:05 +02:00
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Developer documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Plugins</a></li>
2019-12-30 18:31:17 +01:00
</ul>
</div>
2015-11-17 23:38:25 +01:00
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="plugins">
2019-12-30 18:31:17 +01:00
<span id="dev-plugin"></span><h1>Plugins<a class="headerlink" href="#plugins" title="Permalink to this headline"></a></h1>
<div class="sidebar">
2019-12-30 18:31:17 +01:00
<p class="sidebar-title">Further reading ..</p>
<ul class="simple">
<li><p><a class="reference internal" href="../admin/plugins.html#plugins-generic"><span class="std std-ref">Plugins builtin</span></a></p></li>
</ul>
</div>
2019-12-30 18:31:17 +01:00
<p>Plugins can extend or replace functionality of various components of searx.</p>
<div class="section" id="example-plugin">
2016-07-09 22:32:57 +02:00
<h2>Example plugin<a class="headerlink" href="#example-plugin" title="Permalink to this headline"></a></h2>
2019-12-30 18:31:17 +01:00
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">name</span> <span class="o">=</span> <span class="s1">&#39;Example plugin&#39;</span>
2016-11-04 21:56:14 +01:00
<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>
<span class="n">default_on</span> <span class="o">=</span> <span class="kc">False</span> <span class="c1"># disabled by default</span>
2015-11-17 23:38:25 +01:00
2016-11-04 21:56:14 +01:00
<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>
<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>
2015-11-17 23:38:25 +01:00
2016-11-04 21:56:14 +01:00
<span class="c1"># attach callback to the post search hook</span>
<span class="c1"># request: flask request object</span>
<span class="c1"># ctx: the whole local context of the post search hook</span>
2015-11-17 23:38:25 +01:00
<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>
2016-11-04 21:56:14 +01:00
<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>
<span class="k">return</span> <span class="kc">True</span>
2015-11-17 23:38:25 +01:00
</pre></div>
</div>
</div>
<div class="section" id="external-plugins">
2020-09-02 00:33:07 +02:00
<h2>External plugins<a class="headerlink" href="#external-plugins" title="Permalink to this headline"></a></h2>
<p>External plugins are standard python modules implementing all the requirements of the standard plugins.
Plugins can be enabled by adding them to <a class="reference internal" href="../admin/settings.html#settings-yml"><span class="std std-ref">settings.yml</span></a>s <code class="docutils literal notranslate"><span class="pre">plugins</span></code> section.
Example external plugin can be found <a class="reference external" href="https://github.com/asciimoo/searx_external_plugin_example">here</a>.</p>
</div>
<div class="section" id="register-your-plugin">
2020-07-25 18:33:36 +02:00
<h2>Register your plugin<a class="headerlink" href="#register-your-plugin" title="Permalink to this headline"></a></h2>
<p>To enable your plugin register your plugin in
searx &gt; plugin &gt; __init__.py.
And at the bottom of the file add your plugin like.
<code class="docutils literal notranslate"><span class="pre">plugins.register(name_of_python_file)</span></code></p>
</div>
<div class="section" id="plugin-entry-points">
2016-07-09 22:32:57 +02:00
<h2>Plugin entry points<a class="headerlink" href="#plugin-entry-points" title="Permalink to this headline"></a></h2>
2019-12-30 18:31:17 +01:00
<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>
<div class="section" id="pre-search-hook">
2016-07-09 22:32:57 +02:00
<h3>Pre search hook<a class="headerlink" href="#pre-search-hook" title="Permalink to this headline"></a></h3>
2019-12-30 18:31:17 +01:00
<p>Runs BEFORE the search request. Function to implement: <code class="docutils literal notranslate"><span class="pre">pre_search</span></code></p>
</div>
<div class="section" id="post-search-hook">
2016-07-09 22:32:57 +02:00
<h3>Post search hook<a class="headerlink" href="#post-search-hook" title="Permalink to this headline"></a></h3>
2019-12-30 18:31:17 +01:00
<p>Runs AFTER the search request. Function to implement: <code class="docutils literal notranslate"><span class="pre">post_search</span></code></p>
</div>
<div class="section" id="result-hook">
2016-07-09 22:32:57 +02:00
<h3>Result hook<a class="headerlink" href="#result-hook" title="Permalink to this headline"></a></h3>
2019-12-30 18:31:17 +01:00
<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>
</div>
</div>
</div>
2015-11-17 23:38:25 +01:00
2020-09-30 10:35:05 +02:00
<div class="clearer"></div>
2015-11-17 23:38:25 +01:00
</div>
</div>
</div>
2019-12-30 18:31:17 +01:00
<span id="sidebar-top"></span>
2015-11-17 23:38:25 +01:00
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
2019-12-30 18:31:17 +01:00
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../index.html">
<img class="logo" src="../_static/searx_logo_small.png" alt="Logo"/>
</a></p>
<h3>Project Links</h3>
<ul>
2020-09-30 10:35:05 +02:00
<li><a href="https://github.com/searx/searx">Source</a>
2019-12-30 18:31:17 +01:00
2020-09-30 10:35:05 +02:00
<li><a href="https://github.com/searx/searx/wiki">Wiki</a>
2019-12-30 18:31:17 +01:00
<li><a href="https://searx.space">Public instances</a>
2019-12-30 18:31:17 +01:00
<li><a href="https://twitter.com/Searx_engine">Twitter</a>
<li><a href="https://github.com/searx/searx/issues">Issue Tracker</a>
2019-12-30 18:31:17 +01:00
</ul><h3>Navigation</h3>
2015-11-17 23:38:25 +01:00
<ul>
2019-12-30 18:31:17 +01:00
<li><a href="../index.html">Overview</a>
<ul>
<li><a href="index.html">Developer documentation</a>
<ul>
<li>Previous: <a href="search_api.html" title="previous chapter">Search API</a>
<li>Next: <a href="translation.html" title="next chapter">Translation</a></ul>
</li>
</ul>
</li>
2015-11-17 23:38:25 +01:00
</ul>
2019-12-30 18:31:17 +01:00
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
2015-11-17 23:38:25 +01:00
</div>
2020-02-15 10:08:58 +01:00
<script>$('#searchbox').show(0);</script>
2015-11-17 23:38:25 +01:00
</div>
</div>
<div class="clearer"></div>
</div>
2019-12-30 18:31:17 +01:00
<div class="footer" role="contentinfo">
2020-02-20 19:32:55 +01:00
&#169; Copyright 2015-2020, Adam Tauber, Noémi Ványi.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.5.3.
2015-11-17 23:38:25 +01:00
</div>
2020-02-15 10:08:58 +01:00
<script src="../_static/version_warning_offset.js"></script>
2019-12-30 18:31:17 +01:00
2015-11-17 23:38:25 +01:00
</body>
</html>