logo

searx

My custom branche(s) on searx, a meta-search engine
commit: f6b42204148ad3f49165174ef5124090d30f7350
parent: 0ff7a1db29a3543d295da3c33a1824277ed73d39
Author: Adam Tauber <asciimoo@gmail.com>
Date:   Tue, 20 Jan 2015 13:41:07 +0100

Merge pull request #186 from Cqoicebordel/add-bang-autocompletion

Add '?' bang to the autocompleter

Diffstat:

Msearx/autocomplete.py17+++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/searx/autocomplete.py b/searx/autocomplete.py @@ -35,33 +35,34 @@ 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:] # 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 full_query.getSearchQuery()[0] == ':': + elif first_char == ':': if len(full_query.getSearchQuery()) == 1: # show some example queries results.append(":en")