From 2a37619028ce4463f09c373b9e68d43b1b0af854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o?= Date: Wed, 26 Oct 2022 18:26:14 +0200 Subject: [PATCH] Replace error query params w/ preferences param (#867) --- app/models/config.py | 7 +++++-- app/routes.py | 2 +- app/templates/error.html | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/models/config.py b/app/models/config.py index 7379398..3d6001a 100644 --- a/app/models/config.py +++ b/app/models/config.py @@ -158,14 +158,17 @@ class Config: self[param_key] = param_val return self - def to_params(self) -> str: + def to_params(self, keys: list = []) -> str: """Generates a set of safe params for using in Whoogle URLs Returns: str -- a set of URL parameters """ + if not len(keys): + keys = self.safe_keys + param_str = '' - for safe_key in self.safe_keys: + for safe_key in keys: if not self[safe_key]: continue param_str = param_str + f'&{safe_key}={self[safe_key]}' diff --git a/app/routes.py b/app/routes.py index 381b9ea..c1bb56b 100644 --- a/app/routes.py +++ b/app/routes.py @@ -326,7 +326,7 @@ def search(): farside='https://farside.link', config=g.user_config, query=urlparse.unquote(query), - params=g.user_config.to_params()), 503 + params=g.user_config.to_params(keys=['preferences'])), 503 response = bold_search_terms(response, query) # Feature to display IP address diff --git a/app/templates/error.html b/app/templates/error.html index 708f749..d302270 100644 --- a/app/templates/error.html +++ b/app/templates/error.html @@ -25,7 +25,7 @@ Whoogle:
- {{farside}}/whoogle/search?q={{query}}{{params}} + {{farside}}/whoogle/search?q={{query}}

Searx: