From bc2d5bf88cd9a3ad5e19c380d3742fb63a2641e2 Mon Sep 17 00:00:00 2001 From: Cqoicebordel Date: Mon, 19 Jan 2015 19:47:32 +0100 Subject: [PATCH 1/2] Add '?' bang to the autocompleter --- searx/autocomplete.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/searx/autocomplete.py b/searx/autocomplete.py index 7ebebf1de..39b457298 100644 --- a/searx/autocomplete.py +++ b/searx/autocomplete.py @@ -35,13 +35,14 @@ def searx_bang(full_query): results = [] # check if current query stats with !bang - if full_query.getSearchQuery()[0] == '!': + first_char = full_query.getSearchQuery()[0] + if first_char == '!' or first_char == '?': if len(full_query.getSearchQuery()) == 1: # show some example queries # TODO, check if engine is not avaliable - results.append("!images") - results.append("!wikipedia") - results.append("!osm") + results.append(first_char + "images") + results.append(first_char + "wikipedia") + results.append(first_char + "osm") else: engine_query = full_query.getSearchQuery()[1:] @@ -61,7 +62,7 @@ def searx_bang(full_query): results.append('!{engine_shortcut}'.format(engine_shortcut=engine_shortcut)) # check if current query stats with :bang - elif full_query.getSearchQuery()[0] == ':': + elif first_char == ':': if len(full_query.getSearchQuery()) == 1: # show some example queries results.append(":en") From 4d0aeae567e19e68747fd2869741fee11a4df7c4 Mon Sep 17 00:00:00 2001 From: Cqoicebordel Date: Mon, 19 Jan 2015 22:17:12 +0100 Subject: [PATCH 2/2] Thanks @pointhi ! --- searx/autocomplete.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/searx/autocomplete.py b/searx/autocomplete.py index 39b457298..2777a0ca7 100644 --- a/searx/autocomplete.py +++ b/searx/autocomplete.py @@ -49,17 +49,17 @@ def searx_bang(full_query): # check if query starts with categorie name for categorie in categories: if categorie.startswith(engine_query): - results.append('!{categorie}'.format(categorie=categorie)) + results.append(first_char+'{categorie}'.format(categorie=categorie)) # check if query starts with engine name for engine in engines: if engine.startswith(engine_query.replace('_', ' ')): - results.append('!{engine}'.format(engine=engine.replace(' ', '_'))) + results.append(first_char+'{engine}'.format(engine=engine.replace(' ', '_'))) # check if query starts with engine shortcut for engine_shortcut in engine_shortcuts: if engine_shortcut.startswith(engine_query): - results.append('!{engine_shortcut}'.format(engine_shortcut=engine_shortcut)) + results.append(first_char+'{engine_shortcut}'.format(engine_shortcut=engine_shortcut)) # check if current query stats with :bang elif first_char == ':':