Skip loading autocomplete.js if `WHOOGLE_AUTOCOMPLETE=0` (#611)
Bypasses autocomplete.js if `WHOOGLE_AUTOCOMPLETE` is set to 0main
parent
4dd01cdfda
commit
257e3f33ef
|
@ -37,6 +37,9 @@ newest_version = int(''.join(filter(str.isdigit, newest_version)))
|
||||||
newest_version = '' if current_version >= newest_version \
|
newest_version = '' if current_version >= newest_version \
|
||||||
else newest_version
|
else newest_version
|
||||||
|
|
||||||
|
ac_var = 'WHOOGLE_AUTOCOMPLETE'
|
||||||
|
autocomplete_enabled = os.getenv(ac_var, '1')
|
||||||
|
|
||||||
|
|
||||||
def auth_required(f):
|
def auth_required(f):
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
|
@ -201,6 +204,7 @@ def index():
|
||||||
languages=app.config['LANGUAGES'],
|
languages=app.config['LANGUAGES'],
|
||||||
countries=app.config['COUNTRIES'],
|
countries=app.config['COUNTRIES'],
|
||||||
themes=app.config['THEMES'],
|
themes=app.config['THEMES'],
|
||||||
|
autocomplete_enabled=autocomplete_enabled,
|
||||||
translation=app.config['TRANSLATIONS'][
|
translation=app.config['TRANSLATIONS'][
|
||||||
g.user_config.get_localization_lang()
|
g.user_config.get_localization_lang()
|
||||||
],
|
],
|
||||||
|
@ -246,7 +250,6 @@ def search_html():
|
||||||
|
|
||||||
@app.route(f'/{Endpoint.autocomplete}', methods=['GET', 'POST'])
|
@app.route(f'/{Endpoint.autocomplete}', methods=['GET', 'POST'])
|
||||||
def autocomplete():
|
def autocomplete():
|
||||||
ac_var = 'WHOOGLE_AUTOCOMPLETE'
|
|
||||||
if os.getenv(ac_var) and not read_config_bool(ac_var):
|
if os.getenv(ac_var) and not read_config_bool(ac_var):
|
||||||
return jsonify({})
|
return jsonify({})
|
||||||
|
|
||||||
|
@ -344,6 +347,7 @@ def search():
|
||||||
query=urlparse.unquote(query),
|
query=urlparse.unquote(query),
|
||||||
search_type=search_util.search_type,
|
search_type=search_util.search_type,
|
||||||
config=g.user_config,
|
config=g.user_config,
|
||||||
|
autocomplete_enabled=autocomplete_enabled,
|
||||||
lingva_url=app.config['TRANSLATE_URL'],
|
lingva_url=app.config['TRANSLATE_URL'],
|
||||||
translation=translation,
|
translation=translation,
|
||||||
translate_to=translate_to,
|
translate_to=translate_to,
|
||||||
|
|
|
@ -35,7 +35,9 @@
|
||||||
{{ response|safe }}
|
{{ response|safe }}
|
||||||
</body>
|
</body>
|
||||||
{% include 'footer.html' %}
|
{% include 'footer.html' %}
|
||||||
<script src="{{ cb_url('autocomplete.js') }}"></script>
|
{% if autocomplete_enabled == '1' %}
|
||||||
|
<script src="{{ cb_url('autocomplete.js') }}"></script>
|
||||||
|
{% endif %}
|
||||||
<script src="{{ cb_url('utils.js') }}"></script>
|
<script src="{{ cb_url('utils.js') }}"></script>
|
||||||
<script src="{{ cb_url('keyboard.js') }}"></script>
|
<script src="{{ cb_url('keyboard.js') }}"></script>
|
||||||
<script src="{{ cb_url('currency.js') }}"></script>
|
<script src="{{ cb_url('currency.js') }}"></script>
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
<meta name="referrer" content="no-referrer">
|
<meta name="referrer" content="no-referrer">
|
||||||
<meta name="msapplication-TileColor" content="#ffffff">
|
<meta name="msapplication-TileColor" content="#ffffff">
|
||||||
<meta name="msapplication-TileImage" content="static/img/favicon/ms-icon-144x144.png">
|
<meta name="msapplication-TileImage" content="static/img/favicon/ms-icon-144x144.png">
|
||||||
<script type="text/javascript" src="{{ cb_url('autocomplete.js') }}"></script>
|
{% if autocomplete_enabled == '1' %}
|
||||||
|
<script src="{{ cb_url('autocomplete.js') }}"></script>
|
||||||
|
{% endif %}
|
||||||
<script type="text/javascript" src="{{ cb_url('controller.js') }}"></script>
|
<script type="text/javascript" src="{{ cb_url('controller.js') }}"></script>
|
||||||
<link rel="search" href="opensearch.xml" type="application/opensearchdescription+xml" title="Whoogle Search">
|
<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="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
Loading…
Reference in New Issue