forked from Ponysearch/Ponysearch
forward category to engine without highlighting on the ui
This commit is contained in:
parent
d04e471ce5
commit
8cc529e9a3
3 changed files with 19 additions and 11 deletions
|
@ -33,12 +33,8 @@ type_map = {
|
||||||
|
|
||||||
|
|
||||||
def request(query, params):
|
def request(query, params):
|
||||||
category = 'general'
|
|
||||||
if 'category' in params and len(params['category']) == 1:
|
|
||||||
category = params['category'][0]
|
|
||||||
|
|
||||||
params['url'] = search_url.format(
|
params['url'] = search_url.format(
|
||||||
category=type_map[category],
|
category=type_map[params['category']],
|
||||||
q=urlencode({
|
q=urlencode({
|
||||||
'q': query,
|
'q': query,
|
||||||
'page': params['pageno']
|
'page': params['pageno']
|
||||||
|
|
|
@ -107,14 +107,21 @@ class RawTextQuery(object):
|
||||||
# check if prefix is equal with engine shortcut
|
# check if prefix is equal with engine shortcut
|
||||||
if prefix in engine_shortcuts:
|
if prefix in engine_shortcuts:
|
||||||
parse_next = True
|
parse_next = True
|
||||||
self.engines.append({'category': 'none',
|
engine_name = engine_shortcuts[prefix]
|
||||||
'name': engine_shortcuts[prefix]})
|
if engine_name in engines:
|
||||||
|
for engine_category in engines[engine_name].categories:
|
||||||
|
self.engines.append({'category': engine_category,
|
||||||
|
'name': engine_name,
|
||||||
|
'from_bang': True})
|
||||||
|
|
||||||
# check if prefix is equal with engine name
|
# check if prefix is equal with engine name
|
||||||
elif prefix in engines:
|
elif prefix in engines:
|
||||||
parse_next = True
|
parse_next = True
|
||||||
self.engines.append({'category': 'none',
|
if prefix in engines:
|
||||||
'name': prefix})
|
for engine_category in engines[engine_name].categories:
|
||||||
|
self.engines.append({'category': engine_category,
|
||||||
|
'name': engine_name,
|
||||||
|
'from_bang': True})
|
||||||
|
|
||||||
# check if prefix is equal with categorie name
|
# check if prefix is equal with categorie name
|
||||||
elif prefix in categories:
|
elif prefix in categories:
|
||||||
|
|
|
@ -258,8 +258,13 @@ def get_search_query_from_webapp(preferences, form):
|
||||||
# if engines are calculated from query,
|
# if engines are calculated from query,
|
||||||
# set categories by using that informations
|
# set categories by using that informations
|
||||||
if query_engines and raw_text_query.specific:
|
if query_engines and raw_text_query.specific:
|
||||||
query_categories = list(set(engine['category']
|
additional_categories = set()
|
||||||
for engine in query_engines))
|
for engine in query_engines:
|
||||||
|
if 'from_bang' in engine and engine['from_bang']:
|
||||||
|
additional_categories.add('none')
|
||||||
|
else:
|
||||||
|
additional_categories.add(engine['category'])
|
||||||
|
query_categories = list(additional_categories)
|
||||||
|
|
||||||
# otherwise, using defined categories to
|
# otherwise, using defined categories to
|
||||||
# calculate which engines should be used
|
# calculate which engines should be used
|
||||||
|
|
Loading…
Reference in a new issue