Fixed config bug in filter, updated run script to work on mac os

main
Ben Busby 2020-04-16 18:50:31 -06:00
parent 2631335dbf
commit 6a150092a2
2 changed files with 7 additions and 8 deletions

View File

@ -9,8 +9,8 @@ class Filter:
if config is None: if config is None:
config = {} config = {}
self.near_city = config['near'] if 'near' in config else None self.near = config['near'] if 'near' in config else None
self.dark_mode = config['dark_mode'] if 'dark_mode' in config else False self.dark = config['dark'] if 'dark' in config else False
self.nojs = config['nojs'] if 'nojs' in config else False self.nojs = config['nojs'] if 'nojs' in config else False
self.mobile = mobile self.mobile = mobile
@ -19,7 +19,7 @@ class Filter:
page = page.replace('>G<', '>Sh<') page = page.replace('>G<', '>Sh<')
pattern = re.compile('4285f4|ea4335|fbcc05|34a853|fbbc05', re.IGNORECASE) pattern = re.compile('4285f4|ea4335|fbcc05|34a853|fbbc05', re.IGNORECASE)
page = pattern.sub('685e79', page) page = pattern.sub('685e79', page)
if self.dark_mode: if self.dark:
page = page.replace('fff', '000').replace('202124', 'ddd').replace('1967D2', '3b85ea') page = page.replace('fff', '000').replace('202124', 'ddd').replace('1967D2', '3b85ea')
return page return page
@ -47,8 +47,8 @@ class Filter:
# Grab city from config, if available # Grab city from config, if available
near = '' near = ''
if self.near_city: if self.near:
near = '&near=' + urlparse.quote(self.near_city) near = '&near=' + urlparse.quote(self.near)
return q + tbs + tbm + start + near return q + tbs + tbm + start + near
@ -98,7 +98,7 @@ class Filter:
a.append(nojs_link) a.append(nojs_link)
# Set up dark mode if active # Set up dark mode if active
if self.dark_mode: if self.dark:
soup.find('html')['style'] = 'scrollbar-color: #333 #111;' soup.find('html')['style'] = 'scrollbar-color: #333 #111;'
for input_element in soup.findAll('input'): for input_element in soup.findAll('input'):
input_element['style'] = 'color:#fff;' input_element['style'] = 'color:#fff;'

3
run
View File

@ -3,8 +3,7 @@
# ./run # Runs the full web app # ./run # Runs the full web app
# ./run test # Runs the testing suite # ./run test # Runs the testing suite
SCRIPT=`realpath $0` SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
SCRIPT_DIR=`dirname $SCRIPT`
# Set default port if unavailable # Set default port if unavailable
if [[ -z "${PORT}" ]]; then if [[ -z "${PORT}" ]]; then