From 98d639883c4c83288e1b762439c6b3604f713a15 Mon Sep 17 00:00:00 2001 From: Ben Busby <33362396+benbusby@users.noreply.github.com> Date: Tue, 26 May 2020 10:39:19 -0600 Subject: [PATCH 1/3] Fixing styling/url/safe mode inconsistencies --- app/filter.py | 7 +++++-- app/models/config.py | 2 +- app/routes.py | 1 + app/templates/header.html | 8 +++++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/filter.py b/app/filter.py index 54029c5..0478889 100644 --- a/app/filter.py +++ b/app/filter.py @@ -12,6 +12,7 @@ LOGO_URL = GOOG_IMG + '_desk' BLANK_B64 = ''' data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAD0lEQVR42mNkwAIYh7IgAAVVAAuInjI5AAAAAElFTkSuQmCC ''' +GOOGLE_LINKS = ['/gmail', '/calendar', '/advanced_search'] def get_first_link(soup): @@ -174,8 +175,10 @@ class Filter: # Replace hrefs with only the intended destination (no "utm" type tags) for a in soup.find_all('a', href=True): href = a['href'].replace('https://www.google.com', '') - if '/advanced_search' in href: - a.decompose() + if href in GOOGLE_LINKS: + print(href) + if '/advanced_search' in href: + a.decompose() continue elif self.new_tab: a['target'] = '_blank' diff --git a/app/models/config.py b/app/models/config.py index 0976400..544d2d1 100644 --- a/app/models/config.py +++ b/app/models/config.py @@ -300,7 +300,7 @@ class Config: self.url = '' self.lang = 'lang_en' self.ctry = '' - self.safe = True + self.safe = False self.dark = False self.nojs = False self.near = '' diff --git a/app/routes.py b/app/routes.py index 3b99508..82b3147 100644 --- a/app/routes.py +++ b/app/routes.py @@ -144,6 +144,7 @@ def search(): response=formatted_results, search_header=render_template( 'header.html', + dark_mode=g.user_config.dark, q=urlparse.unquote(q), search_type=search_type, mobile=g.user_request.mobile) if 'isch' not in search_type else '') diff --git a/app/templates/header.html b/app/templates/header.html index 8db1459..5356ec2 100644 --- a/app/templates/header.html +++ b/app/templates/header.html @@ -12,6 +12,9 @@
@@ -34,7 +37,10 @@
+ spellcheck="false" type="text" value="{{ q }}" + style="background-color: {{ '#000' if dark_mode else '#fff' }}; + color: {{ '#685e79' if dark_mode else '#000' }}; + border: {{ '1px solid #685e79' if dark_mode else '' }}">
From 78939e7fb447eff2613200c448716870b9aa1c68 Mon Sep 17 00:00:00 2001 From: Ben Busby <33362396+benbusby@users.noreply.github.com> Date: Tue, 26 May 2020 10:47:40 -0600 Subject: [PATCH 2/3] Reworked google url routing --- app/filter.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/filter.py b/app/filter.py index 0478889..5ff46b7 100644 --- a/app/filter.py +++ b/app/filter.py @@ -12,7 +12,6 @@ LOGO_URL = GOOG_IMG + '_desk' BLANK_B64 = ''' data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAD0lEQVR42mNkwAIYh7IgAAVVAAuInjI5AAAAAElFTkSuQmCC ''' -GOOGLE_LINKS = ['/gmail', '/calendar', '/advanced_search'] def get_first_link(soup): @@ -175,10 +174,8 @@ class Filter: # Replace hrefs with only the intended destination (no "utm" type tags) for a in soup.find_all('a', href=True): href = a['href'].replace('https://www.google.com', '') - if href in GOOGLE_LINKS: - print(href) - if '/advanced_search' in href: - a.decompose() + if '/advanced_search' in href: + a.decompose() continue elif self.new_tab: a['target'] = '_blank' @@ -186,7 +183,9 @@ class Filter: result_link = urlparse.urlparse(href) query_link = parse_qs(result_link.query)['q'][0] if '?q=' in href else '' - if '/search?q=' in href: + if query_link.startswith('/'): + a['href'] = 'https://google.com' + query_link + elif '/search?q=' in href: enc_result = Fernet(self.secret_key).encrypt(query_link.encode()) new_search = '/search?q=' + enc_result.decode() From cb18bc6ccc7027f87a4043669dbcb31b78a32d75 Mon Sep 17 00:00:00 2001 From: Ben Busby <33362396+benbusby@users.noreply.github.com> Date: Tue, 26 May 2020 10:58:37 -0600 Subject: [PATCH 3/3] Updated autocomplete styling Added dark theme specific stylesheet to use if dark mode is active --- app/routes.py | 1 + app/static/css/search-dark.css | 35 ++++++++++++++++++++++++++++++++++ app/templates/display.html | 2 +- app/templates/index.html | 2 +- 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 app/static/css/search-dark.css diff --git a/app/routes.py b/app/routes.py index 82b3147..3f50082 100644 --- a/app/routes.py +++ b/app/routes.py @@ -141,6 +141,7 @@ def search(): 'display.html', query=urlparse.unquote(q), search_type=search_type, + dark_mode=g.user_config.dark, response=formatted_results, search_header=render_template( 'header.html', diff --git a/app/static/css/search-dark.css b/app/static/css/search-dark.css new file mode 100644 index 0000000..2ac5b47 --- /dev/null +++ b/app/static/css/search-dark.css @@ -0,0 +1,35 @@ +.autocomplete { + position: relative; + display: inline-block; + width: 100%; +} + +.autocomplete-items { + position: absolute; + border: 1px solid #685e79; + border-bottom: none; + border-top: none; + z-index: 99; + + /*position the autocomplete items to be the same width as the container:*/ + top: 100%; + left: 0; + right: 0; +} + +.autocomplete-items div { + padding: 10px; + cursor: pointer; + color: #fff; + background-color: #000; + border-bottom: 1px solid #242424; +} + +.autocomplete-items div:hover { + background-color: #404040; +} + +.autocomplete-active { + background-color: #685e79 !important; + color: #ffffff; +} \ No newline at end of file diff --git a/app/templates/display.html b/app/templates/display.html index e66de6f..94ebed2 100644 --- a/app/templates/display.html +++ b/app/templates/display.html @@ -6,7 +6,7 @@ - + {{ query }} - Whoogle Search diff --git a/app/templates/index.html b/app/templates/index.html index b4edf12..9279031 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -21,7 +21,7 @@ - + Whoogle Search