forked from zaclys/searxng
[enh] default disabled engines - closes #109
This commit is contained in:
parent
bfd321a7a9
commit
b19e681cce
|
@ -69,17 +69,17 @@ def load_engine(engine_data):
|
||||||
engine.categories = ['general']
|
engine.categories = ['general']
|
||||||
|
|
||||||
if not hasattr(engine, 'language_support'):
|
if not hasattr(engine, 'language_support'):
|
||||||
# engine.language_support = False
|
|
||||||
engine.language_support = True
|
engine.language_support = True
|
||||||
|
|
||||||
if not hasattr(engine, 'timeout'):
|
if not hasattr(engine, 'timeout'):
|
||||||
# engine.language_support = False
|
|
||||||
engine.timeout = settings['server']['request_timeout']
|
engine.timeout = settings['server']['request_timeout']
|
||||||
|
|
||||||
if not hasattr(engine, 'shortcut'):
|
if not hasattr(engine, 'shortcut'):
|
||||||
# engine.shortcut = '''
|
|
||||||
engine.shortcut = ''
|
engine.shortcut = ''
|
||||||
|
|
||||||
|
if not hasattr(engine, 'disabled'):
|
||||||
|
engine.disabled = False
|
||||||
|
|
||||||
# checking required variables
|
# checking required variables
|
||||||
for engine_attr in dir(engine):
|
for engine_attr in dir(engine):
|
||||||
if engine_attr.startswith('_'):
|
if engine_attr.startswith('_'):
|
||||||
|
|
|
@ -27,7 +27,7 @@ from searx.engines import (
|
||||||
categories, engines
|
categories, engines
|
||||||
)
|
)
|
||||||
from searx.languages import language_codes
|
from searx.languages import language_codes
|
||||||
from searx.utils import gen_useragent
|
from searx.utils import gen_useragent, get_blocked_engines
|
||||||
from searx.query import Query
|
from searx.query import Query
|
||||||
from searx import logger
|
from searx import logger
|
||||||
|
|
||||||
|
@ -320,10 +320,7 @@ class Search(object):
|
||||||
self.lang = 'all'
|
self.lang = 'all'
|
||||||
|
|
||||||
# set blocked engines
|
# set blocked engines
|
||||||
if request.cookies.get('blocked_engines'):
|
self.blocked_engines = get_blocked_engines(engines, request.cookies)
|
||||||
self.blocked_engines = request.cookies['blocked_engines'].split(',') # noqa
|
|
||||||
else:
|
|
||||||
self.blocked_engines = []
|
|
||||||
|
|
||||||
self.results = []
|
self.results = []
|
||||||
self.suggestions = []
|
self.suggestions = []
|
||||||
|
|
|
@ -96,6 +96,7 @@ engines:
|
||||||
- name : general-file
|
- name : general-file
|
||||||
engine : generalfile
|
engine : generalfile
|
||||||
shortcut : gf
|
shortcut : gf
|
||||||
|
disabled : True
|
||||||
|
|
||||||
- name : github
|
- name : github
|
||||||
engine : github
|
engine : github
|
||||||
|
@ -121,6 +122,7 @@ engines:
|
||||||
content_xpath : //a[@class="subtitle"]
|
content_xpath : //a[@class="subtitle"]
|
||||||
categories : files
|
categories : files
|
||||||
shortcut : gpa
|
shortcut : gpa
|
||||||
|
disabled : True
|
||||||
|
|
||||||
- name : google play movies
|
- name : google play movies
|
||||||
engine : xpath
|
engine : xpath
|
||||||
|
@ -130,6 +132,7 @@ engines:
|
||||||
content_xpath : //a[@class="subtitle"]
|
content_xpath : //a[@class="subtitle"]
|
||||||
categories : videos
|
categories : videos
|
||||||
shortcut : gpm
|
shortcut : gpm
|
||||||
|
disabled : True
|
||||||
|
|
||||||
- name : google play music
|
- name : google play music
|
||||||
engine : xpath
|
engine : xpath
|
||||||
|
@ -139,6 +142,7 @@ engines:
|
||||||
content_xpath : //a[@class="subtitle"]
|
content_xpath : //a[@class="subtitle"]
|
||||||
categories : music
|
categories : music
|
||||||
shortcut : gps
|
shortcut : gps
|
||||||
|
disabled : True
|
||||||
|
|
||||||
- name : mixcloud
|
- name : mixcloud
|
||||||
engine : mixcloud
|
engine : mixcloud
|
||||||
|
@ -175,6 +179,7 @@ engines:
|
||||||
- name : searchcode code
|
- name : searchcode code
|
||||||
engine : searchcode_code
|
engine : searchcode_code
|
||||||
shortcut : scc
|
shortcut : scc
|
||||||
|
disabled : True
|
||||||
|
|
||||||
- name : subtitleseeker
|
- name : subtitleseeker
|
||||||
engine : subtitleseeker
|
engine : subtitleseeker
|
||||||
|
@ -239,7 +244,7 @@ engines:
|
||||||
# shortcut : ya
|
# shortcut : ya
|
||||||
# base_url : 'http://localhost:8090'
|
# base_url : 'http://localhost:8090'
|
||||||
# number_of_results : 5
|
# number_of_results : 5
|
||||||
# timeout: 3.0
|
# timeout : 3.0
|
||||||
|
|
||||||
locales:
|
locales:
|
||||||
en : English
|
en : English
|
||||||
|
|
|
@ -225,3 +225,11 @@ def prettify_url(url):
|
||||||
return u'{0}[...]{1}'.format(url[:35], url[-35:])
|
return u'{0}[...]{1}'.format(url[:35], url[-35:])
|
||||||
else:
|
else:
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
|
||||||
|
def get_blocked_engines(engines, cookies):
|
||||||
|
if 'blocked_engines' not in cookies:
|
||||||
|
return [engine for engine in engines if engines[engine].disabled]
|
||||||
|
|
||||||
|
return [engine for engine in cookies.get('blocked_engines', '').split(',')
|
||||||
|
if engine in engines]
|
||||||
|
|
|
@ -43,7 +43,7 @@ from searx.engines import (
|
||||||
from searx.utils import (
|
from searx.utils import (
|
||||||
UnicodeWriter, highlight_content, html_to_text, get_themes,
|
UnicodeWriter, highlight_content, html_to_text, get_themes,
|
||||||
get_static_files, get_result_templates, gen_useragent, dict_subset,
|
get_static_files, get_result_templates, gen_useragent, dict_subset,
|
||||||
prettify_url
|
prettify_url, get_blocked_engines
|
||||||
)
|
)
|
||||||
from searx.version import VERSION_STRING
|
from searx.version import VERSION_STRING
|
||||||
from searx.languages import language_codes
|
from searx.languages import language_codes
|
||||||
|
@ -225,7 +225,7 @@ def image_proxify(url):
|
||||||
|
|
||||||
|
|
||||||
def render(template_name, override_theme=None, **kwargs):
|
def render(template_name, override_theme=None, **kwargs):
|
||||||
blocked_engines = request.cookies.get('blocked_engines', '').split(',')
|
blocked_engines = get_blocked_engines(engines, request.cookies)
|
||||||
|
|
||||||
autocomplete = request.cookies.get('autocomplete')
|
autocomplete = request.cookies.get('autocomplete')
|
||||||
|
|
||||||
|
@ -410,10 +410,7 @@ def autocompleter():
|
||||||
request_data = request.args
|
request_data = request.args
|
||||||
|
|
||||||
# set blocked engines
|
# set blocked engines
|
||||||
if request.cookies.get('blocked_engines'):
|
blocked_engines = get_blocked_engines(engines, request.cookies)
|
||||||
blocked_engines = request.cookies['blocked_engines'].split(',') # noqa
|
|
||||||
else:
|
|
||||||
blocked_engines = []
|
|
||||||
|
|
||||||
# parse query
|
# parse query
|
||||||
query = Query(request_data.get('q', '').encode('utf-8'), blocked_engines)
|
query = Query(request_data.get('q', '').encode('utf-8'), blocked_engines)
|
||||||
|
@ -468,7 +465,7 @@ def preferences():
|
||||||
resp = make_response(redirect(url_for('index')))
|
resp = make_response(redirect(url_for('index')))
|
||||||
|
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
blocked_engines = request.cookies.get('blocked_engines', '').split(',')
|
blocked_engines = get_blocked_engines(engines, request.cookies)
|
||||||
else: # on save
|
else: # on save
|
||||||
selected_categories = []
|
selected_categories = []
|
||||||
locale = None
|
locale = None
|
||||||
|
|
Loading…
Reference in New Issue