searx/dev/plugins.html

113 lines
5.9 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Plugins &#8212; searx 0.10.0 documentation</title>
<link rel="stylesheet" href="../_static/style.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.10.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="top" title="searx 0.10.0 documentation" href="../index.html" />
<link rel="next" title="Translation" href="translation.html" />
<link rel="prev" title="Search API" href="search_api.html" />
<link media="only screen and (max-device-width: 480px)" href="../_static/small_flask.css" type= "text/css" rel="stylesheet" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">
</head>
<body role="document">
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="plugins">
<h1>Plugins<a class="headerlink" href="#plugins" title="Permalink to this headline"></a></h1>
<p>Plugins can extend or replace functionality of various components of
searx.</p>
<div class="section" id="example-plugin">
<h2>Example plugin<a class="headerlink" href="#example-plugin" title="Permalink to this headline"></a></h2>
<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>
<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>
<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>
<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>
<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>
<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>
</pre></div>
</div>
</div>
<div class="section" id="plugin-entry-points">
<h2>Plugin entry points<a class="headerlink" href="#plugin-entry-points" title="Permalink to this headline"></a></h2>
<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">
<h3>Pre search hook<a class="headerlink" href="#pre-search-hook" title="Permalink to this headline"></a></h3>
<p>Runs BEFORE the search request. Function to implement: <code class="docutils literal"><span class="pre">pre_search</span></code></p>
</div>
<div class="section" id="post-search-hook">
<h3>Post search hook<a class="headerlink" href="#post-search-hook" title="Permalink to this headline"></a></h3>
<p>Runs AFTER the search request. Function to implement: <code class="docutils literal"><span class="pre">post_search</span></code></p>
</div>
<div class="section" id="result-hook">
<h3>Result hook<a class="headerlink" href="#result-hook" title="Permalink to this headline"></a></h3>
<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>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper"><div class="sidebar_container body">
<h1>Searx</h1>
<ul>
<li><a href="../index.html">Home</a></li>
<li><a href="https://github.com/asciimoo/searx">Source</a></li>
<li><a href="https://github.com/asciimoo/searx/wiki">Wiki</a></li>
<li><a href="https://github.com/asciimoo/searx/wiki/Searx-instances">Public instances</a></li>
</ul>
<hr />
<ul>
<li><a href="https://twitter.com/Searx_engine">Twitter</a></li>
<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>
<li><a href="https://gratipay.com/searx">Gratipay</a></li>
</ul>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy; Copyright 2015-2016, Adam Tauber.
</div>
</body>
</html>