[enh] default settings option to safe_search - #396

This commit is contained in:
Adam Tauber 2015-08-02 20:29:19 +02:00
parent c1d9cfd9ae
commit 43cd8e0c41
2 changed files with 5 additions and 4 deletions

View File

@ -23,6 +23,7 @@ from operator import itemgetter
from Queue import Queue from Queue import Queue
from time import time from time import time
from urlparse import urlparse, unquote from urlparse import urlparse, unquote
from searx import settings
from searx.engines import ( from searx.engines import (
categories, engines categories, engines
) )
@ -480,9 +481,9 @@ class Search(object):
try: try:
# 0 = None, 1 = Moderate, 2 = Strict # 0 = None, 1 = Moderate, 2 = Strict
request_params['safesearch'] = int(request.cookies.get('safesearch', 1)) request_params['safesearch'] = int(request.cookies.get('safesearch'))
except ValueError: except ValueError:
request_params['safesearch'] = 1 request_params['safesearch'] = settings['search']['safe_search']
# update request parameters dependent on # update request parameters dependent on
# search-engine (contained in engines folder) # search-engine (contained in engines folder)

View File

@ -312,7 +312,7 @@ def render(template_name, override_theme=None, **kwargs):
kwargs['method'] = request.cookies.get('method', 'POST') kwargs['method'] = request.cookies.get('method', 'POST')
kwargs['safesearch'] = request.cookies.get('safesearch', '1') kwargs['safesearch'] = request.cookies.get('safesearch', str(settings['search']['safe_search']))
# override url_for function in templates # override url_for function in templates
kwargs['url_for'] = url_for_theme kwargs['url_for'] = url_for_theme
@ -542,7 +542,7 @@ def preferences():
locale = None locale = None
autocomplete = '' autocomplete = ''
method = 'POST' method = 'POST'
safesearch = '1' safesearch = settings['search']['safe_search']
for pd_name, pd in request.form.items(): for pd_name, pd in request.form.items():
if pd_name.startswith('category_'): if pd_name.startswith('category_'):
category = pd_name[9:] category = pd_name[9:]