diff options
| author | Alexandre Flament <alex@al-f.net> | 2019-07-16 11:08:36 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-16 11:08:36 +0200 |
| commit | ddee4861cee8d5b08e9219d4e727acc35fc3ca32 (patch) | |
| tree | 3ad42e60342e90d577c1f83c5e726665163a4a7d | |
| parent | f750df871318c435c40c7d910e5dcd47b350e73d (diff) | |
| parent | 4d38b8bef7de16f741d20839ee5d31a48d499f81 (diff) | |
Merge pull request #1630 from MarcAbonce/bang_fixes
[fix] Small fixes with bangs in queries
| -rw-r--r-- | searx/autocomplete.py | 4 | ||||
| -rw-r--r-- | searx/templates/oscar/results.html | 4 | ||||
| -rw-r--r-- | searx/webapp.py | 8 |
3 files changed, 12 insertions, 4 deletions
diff --git a/searx/autocomplete.py b/searx/autocomplete.py index f8a45b3ec..ff8958500 100644 --- a/searx/autocomplete.py +++ b/searx/autocomplete.py @@ -16,6 +16,7 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >. ''' +import sys from lxml import etree from json import loads from searx import settings @@ -26,6 +27,9 @@ from searx.engines import ( from searx.poolrequests import get as http_get from searx.url_utils import urlencode +if sys.version_info[0] == 3: + unicode = str + def get(*args, **kwargs): if 'timeout' not in kwargs: diff --git a/searx/templates/oscar/results.html b/searx/templates/oscar/results.html index ee1052dba..3a1f84067 100644 --- a/searx/templates/oscar/results.html +++ b/searx/templates/oscar/results.html @@ -21,7 +21,7 @@ <span class="result_header text-muted form-inline pull-left suggestion_item">{{ _('Try searching for:') }}</span>
{% for correction in corrections %}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" role="navigation" class="form-inline pull-left suggestion_item">
- <input type="hidden" name="q" value="{{ correction }}">
+ <input type="hidden" name="q" value="{{ query_prefix + correction }}">
<button type="submit" class="btn btn-default btn-xs">{{ correction }}</button>
</form>
{% endfor %}
@@ -118,7 +118,7 @@ <div class="panel-body">
{% for suggestion in suggestions %}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" role="navigation" class="form-inline pull-{% if rtl %}right{% else %}left{% endif %} suggestion_item">
- <input type="hidden" name="q" value="{{ suggestion }}">
+ <input type="hidden" name="q" value="{{ query_prefix + suggestion }}">
<button type="submit" class="btn btn-default btn-xs">{{ suggestion }}</button>
</form>
{% endfor %}
diff --git a/searx/webapp.py b/searx/webapp.py index 8290b6822..4c983509d 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -584,6 +584,7 @@ def index(): 'results.html', results=results, q=request.form['q'], + query_prefix=u''.join((request.form['q']).rsplit(search_query.query.decode('utf-8'), 1)), selected_categories=search_query.categories, pageno=search_query.pageno, time_range=search_query.time_range, @@ -636,8 +637,11 @@ def autocompleter(): # parse searx specific autocompleter results like !bang raw_results = searx_bang(raw_text_query) - # normal autocompletion results only appear if max 3 inner results returned - if len(raw_results) <= 3 and completer: + # normal autocompletion results only appear if no inner results returned + # and there is a query part besides the engine and language bangs + if len(raw_results) == 0 and completer and (len(raw_text_query.query_parts) > 1 or + (len(raw_text_query.languages) == 0 and + not raw_text_query.specific)): # get language from cookie language = request.preferences.get_value('language') if not language or language == 'all': |