Add option to disable changing of configuration

This commit is contained in:
notangelmario 2021-04-22 10:37:48 +03:00
parent d2fac809ca
commit 447a415e16
4 changed files with 136 additions and 125 deletions

View File

@ -75,6 +75,12 @@
"value": "",
"required": false
},
"WHOOGLE_CONFIG_DISABLE_CHANGE": {
"description": "[CONFIG] Disable ability for client to change config (set to 1 or leave blank)",
"value": "",
"required": false
},
"WHOOGLE_CONFIG_DARK": {
"description": "[CONFIG] Enable dark mode (set to 1 or leave blank)",
"value": "",

View File

@ -129,6 +129,7 @@ def index():
logo=render_template(
'logo.html',
dark=g.user_config.dark),
config_disabled=os.getenv('WHOOGLE_CONFIG_DISABLE_CHANGE', ''),
config=g.user_config,
tor_available=int(os.environ.get('TOR_AVAILABLE')),
version_number=app.config['VERSION_NUMBER'])
@ -237,6 +238,7 @@ def search():
@app.route('/config', methods=['GET', 'POST', 'PUT'])
@auth_required
def config():
if os.getenv('WHOOGLE_CONFIG_DISABLE_CHANGE', '') != '':
if request.method == 'GET':
return json.dumps(g.user_config.__dict__)
elif request.method == 'PUT':

View File

@ -47,6 +47,7 @@
<input type="submit" id="search-submit" value="Search">
</div>
</form>
{% if config_disabled == '' %}
<br/>
<button id="config-collapsible" class="collapsible">Configuration</button>
<div class="content">
@ -142,6 +143,7 @@
</form>
</div>
</div>
{% endif %}
</div>
<footer>
<p style="color: {{ 'var(--whoogle-dark-text)' if config.dark else 'var(--whoogle-text)' }};">

View File

@ -15,6 +15,7 @@
#WHOOGLE_CONFIG_COUNTRY=countryUK # See app/static/settings/countries.json for values
#WHOOGLE_CONFIG_LANGUAGE=lang_en # See app/static/settings/languages.json for values
#WHOOGLE_CONFIG_DISABLE_CHANGE=1 # Disables changing of config from client
#WHOOGLE_CONFIG_DARK=1 # Dark mode
#WHOOGLE_CONFIG_SAFE=1 # Safe searches
#WHOOGLE_CONFIG_ALTS=1 # Use social media site alternatives