searx/dev/plugins.html

113 lines
5.9 KiB
HTML
Raw Normal View History

2015-11-17 23:38:25 +01:00
<!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" />
2017-03-18 23:56:08 +01:00
<title>Plugins &#8212; searx 0.11.0 documentation</title>
2015-11-17 23:38:25 +01:00
<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: '../',
2017-03-18 23:56:08 +01:00
VERSION: '0.11.0',
2015-11-17 23:38:25 +01:00
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>
2016-11-04 21:56:14 +01:00
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
2017-03-18 23:56:08 +01:00
<link rel="top" title="searx 0.11.0 documentation" href="../index.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" />
<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>
2016-07-09 22:32:57 +02:00
<p>Plugins can extend or replace functionality of various components of
2015-11-17 23:38:25 +01:00
searx.</p>
2016-07-09 22:32:57 +02:00
<div class="section" id="example-plugin">
<h2>Example plugin<a class="headerlink" href="#example-plugin" title="Permalink to this headline"></a></h2>
2016-11-04 21:56:14 +01:00
<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>
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>
2016-07-09 22:32:57 +02:00
<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>
2015-11-17 23:38:25 +01:00
</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">
2016-07-09 21:55:17 +02:00
&copy; Copyright 2015-2016, Adam Tauber.
2015-11-17 23:38:25 +01:00
</div>
</body>
</html>