summaryrefslogtreecommitdiff
path: root/searx/webapp.py
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2020-09-28 14:56:23 +0200
committerGitHub <noreply@github.com>2020-09-28 14:56:23 +0200
commit8d47142f35199866b26ee4e9149bbb8b058a6873 (patch)
tree2d67cc00aa2a9d6546178d7149802ef4313533b9 /searx/webapp.py
parentc2a6f145160dca0873dbd2f2c9ffe7e1bc340236 (diff)
parentf2f3300bde0cc304f80809ff766fc557b5486098 (diff)
downloadsearxng-8d47142f35199866b26ee4e9149bbb8b058a6873.tar.gz
searxng-8d47142f35199866b26ee4e9149bbb8b058a6873.zip
Merge pull request #2189 from dalf/architecture-clean-up
Architecture clean up
Diffstat (limited to 'searx/webapp.py')
-rwxr-xr-xsearx/webapp.py28
1 files changed, 7 insertions, 21 deletions
diff --git a/searx/webapp.py b/searx/webapp.py
index 2be15ab91..5723734c1 100755
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -67,10 +67,11 @@ from searx.webutils import (
get_static_files, get_result_templates, get_themes,
prettify_url, new_hmac
)
+from searx.webadapter import get_search_query_from_webapp, get_selected_categories
from searx.utils import html_to_text, gen_useragent, dict_subset, match_language
from searx.version import VERSION_STRING
from searx.languages import language_codes as languages
-from searx.search import SearchWithPlugins, get_search_query_from_webapp
+from searx.search import SearchWithPlugins
from searx.query import RawTextQuery
from searx.autocomplete import searx_bang, backends as autocomplete_backends
from searx.plugins import plugins
@@ -347,25 +348,6 @@ def render(template_name, override_theme=None, **kwargs):
_get_ordered_categories()
if x in enabled_categories]
- if 'all_categories' not in kwargs:
- kwargs['all_categories'] = _get_ordered_categories()
-
- if 'selected_categories' not in kwargs:
- kwargs['selected_categories'] = []
- for arg in request.args:
- if arg.startswith('category_'):
- c = arg.split('_', 1)[1]
- if c in categories:
- kwargs['selected_categories'].append(c)
-
- if not kwargs['selected_categories']:
- cookie_categories = request.preferences.get_value('categories')
- for ccateg in cookie_categories:
- kwargs['selected_categories'].append(ccateg)
-
- if not kwargs['selected_categories']:
- kwargs['selected_categories'] = ['general']
-
if 'autocomplete' not in kwargs:
kwargs['autocomplete'] = request.preferences.get_value('autocomplete')
@@ -524,6 +506,7 @@ def index_error(output_format, error_message):
request.errors.append(gettext('search error'))
return render(
'index.html',
+ selected_categories=get_selected_categories(request.preferences, request.form),
)
@@ -545,6 +528,7 @@ def index():
if output_format == 'html':
return render(
'index.html',
+ selected_categories=get_selected_categories(request.preferences, request.form),
)
else:
return index_error(output_format, 'No query'), 400
@@ -554,7 +538,7 @@ def index():
raw_text_query = None
result_container = None
try:
- search_query, raw_text_query = get_search_query_from_webapp(request.preferences, request.form)
+ search_query, raw_text_query, _, _ = get_search_query_from_webapp(request.preferences, request.form)
# search = Search(search_query) # without plugins
search = SearchWithPlugins(search_query, request.user_plugins, request)
@@ -825,6 +809,8 @@ def preferences():
# end of stats
return render('preferences.html',
+ selected_categories=get_selected_categories(request.preferences, request.form),
+ all_categories=_get_ordered_categories(),
locales=settings['locales'],
current_locale=request.preferences.get_value("locale"),
image_proxy=image_proxy,