Merge remote-tracking branch 'origin/master' into heroku-app

This commit is contained in:
Ben Busby 2020-05-25 10:54:31 -06:00
commit 176c96374c
3 changed files with 17 additions and 5 deletions

View File

@ -61,9 +61,8 @@ def unknown_page(e):
@app.route('/', methods=['GET']) @app.route('/', methods=['GET'])
@auth_required @auth_required
def index(): def index():
bg = '#000' if g.user_config.dark else '#fff'
return render_template('index.html', return render_template('index.html',
bg=bg, dark_mode=g.user_config.dark,
ua=g.user_request.modified_user_agent, ua=g.user_request.modified_user_agent,
languages=Config.LANGUAGES, languages=Config.LANGUAGES,
countries=Config.COUNTRIES, countries=Config.COUNTRIES,
@ -137,14 +136,20 @@ def search():
else: else:
formatted_results = content_filter.clean(dirty_soup) formatted_results = content_filter.clean(dirty_soup)
# Set search type to be used in the header template to allow for repeated searches
# in the same category
search_type = request_params.get('tbm') if 'tbm' in request_params else ''
return render_template( return render_template(
'display.html', 'display.html',
query=urlparse.unquote(q), query=urlparse.unquote(q),
search_type=search_type,
response=formatted_results, response=formatted_results,
search_header=render_template( search_header=render_template(
'header.html', 'header.html',
q=urlparse.unquote(q), q=urlparse.unquote(q),
mobile=g.user_request.mobile)) search_type=search_type,
mobile=g.user_request.mobile) if 'isch' not in search_type else '')
@app.route('/config', methods=['GET', 'POST']) @app.route('/config', methods=['GET', 'POST'])

View File

@ -13,6 +13,7 @@
<div class="sbc esbc autocomplete"> <div class="sbc esbc autocomplete">
<input id="search-bar" autocapitalize="none" autocomplete="off" class="noHIxc" name="q" <input id="search-bar" autocapitalize="none" autocomplete="off" class="noHIxc" name="q"
spellcheck="false" type="text" value="{{ q }}"> spellcheck="false" type="text" value="{{ q }}">
<input name="tbm" value="{{ search_type }}" style="display: none">
<div class="sc"></div> <div class="sc"></div>
</div> </div>
</div> </div>
@ -34,6 +35,7 @@
<div style="width: 100%; display: flex"> <div style="width: 100%; display: flex">
<input id="search-bar" autocapitalize="none" autocomplete="off" class="noHIxc" name="q" <input id="search-bar" autocapitalize="none" autocomplete="off" class="noHIxc" name="q"
spellcheck="false" type="text" value="{{ q }}"> spellcheck="false" type="text" value="{{ q }}">
<input name="tbm" value="{{ search_type }}" style="display: none">
<div class="sc"></div> <div class="sc"></div>
</div> </div>
</div> </div>
@ -48,6 +50,8 @@
searchBar.addEventListener("keyup", function (event) { searchBar.addEventListener("keyup", function (event) {
if (event.keyCode !== 13) { if (event.keyCode !== 13) {
handleUserInput(searchBar); handleUserInput(searchBar);
} else {
document.getElementById("search-form").submit();
} }
}); });
</script> </script>

View File

@ -25,7 +25,7 @@
<link rel="stylesheet" href="/static/css/main.css"> <link rel="stylesheet" href="/static/css/main.css">
<title>Whoogle Search</title> <title>Whoogle Search</title>
</head> </head>
<body id="main" style="display: none; background-color: {{ bg }}"> <body id="main" style="display: none; background-color: {{ '#000' if dark_mode else '#fff' }}">
<div class="search-container"> <div class="search-container">
<img class="logo" src="/static/img/logo.png"> <img class="logo" src="/static/img/logo.png">
<form id="search-form" action="/search" method="{{ request_type }}"> <form id="search-form" action="/search" method="{{ request_type }}">
@ -107,7 +107,10 @@
</div> </div>
</div> </div>
<footer> <footer>
<p>Whoogle Search v{{ version_number }} || <a href="https://github.com/benbusby/whoogle-search">View on GitHub</a></p> <p style="color: {{ '#fff' if dark_mode else '#000' }};">
Whoogle Search v{{ version_number }} ||
<a style="color: #685e79" href="https://github.com/benbusby/whoogle-search">View on GitHub</a>
</p>
</footer> </footer>
</body> </body>
</html> </html>