From 7313edff4632a4b0c037e0e11dc259c9303a4c1c Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Wed, 20 Dec 2023 12:14:34 -0700 Subject: [PATCH] Include more options for continuing search in error tmpl The error template previously only included the option to continue a user's search via Farside (whoogle or searxng), and would only appear when an instance was ratelimited. This has been updated to display anytime an exception has occurred, and now includes other options for continuing a search, such as Kagi, DDG, Brave, Ecosia, etc. Closes #1099 --- app/routes.py | 20 +++++++++ app/templates/error.html | 91 ++++++++++++++++++++++++++++++++++------ 2 files changed, 98 insertions(+), 13 deletions(-) diff --git a/app/routes.py b/app/routes.py index 90eeab6..4efc343 100644 --- a/app/routes.py +++ b/app/routes.py @@ -609,6 +609,26 @@ def page_not_found(e): return render_template('error.html', error_message=str(e)), 404 +@app.errorhandler(Exception) +def internal_error(e): + query = '' + if request.method == 'POST': + query = request.form.get('q') + else: + query = request.args.get('q') + + localization_lang = g.user_config.get_localization_lang() + translation = app.config['TRANSLATIONS'][localization_lang] + return render_template( + 'error.html', + error_message='Internal server error (500)', + translation=translation, + farside='https://farside.link', + config=g.user_config, + query=urlparse.unquote(query), + params=g.user_config.to_params(keys=['preferences'])), 500 + + def run_app() -> None: parser = argparse.ArgumentParser( description='Whoogle Search console runner') diff --git a/app/templates/error.html b/app/templates/error.html index d302270..99e87b3 100644 --- a/app/templates/error.html +++ b/app/templates/error.html @@ -20,21 +20,86 @@


- {% if blocked is defined %}

{{ translation['continue-search'] }}

- Whoogle: -
- - {{farside}}/whoogle/search?q={{query}} - -

- Searx: -
- - {{farside}}/searx/search?q={{query}} - + +
+

Other options:

+
- {% endif %}

Return Home