adds theme to routes and Index.html

This commit is contained in:
Alexandar Mechev 2020-10-05 17:20:06 +02:00
parent fbd14c0a55
commit 4d55a56189
No known key found for this signature in database
GPG Key ID: 1B754EA636091772
6 changed files with 48 additions and 29 deletions

View File

@ -15,6 +15,7 @@ class Filter:
self.near = config['near'] if 'near' in config else ''
self.dark = config['dark'] if 'dark' in config else False
self.nojs = config['nojs'] if 'nojs' in config else False
self.theme = config['theme'] if 'theme' in config else None
self.new_tab = config['new_tab'] if 'new_tab' in config else False
self.alt_redirect = config['alts'] if 'alts' in config else False
self.mobile = mobile
@ -35,7 +36,7 @@ class Filter:
pattern = re.compile('4285f4|ea4335|fbcc05|34a853|fbbc05', re.IGNORECASE)
page = pattern.sub('685e79', page)
if self.dark:
page = page.replace('fff', '000').replace('202124', 'ddd').replace('1967D2', '3b85ea')
page = page.replace('fff', '2E3440').replace('202124', 'ddd').replace('1967D2', '3b85ea')
return page

View File

@ -312,7 +312,7 @@ class Config:
self.dark = False
self.nojs = False
self.near = ''
self.theme = None
self.theme = 'whoogle'
self.alts = False
self.new_tab = False
self.get_only = False

View File

@ -59,7 +59,7 @@ def before_request_func():
if https_only and request.url.startswith('http://'):
return redirect(request.url.replace('http://', 'https://', 1), code=308)
g.user_config = Config(**session['config'])
if not g.user_config.url:
@ -104,6 +104,7 @@ def index():
return render_template('index.html',
languages=Config.LANGUAGES,
countries=Config.COUNTRIES,
themes=Config.THEMES,
config=g.user_config,
version_number=app.config['VERSION_NUMBER'])
@ -160,11 +161,13 @@ def search():
query=urlparse.unquote(query),
search_type=search_util.search_type,
dark_mode=g.user_config.dark,
theme=g.user_config.theme,
response=response,
version_number=app.config['VERSION_NUMBER'],
search_header=render_template(
'header.html',
dark_mode=g.user_config.dark,
theme=g.user_config.theme,
query=urlparse.unquote(query),
search_type=search_util.search_type,
mobile=g.user_request.mobile) if 'isch' not in search_util.search_type else '')

View File

@ -1,26 +1,33 @@
<html>
<head>
<link rel="shortcut icon" href="/static/img/favicon.ico" type="image/x-icon">
<link rel="icon" href="/static/img/favicon.ico" type="image/x-icon">
<link rel="search" href="/opensearch.xml" type="application/opensearchdescription+xml" title="Whoogle Search">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="referrer" content="no-referrer">
<script type="text/javascript" src="/static/js/autocomplete.js"></script>
<link rel="stylesheet" href="/static/css/{{ 'search-dark' if dark_mode else 'search' }}.css">
<link rel="stylesheet" href="/static/css/header.css">
{% if dark_mode %}
<link rel="stylesheet" href="/static/css/dark-theme.css"/>
{% endif %}
<title>{{ query }} - Whoogle Search</title>
</head>
<body>
<head>
<link rel="shortcut icon" href="/static/img/favicon.ico" type="image/x-icon">
<link rel="icon" href="/static/img/favicon.ico" type="image/x-icon">
<link rel="search" href="/opensearch.xml" type="application/opensearchdescription+xml" title="Whoogle Search">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="referrer" content="no-referrer">
<script type="text/javascript" src="/static/js/autocomplete.js"></script>
{% if theme %}
<link rel="stylesheet" href="/static/css/{{'theme/' if theme else ''}}{{ 'search-dark' if dark_mode else 'search' }}.css" />
{% else %}
<link rel="stylesheet" href="/static/css/{{ 'dark-' if dark_mode else '' }}theme.css" />
{% endif %}
<link rel="stylesheet" href="/static/css/{{ 'search-dark' if dark_mode else 'search' }}.css">
<link rel="stylesheet" href="/static/css/header.css">
{% if theme %}
<link rel="stylesheet" href="/static/css/themes/{{theme}}{{ '-dark' if dark_mode else '' }}.css" />
{% else %}
<link rel="stylesheet" href="/static/css/{{ 'dark-' if dark_mode else '' }}theme.css" />
{% endif %}
<title>{{ query }} - Whoogle Search</title>
</head>
<body>
{{ search_header|safe }}
{{ response|safe }}
</body>
<footer>
<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>
</body>
<footer>
<p style=" color: {{ '#ECEFF4' 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>
</html>

View File

@ -13,7 +13,7 @@
<div class="sbc esbc autocomplete">
<input id="search-bar" autocapitalize="none" autocomplete="off" class="noHIxc" name="q"
style="background-color: {{ '#000' if dark_mode else '#fff' }};
color: {{ '#685e79' if dark_mode else '#000' }};
color: {{ '#292E39' if dark_mode else '#000' }};
border: {{ '1px solid #685e79' if dark_mode else '' }}"
spellcheck="false" type="text" value="{{ query }}">
<input name="tbm" value="{{ search_type }}" style="display: none">

View File

@ -22,13 +22,21 @@
<script type="text/javascript" src="/static/js/controller.js"></script>
<link rel="search" href="/opensearch.xml" type="application/opensearchdescription+xml" title="Whoogle Search">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/static/css/{{ 'search-dark' if config.dark else 'search' }}.css">
<link rel="stylesheet" href="/static/css/main.css">
{% if config.dark %}
<link rel="stylesheet" href="/static/css/dark-theme.css"/>
{% if config['theme'] %}
<link rel="stylesheet"
href="/static/css/themes/{{config['theme']}}{{ '-search-dark' if config['dark'] else '-search' }}.css" />
{% else %}
<link rel="stylesheet" href="/static/css/{{ 'dark-' if config['dark'] else '' }}theme.css" />
{% endif %}
{% if config['theme'] %}
<link rel="stylesheet" href="/static/css/themes/{{config['theme']}}{{ '-dark' if config['dark'] else '' }}.css" />
{% else %}
<link rel="stylesheet" href="/static/css/{{ 'dark-' if config['dark'] else '' }}theme.css" />
{% endif %}
<title>Whoogle Search</title>
</head>
<body id="main" style="display: none; background-color: {{ '#ECEFF4' if config.dark else '#fff' }}">
<div class="search-container">
<img class="logo" src="/static/img/logo.png">