can choose themes in config

This commit is contained in:
Alexandar Mechev 2020-10-05 16:00:33 +02:00
parent 6a9e53b121
commit 2f3f5ef035
No known key found for this signature in database
GPG Key ID: 1B754EA636091772
2 changed files with 151 additions and 132 deletions

View File

@ -1,3 +1,6 @@
import os
class Config: class Config:
# Derived from here: # Derived from here:
# https://sites.google.com/site/tomihasa/google-language-codes#searchlanguage # https://sites.google.com/site/tomihasa/google-language-codes#searchlanguage
@ -297,6 +300,9 @@ class Config:
{'name': 'Zimbabwe', 'value': 'countryZW'} {'name': 'Zimbabwe', 'value': 'countryZW'}
] ]
THEMES = list(set([theme_name.split('-')[0]
for theme_name in os.listdir('app/static/css/themes/')]))
def __init__(self, **kwargs): def __init__(self, **kwargs):
self.url = '' self.url = ''
self.lang_search = '' self.lang_search = ''
@ -306,6 +312,7 @@ class Config:
self.dark = False self.dark = False
self.nojs = False self.nojs = False
self.near = '' self.near = ''
self.theme = None
self.alts = False self.alts = False
self.new_tab = False self.new_tab = False
self.get_only = False self.get_only = False

View File

@ -1,4 +1,5 @@
<html> <html>
<head> <head>
<link rel="apple-touch-icon" sizes="57x57" href="/static/img/favicon/apple-icon-57x57.png"> <link rel="apple-touch-icon" sizes="57x57" href="/static/img/favicon/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/static/img/favicon/apple-icon-60x60.png"> <link rel="apple-touch-icon" sizes="60x60" href="/static/img/favicon/apple-icon-60x60.png">
@ -28,7 +29,7 @@
{% endif %} {% endif %}
<title>Whoogle Search</title> <title>Whoogle Search</title>
</head> </head>
<body id="main" style="display: none; background-color: {{ '#000' if config.dark else '#fff' }}"> <body id="main" style="display: none; background-color: {{ '#ECEFF4' if config.dark 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="{{ 'get' if config.get_only else 'post' }}"> <form id="search-form" action="/search" method="{{ 'get' if config.get_only else 'post' }}">
@ -88,6 +89,16 @@
<label for="config-near">Near: </label> <label for="config-near">Near: </label>
<input type="text" name="near" id="config-near" placeholder="City Name"> <input type="text" name="near" id="config-near" placeholder="City Name">
</div> </div>
<div class="config-div">
<label for="config-theme">Theme: </label>
<select name="theme" id="config-theme">
{% for theme in themes %}
<option value="{{ theme }}" {% if theme in config.theme %} selected {% endif %}>
{{ theme }}
</option>
{% endfor %}
</select>
</div>
<div class="config-div"> <div class="config-div">
<label for="config-nojs">Show NoJS Links: </label> <label for="config-nojs">Show NoJS Links: </label>
<input type="checkbox" name="nojs" id="config-nojs"> <input type="checkbox" name="nojs" id="config-nojs">
@ -128,10 +139,11 @@
</div> </div>
</div> </div>
<footer> <footer>
<p style="color: {{ '#fff' if config.dark else '#000' }};"> <p style="color: {{ '#ECEFF4' if config.dark else '#000' }};">
Whoogle Search v{{ version_number }} || Whoogle Search v{{ version_number }} ||
<a style="color: #685e79" href="https://github.com/benbusby/whoogle-search">View on GitHub</a> <a style="color: #685e79" href="https://github.com/benbusby/whoogle-search">View on GitHub</a>
</p> </p>
</footer> </footer>
</body> </body>
</html> </html>