mirror of https://github.com/searxng/searxng.git
Merge 121993abcd
into 231e55f38d
This commit is contained in:
commit
cb67194ef8
|
@ -210,6 +210,7 @@ class PluginStore:
|
||||||
|
|
||||||
plugins = PluginStore()
|
plugins = PluginStore()
|
||||||
|
|
||||||
|
plugins.register('./query_strings.py')
|
||||||
|
|
||||||
def plugin_module_names():
|
def plugin_module_names():
|
||||||
yield_plugins = set()
|
yield_plugins = set()
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
import shlex, string
|
||||||
|
from flask_babel import gettext
|
||||||
|
|
||||||
|
name = gettext("query strings")
|
||||||
|
description = gettext('adds site:, - and "" to searx')
|
||||||
|
default_on = True
|
||||||
|
|
||||||
|
def on_result(request, search, result):
|
||||||
|
q = search.search_query.query
|
||||||
|
qs = shlex.split(q)
|
||||||
|
spitems = [x.lower() for x in qs if ' ' in x]
|
||||||
|
mitems = [x.lower() for x in qs if x.startswith('-')]
|
||||||
|
siteitems = [x.lower() for x in qs if x.startswith('site:')]
|
||||||
|
msiteitems = [x.lower() for x in qs if x.startswith('-site:')]
|
||||||
|
url, title, content = result["url"].lower(), result["title"].lower(), (result.get("content").lower() if result.get("content") else '')
|
||||||
|
if all((x not in title or x not in content) for x in spitems):
|
||||||
|
return False
|
||||||
|
if all((x in title or x in content) for x in mitems):
|
||||||
|
return False
|
||||||
|
if all(x not in url for x in siteitems):
|
||||||
|
return False
|
||||||
|
if all(x in url for x in msiteitems):
|
||||||
|
return False
|
||||||
|
return True
|
|
@ -217,7 +217,8 @@ outgoing:
|
||||||
|
|
||||||
# Comment or un-comment plugin to activate / deactivate by default.
|
# Comment or un-comment plugin to activate / deactivate by default.
|
||||||
#
|
#
|
||||||
# enabled_plugins:
|
enabled_plugins:
|
||||||
|
- 'query strings'
|
||||||
# # these plugins are enabled if nothing is configured ..
|
# # these plugins are enabled if nothing is configured ..
|
||||||
# - 'Basic Calculator'
|
# - 'Basic Calculator'
|
||||||
# - 'Hash plugin'
|
# - 'Hash plugin'
|
||||||
|
|
Loading…
Reference in New Issue