From cb80c181a6129459a6aeae61e882580c0f7ac084 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Fri, 9 Apr 2021 23:56:14 -0400 Subject: [PATCH 1/4] Direct wget output in Docker healthcheck to stdout wget's default behavior to download contents to a file is not always a valid method to use as a Docker healthcheck, due to permission issues. This circumvents any issues there by redirecting the healthcheck output to stdout, which shouldn't cause any issues regardless of context. Fixes #272 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 50bbf87..df50793 100644 --- a/Dockerfile +++ b/Dockerfile @@ -68,6 +68,6 @@ COPY whoogle.env . EXPOSE $EXPOSE_PORT HEALTHCHECK --interval=30s --timeout=5s \ - CMD wget --no-verbose --tries=1 http://localhost:${EXPOSE_PORT}/ || exit 1 + CMD wget -qO- --no-verbose --tries=1 http://localhost:${EXPOSE_PORT}/ || exit 1 CMD misc/tor/start-tor.sh & ./run From 18af72c1828996202573126403457bb516608263 Mon Sep 17 00:00:00 2001 From: FlawCra Date: Mon, 12 Apr 2021 16:02:37 +0200 Subject: [PATCH 2/4] Add public instance to readme (#273) https://search.flawcra.cc --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0f67982..310fab5 100644 --- a/README.md +++ b/README.md @@ -366,6 +366,7 @@ A lot of the app currently piggybacks on Google's existing support for fetching - [https://search.garudalinux.org](https://search.garudalinux.org) - [https://whooglesearch.net/](https://whooglesearch.net/) - [https://search.whoogle.tech/](https://search.whoogle.tech/) +- [https://search.flawcra.cc/](https://search.flawcra.cc/) ## Screenshots #### Desktop ![Whoogle Desktop](docs/screenshot_desktop.jpg) From b7e48a9597bbcba39b228abd430d2b3df38259d8 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Mon, 12 Apr 2021 10:22:34 -0400 Subject: [PATCH 3/4] Replace remaining hardcoded theme values Both light and dark themes have been updated to remove the leftover hardcoded values (mostly related to the search suggestion styling). See discussion in #247. --- app/static/css/dark-theme.css | 13 +++++++------ app/static/css/light-theme.css | 10 +++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/static/css/dark-theme.css b/app/static/css/dark-theme.css index 97a819f..3579752 100644 --- a/app/static/css/dark-theme.css +++ b/app/static/css/dark-theme.css @@ -15,7 +15,7 @@ label { } li a { - color: #4b8eaa !important; + color: var(--whoogle-dark-result-url) !important; } li { @@ -116,17 +116,18 @@ select { } .autocomplete-items { - border: 1px solid #685e79; + border: 1px solid var(--whoogle-dark-element-bg); } .autocomplete-items div { - color: #fff; - background-color: #222; - border-bottom: 1px solid #242424; + color: var(--whoogle-dark-text); + background-color: var(--whoogle-dark-page-bg); + border-bottom: 1px solid var(--whoogle-dark-element-bg); } .autocomplete-items div:hover { - background-color: #404040; + background-color: var(--whoogle-dark-element-bg); + color: var(--whoogle-dark-contrast-text) !important; } .autocomplete-active { diff --git a/app/static/css/light-theme.css b/app/static/css/light-theme.css index 2548400..de76eb6 100644 --- a/app/static/css/light-theme.css +++ b/app/static/css/light-theme.css @@ -15,7 +15,7 @@ label { } li a { - color: #4b8eaa !important; + color: var(--whoogle-result-url) !important; } li { @@ -112,16 +112,16 @@ input { } .autocomplete-items { - border: 1px solid #d4d4d4; + border: 1px solid var(--whoogle-element-bg); } .autocomplete-items div { - background-color: #fff; - border-bottom: 1px solid #d4d4d4; + background-color: var(--whoogle-page-bg); + border-bottom: 1px solid var(--whoogle-element-bg); } .autocomplete-items div:hover { - background-color: #e9e9e9; + background-color: var(--whoogle-element-bg); } .autocomplete-active { From baa7a87efb970a5db277c9905f2e4b881912c514 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Mon, 12 Apr 2021 16:40:59 -0400 Subject: [PATCH 4/4] Fix incorrect config bool env var casting Config boolean environment variables need to be cast to ints, since they are set or unset using 0 and 1. Previously they were interpreted as (pseudocode) read_var(name, default=False), which meant that setting CONFIG_VAR=0 would enable that variable since Python reads environment variables as strings, and '0' is truthy. This updates the previous logic to (still pseudocode) int(read_var(name, default='0')). Fixes #279 --- app/models/config.py | 36 +++++++++++++++++++++++------------- test/conftest.py | 2 +- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/app/models/config.py b/app/models/config.py index b2ebc57..ec2bc79 100644 --- a/app/models/config.py +++ b/app/models/config.py @@ -8,17 +8,19 @@ class Config: self.url = os.getenv('WHOOGLE_CONFIG_URL', '') self.lang_search = os.getenv('WHOOGLE_CONFIG_LANGUAGE', '') self.lang_interface = os.getenv('WHOOGLE_CONFIG_LANGUAGE', '') - self.style = open(os.path.join(app_config['STATIC_FOLDER'], - 'css/variables.css')).read() + self.style = os.getenv( + 'WHOOGLE_CONFIG_STYLE', + open(os.path.join(app_config['STATIC_FOLDER'], + 'css/variables.css')).read()) self.ctry = os.getenv('WHOOGLE_CONFIG_COUNTRY', '') - self.safe = bool(os.getenv('WHOOGLE_CONFIG_SAFE', False)) - self.dark = bool(os.getenv('WHOOGLE_CONFIG_DARK', False)) - self.alts = bool(os.getenv('WHOOGLE_CONFIG_ALTS', False)) - self.nojs = bool(os.getenv('WHOOGLE_CONFIG_NOJS', False)) - self.tor = bool(os.getenv('WHOOGLE_CONFIG_TOR', False)) + self.safe = int(os.getenv('WHOOGLE_CONFIG_SAFE', '0')) + self.dark = int(os.getenv('WHOOGLE_CONFIG_DARK', '0')) + self.alts = int(os.getenv('WHOOGLE_CONFIG_ALTS', '0')) + self.nojs = int(os.getenv('WHOOGLE_CONFIG_NOJS', '0')) + self.tor = int(os.getenv('WHOOGLE_CONFIG_TOR', '0')) self.near = os.getenv('WHOOGLE_CONFIG_NEAR', '') - self.new_tab = bool(os.getenv('WHOOGLE_CONFIG_NEW_TAB', False)) - self.get_only = bool(os.getenv('WHOOGLE_CONFIG_GET_ONLY', False)) + self.new_tab = int(os.getenv('WHOOGLE_CONFIG_NEW_TAB', '0')) + self.get_only = int(os.getenv('WHOOGLE_CONFIG_GET_ONLY', '0')) self.safe_keys = [ 'lang_search', 'lang_interface', @@ -26,10 +28,13 @@ class Config: 'dark' ] - for key, value in kwargs.items(): - if not value: - continue - setattr(self, key, value) + # Skip setting custom config if there isn't one + if kwargs: + for attr in self.get_mutable_attrs(): + if attr not in kwargs.keys(): + setattr(self, attr, '') + else: + setattr(self, attr, kwargs[attr]) def __getitem__(self, name): return getattr(self, name) @@ -43,6 +48,11 @@ class Config: def __contains__(self, name): return hasattr(self, name) + def get_mutable_attrs(self): + return {name: attr for name, attr in self.__dict__.items() + if not name.startswith("__") + and (type(attr) is int or type(attr) is str)} + def is_safe_key(self, key) -> bool: """Establishes a group of config options that are safe to set in the url. diff --git a/test/conftest.py b/test/conftest.py index 34c92c4..3068b32 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -5,7 +5,7 @@ import random demo_config = { 'near': random.choice(['Seattle', 'New York', 'San Francisco']), - 'dark_mode': str(random.getrandbits(1)), + 'dark': str(random.getrandbits(1)), 'nojs': str(random.getrandbits(1)), 'lang_interface': random.choice(app.config['LANGUAGES'])['value'], 'lang_search': random.choice(app.config['LANGUAGES'])['value'],