diff options
author | asciimoo <asciimoo@gmail.com> | 2014-02-07 00:35:15 +0100 |
---|---|---|
committer | asciimoo <asciimoo@gmail.com> | 2014-02-07 00:35:15 +0100 |
commit | c0013edcdd998b49bdfce0b68ec38a0024347fd3 (patch) | |
tree | bfd43430068f93959bc17a4e5dd0dc8455537570 /searx/webapp.py | |
parent | b8d836e445484b6db4a2fd4c9102e0518889f220 (diff) | |
download | searxng-c0013edcdd998b49bdfce0b68ec38a0024347fd3.tar.gz searxng-c0013edcdd998b49bdfce0b68ec38a0024347fd3.zip |
[enh] engine customisation init
Diffstat (limited to 'searx/webapp.py')
-rw-r--r-- | searx/webapp.py | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/searx/webapp.py b/searx/webapp.py index 4f0fe92b3..80b5e4135 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -242,17 +242,6 @@ def about(): return render('about.html') -@app.route('/engines', methods=['GET']) -def list_engines(): - """Render engines page. - - List of all supported engines. - """ - return render('engines.html', - categs=categories.items(), - shortcuts={y: x for x, y in engine_shortcuts.items()}) - - @app.route('/preferences', methods=['GET', 'POST']) def preferences(): """Render preferences page. @@ -264,7 +253,11 @@ def preferences(): and request.cookies['language'] in (x[0] for x in language_codes): lang = request.cookies['language'] - if request.method == 'POST': + blocked_engines = [] + + if request.method == 'GET': + blocked_engines = request.cookies.get('blocked_engines', '').split(',') + else: selected_categories = [] locale = None for pd_name, pd in request.form.items(): @@ -278,10 +271,24 @@ def preferences(): elif pd_name == 'language' and (pd == 'all' or pd in (x[0] for x in language_codes)): + locale = pd lang = pd + elif pd_name.startswith('engine_'): + engine_name = pd_name.replace('engine_', '', 1) + if engine_name in engines: + blocked_engines.append(engine_name) resp = make_response(redirect('/')) + user_blocked_engines = request.cookies.get('blocked_engines', '').split(',') # noqa + + if sorted(blocked_engines) != sorted(user_blocked_engines): + # cookie max age: 4 weeks + resp.set_cookie( + 'blocked_engines', ','.join(blocked_engines), + max_age=60 * 60 * 24 * 7 * 4 + ) + if locale: # cookie max age: 4 weeks resp.set_cookie( @@ -307,7 +314,10 @@ def preferences(): locales=settings['locales'], current_locale=get_locale(), current_language=lang or 'all', - language_codes=language_codes) + language_codes=language_codes, + categs=categories.items(), + blocked_engines=blocked_engines, + shortcuts={y: x for x, y in engine_shortcuts.items()}) @app.route('/stats', methods=['GET']) |