From f60e132d3c4bdd49c29c6d8759b775eb8ad50db0 Mon Sep 17 00:00:00 2001 From: gmd85 Date: Thu, 7 Apr 2022 01:35:04 +0200 Subject: [PATCH] Relativization of search results --- app/filter.py | 12 ++++++++++++ app/templates/search.html | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/filter.py b/app/filter.py index 6b4e284..8c3b780 100644 --- a/app/filter.py +++ b/app/filter.py @@ -104,6 +104,8 @@ class Filter: input_form = soup.find('form') if input_form is not None: input_form['method'] = 'GET' if self.config.get_only else 'POST' + # Use a relative URI for submissions + input_form['action'] = 'search' # Ensure no extra scripts passed through for script in soup('script'): @@ -394,6 +396,16 @@ class Filter: if href.startswith(MAPS_URL): # Maps links don't work if a site filter is applied link['href'] = MAPS_URL + "?q=" + clean_query(q) + elif href.startswith('/?') or href.startswith('/search?'): + # make sure that tags can be clicked as relative URLs + link['href'] = href[1:] + elif href.startswith('/intl/'): + # do nothing, keep original URL for ToS + pass + elif href.startswith('/preferences'): + # there is no config specific URL, remove this + link.decompose() + return else: link['href'] = href diff --git a/app/templates/search.html b/app/templates/search.html index 4695291..073b7ed 100644 --- a/app/templates/search.html +++ b/app/templates/search.html @@ -1,4 +1,4 @@ -
+