Merge branch 'develop' of github.com:benbusby/whoogle-search into develop
commit
4577c11d4c
|
@ -2,6 +2,7 @@ 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
|
||||||
LANGUAGES = [
|
LANGUAGES = [
|
||||||
|
{'name': 'Default (use server location)', 'value': ''},
|
||||||
{'name': 'English', 'value': 'lang_en'},
|
{'name': 'English', 'value': 'lang_en'},
|
||||||
{'name': 'Afrikaans', 'value': 'lang_af'},
|
{'name': 'Afrikaans', 'value': 'lang_af'},
|
||||||
{'name': 'Arabic', 'value': 'lang_ar'},
|
{'name': 'Arabic', 'value': 'lang_ar'},
|
||||||
|
@ -298,7 +299,8 @@ class Config:
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.url = ''
|
self.url = ''
|
||||||
self.lang = 'lang_en'
|
self.lang_search = ''
|
||||||
|
self.lang_interface = ''
|
||||||
self.ctry = ''
|
self.ctry = ''
|
||||||
self.safe = False
|
self.safe = False
|
||||||
self.dark = False
|
self.dark = False
|
||||||
|
|
|
@ -66,10 +66,10 @@ def gen_query(query, args, config, near_city=None):
|
||||||
param_dict['source'] = '&source=' + args.get('source')
|
param_dict['source'] = '&source=' + args.get('source')
|
||||||
param_dict['lr'] = ('&lr=' + ''.join([_ for _ in sub_lang if not _.isdigit()])) if sub_lang else ''
|
param_dict['lr'] = ('&lr=' + ''.join([_ for _ in sub_lang if not _.isdigit()])) if sub_lang else ''
|
||||||
else:
|
else:
|
||||||
param_dict['lr'] = '&lr=' + config.lang
|
param_dict['lr'] = ('&lr=' + config.lang_search) if config.lang_search else ''
|
||||||
|
|
||||||
param_dict['cr'] = ('&cr=' + config.ctry) if config.ctry else ''
|
param_dict['cr'] = ('&cr=' + config.ctry) if config.ctry else ''
|
||||||
param_dict['hl'] = '&hl=' + config.lang.replace('lang_', '')
|
param_dict['hl'] = ('&hl=' + config.lang_interface.replace('lang_', '')) if config.lang_interface else ''
|
||||||
param_dict['safe'] = '&safe=' + ('active' if config.safe else 'off')
|
param_dict['safe'] = '&safe=' + ('active' if config.safe else 'off')
|
||||||
|
|
||||||
for val in param_dict.values():
|
for val in param_dict.values():
|
||||||
|
|
|
@ -65,7 +65,7 @@ def before_request_func():
|
||||||
if not g.user_config.url:
|
if not g.user_config.url:
|
||||||
g.user_config.url = request.url_root.replace('http://', 'https://') if https_only else request.url_root
|
g.user_config.url = request.url_root.replace('http://', 'https://') if https_only else request.url_root
|
||||||
|
|
||||||
g.user_request = Request(request.headers.get('User-Agent'), language=g.user_config.lang)
|
g.user_request = Request(request.headers.get('User-Agent'), language=g.user_config.lang_search)
|
||||||
g.app_location = g.user_config.url
|
g.app_location = g.user_config.url
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,11 +55,24 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="config-div">
|
<div class="config-div">
|
||||||
<label for="config-lang">Language: </label>
|
<label for="config-lang-interface">Interface Language: </label>
|
||||||
<select name="lang" id="config-lang">
|
<select name="lang_interface" id="config-lang-interface">
|
||||||
{% for lang in languages %}
|
{% for lang in languages %}
|
||||||
<option value="{{ lang.value }}"
|
<option value="{{ lang.value }}"
|
||||||
{% if lang.value in config.lang %}
|
{% if lang.value in config.lang_interface %}
|
||||||
|
selected
|
||||||
|
{% endif %}>
|
||||||
|
{{ lang.name }}
|
||||||
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="config-div">
|
||||||
|
<label for="config-lang-search">Search Language: </label>
|
||||||
|
<select name="lang_search" id="config-lang-search">
|
||||||
|
{% for lang in languages %}
|
||||||
|
<option value="{{ lang.value }}"
|
||||||
|
{% if lang.value in config.lang_search %}
|
||||||
selected
|
selected
|
||||||
{% endif %}>
|
{% endif %}>
|
||||||
{{ lang.name }}
|
{{ lang.name }}
|
||||||
|
|
|
@ -6,7 +6,8 @@ demo_config = {
|
||||||
'near': random.choice(['Seattle', 'New York', 'San Francisco']),
|
'near': random.choice(['Seattle', 'New York', 'San Francisco']),
|
||||||
'dark_mode': str(random.getrandbits(1)),
|
'dark_mode': str(random.getrandbits(1)),
|
||||||
'nojs': str(random.getrandbits(1)),
|
'nojs': str(random.getrandbits(1)),
|
||||||
'lang': random.choice(Config.LANGUAGES)['value'],
|
'lang_interface': random.choice(Config.LANGUAGES)['value'],
|
||||||
|
'lang_search': random.choice(Config.LANGUAGES)['value'],
|
||||||
'ctry': random.choice(Config.COUNTRIES)['value']
|
'ctry': random.choice(Config.COUNTRIES)['value']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue