From 06b5126365ca3b38b75498949a237fa8ae2f4037 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Thu, 8 Apr 2021 09:43:41 -0400 Subject: [PATCH 1/3] Hotfix: Send generic "Mozilla" in user agent Randomizing the "Mozilla" portion of the user agent changed the character encoding to GB2312. Setting it to plain "Mozilla" enforces UTF-8 encoding. Bump to version 0.4.1 for release of bug fix Fixes #267 --- app/__init__.py | 2 +- app/request.py | 5 ++--- setup.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 67e6b76..f2119f4 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -21,7 +21,7 @@ app.default_key = generate_user_key() app.no_cookie_ips = [] app.config['SECRET_KEY'] = os.urandom(32) app.config['SESSION_TYPE'] = 'filesystem' -app.config['VERSION_NUMBER'] = '0.4.0' +app.config['VERSION_NUMBER'] = '0.4.1' app.config['APP_ROOT'] = os.getenv( 'APP_ROOT', os.path.dirname(os.path.abspath(__file__))) diff --git a/app/request.py b/app/request.py index 4cd9fcf..b4c67dd 100644 --- a/app/request.py +++ b/app/request.py @@ -49,14 +49,13 @@ def send_tor_signal(signal: Signal) -> bool: def gen_user_agent(is_mobile) -> str: - mozilla = random.choice(['Moo', 'Woah', 'Bro', 'Slow']) + 'zilla' firefox = random.choice(['Choir', 'Squier', 'Higher', 'Wire']) + 'fox' linux = random.choice(['Win', 'Sin', 'Gin', 'Fin', 'Kin']) + 'ux' if is_mobile: - return MOBILE_UA.format(mozilla, firefox) + return MOBILE_UA.format("Mozilla", firefox) - return DESKTOP_UA.format(mozilla, linux, firefox) + return DESKTOP_UA.format("Mozilla", linux, firefox) def gen_query(query, args, config, near_city=None) -> str: diff --git a/setup.py b/setup.py index 2bd2d4a..8ef0933 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( author='Ben Busby', author_email='benbusby@protonmail.com', name='whoogle-search', - version='0.4.0', + version='0.4.1', include_package_data=True, install_requires=requirements, description='Self-hosted, ad-free, privacy-respecting metasearch engine', From 01aaf5aaabde39398896a1d23fc761b0b02df6d0 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Fri, 9 Apr 2021 09:26:16 -0400 Subject: [PATCH 2/3] Disable logging from imported modules The logging from imported modules (stem, in particular) has caused quite a few users to assume there are errors where there aren't any. The logs from stem also aren't helpful, as everything in the library works as expected despite the implication from the logs that it is not working. --- app/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/__init__.py b/app/__init__.py index f2119f4..164b8e9 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -4,6 +4,7 @@ from app.utils.bangs import gen_bangs_json from flask import Flask from flask_session import Session import json +import logging.config import os from stem import Signal from dotenv import load_dotenv @@ -74,3 +75,9 @@ Session(app) send_tor_signal(Signal.HEARTBEAT) from app import routes # noqa + +# Disable logging from imported modules +logging.config.dictConfig({ + 'version': 1, + 'disable_existing_loggers': True, +}) From 9b141bb1913fe4fd75dffe7adc5cafeabbc34178 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Fri, 9 Apr 2021 11:00:02 -0400 Subject: [PATCH 3/3] Expand custom css theming support Also adds new default dark theme designed by @gripped. --- app/filter.py | 5 +++-- app/routes.py | 4 ++-- app/static/css/dark-theme.css | 8 ++++---- app/static/css/light-theme.css | 4 ++-- app/static/css/variables.css | 20 ++++++++++---------- app/templates/display.html | 4 ++-- app/templates/index.html | 8 ++++---- app/templates/logo.html | 2 +- 8 files changed, 28 insertions(+), 27 deletions(-) diff --git a/app/filter.py b/app/filter.py index 8f457f3..7848a79 100644 --- a/app/filter.py +++ b/app/filter.py @@ -153,7 +153,9 @@ class Filter: if src.startswith(LOGO_URL): # Re-brand with Whoogle logo - element.replace_with(BeautifulSoup(render_template('logo.html'))) + element.replace_with(BeautifulSoup( + render_template('logo.html', dark=self.dark), + features='html.parser')) return elif src.startswith(GOOG_IMG) or GOOG_STATIC in src: element['src'] = BLANK_B64 @@ -164,7 +166,6 @@ class Filter: is_element=True) + '&type=' + urlparse.quote(mime) def update_styling(self, soup) -> None: - """""" # Remove unnecessary button(s) for button in soup.find_all('button'): button.decompose() diff --git a/app/routes.py b/app/routes.py index 3ae805e..ff915ca 100644 --- a/app/routes.py +++ b/app/routes.py @@ -128,7 +128,7 @@ def index(): countries=app.config['COUNTRIES'], logo=render_template( 'logo.html', - config=g.user_config), + dark=g.user_config.dark), config=g.user_config, tor_available=int(os.environ.get('TOR_AVAILABLE')), version_number=app.config['VERSION_NUMBER']) @@ -227,7 +227,7 @@ def search(): search_header=(render_template( 'header.html', config=g.user_config, - logo=render_template('logo.html'), + logo=render_template('logo.html', dark=g.user_config.dark), query=urlparse.unquote(query), search_type=search_util.search_type, mobile=g.user_request.mobile) diff --git a/app/static/css/dark-theme.css b/app/static/css/dark-theme.css index 720f27a..732e4f0 100644 --- a/app/static/css/dark-theme.css +++ b/app/static/css/dark-theme.css @@ -86,11 +86,11 @@ select { } .collapsible { - color: var(--whoogle-dark-element-bg) !important; + color: var(--whoogle-dark-text); } .collapsible:after { - color: var(--whoogle-dark-element-bg) !important; + color: var(--whoogle-dark-text); } .active { @@ -104,11 +104,11 @@ select { } .active:after { - color: var(--whoogle-dark-contrast-text); + color: var(--whoogle-dark-contrast-text) !important; } #gh-link { - color: var(--whoogle-dark-element-bg); + color: var(--whoogle-dark-contrast-text); } .autocomplete-items { diff --git a/app/static/css/light-theme.css b/app/static/css/light-theme.css index b4da052..2548400 100644 --- a/app/static/css/light-theme.css +++ b/app/static/css/light-theme.css @@ -86,11 +86,11 @@ input { } .collapsible { - color: var(--whoogle-element-bg) !important; + color: var(--whoogle-text) !important; } .collapsible:after { - color: var(--whoogle-element-bg) !important; + color: var(--whoogle-text); } .active { diff --git a/app/static/css/variables.css b/app/static/css/variables.css index 76f94ac..7fd5c0c 100644 --- a/app/static/css/variables.css +++ b/app/static/css/variables.css @@ -13,14 +13,14 @@ --whoogle-result-visited: #4b11a8; /* DARK THEME COLORS */ - --whoogle-dark-logo: #685e79; - --whoogle-dark-page-bg: #222222; - --whoogle-dark-element-bg: #685e79; - --whoogle-dark-text: #ffffff; - --whoogle-dark-contrast-text: #000000; - --whoogle-dark-secondary-text: #bbbbbb; - --whoogle-dark-result-bg: #000000; - --whoogle-dark-result-title: #1967d2; - --whoogle-dark-result-url: #4b11a8; - --whoogle-dark-result-visited: #bbbbff; + --whoogle-dark-logo: #888888; + --whoogle-dark-page-bg: #080808; + --whoogle-dark-element-bg: #111111; + --whoogle-dark-text: #dddddd; + --whoogle-dark-contrast-text: #aaaaaa; + --whoogle-dark-secondary-text: #8a8b8c; + --whoogle-dark-result-bg: #111111; + --whoogle-dark-result-title: #dddddd; + --whoogle-dark-result-url: #eceff4; + --whoogle-dark-result-visited: #959595; } diff --git a/app/templates/display.html b/app/templates/display.html index 4eb0512..d21bd6b 100644 --- a/app/templates/display.html +++ b/app/templates/display.html @@ -17,9 +17,9 @@ {{ response|safe }} diff --git a/app/templates/index.html b/app/templates/index.html index c49943e..336b159 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -144,10 +144,10 @@ diff --git a/app/templates/logo.html b/app/templates/logo.html index bbd99b6..d1f4c4b 100644 --- a/app/templates/logo.html +++ b/app/templates/logo.html @@ -2,7 +2,7 @@