on master help sign in
Merge branch 'master' into feature/accessibility
commite9d90d06a9343bdfa26c6993bb3fcc3cf17ac3ac authorMathieu Brunot <mathieu.brunot@monogramm.io> dateTue 29 Oct 2019, 23:53 (7 years ago) parenta51b2b64e029b0
4 files changed+16−12
searx/plugins/tracker_url_remover.py+5−7 searx/templates/oscar/results.html+2−2 searx/templates/simple/results.html+2−2 searx/webapp.py+7−1
searx/plugins/tracker_url_remover.py+5−7
@@ -39,16 +39,14 @@ def on_result(request, search, result):
3939 return True
4040 parsed_query = parse_qsl(query)
4141
42− changed = False
42+ changes = 0
4343 for i, (param_name, _) in enumerate(list(parsed_query)):
4444 for reg in regexes:
4545 if reg.match(param_name):
46− parsed_query.pop(i)
47− changed = True
46+ parsed_query.pop(i - changes)
47+ changes += 1
48+ result['parsed_url'] = result['parsed_url']._replace(query=urlencode(parsed_query))
49+ result['url'] = urlunparse(result['parsed_url'])
4850 break
4951
50− if changed:
51− result['parsed_url'] = result['parsed_url']._replace(query=urlencode(parsed_query))
52− result['url'] = urlunparse(result['parsed_url'])
53−
5452 return True
searx/templates/oscar/results.html+2−2
@@ -22,8 +22,8 @@
2222 <span class="result_header text-muted form-inline pull-left suggestion_item">{{ _('Try searching for:') }}</span>
2323 {% for correction in corrections %}
2424 <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" role="navigation" class="form-inline pull-left suggestion_item">
25− <input type="hidden" name="q" value="{{ query_prefix + correction }}">
26− <button type="submit" class="btn btn-default btn-xs">{{ correction }}</button>
25+ <input type="hidden" name="q" value="{{ correction.url }}">
26+ <button type="submit" class="btn btn-default btn-xs">{{ correction.title }}</button>
2727 </form>
2828 {% endfor %}
2929 </div>
searx/templates/simple/results.html+2−2
@@ -95,13 +95,13 @@
9595 {% for correction in corrections %}
9696 <div class="left">
9797 <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" role="navigation">
98− <input type="hidden" name="q" value="{{ correction }}">
98+ <input type="hidden" name="q" value="{{ correction.url }}">
9999 <input type="hidden" name="time_range" value="{{ time_range }}">
100100 <input type="hidden" name="language" value="{{ current_language }}">
101101 <input type="hidden" name="safesearch" value="{{ safesearch }}">
102102 <input type="hidden" name="theme" value="{{ theme }}">
103103 {% if timeout_limit %}<input type="hidden" name="timeout_limit" value="{{ timeout_limit }}" >{% endif %}
104− <input type="submit" value="{{ correction }}">
104+ <input type="submit" value="{{ correction.title }}">
105105 </form>
106106 </div>
107107 {% endfor %}
searx/webapp.py+7−1
@@ -610,6 +610,12 @@ def index():
610610 'title': suggestion
611611 },
612612 result_container.suggestions)
613+
614+ correction_urls = list(map(lambda correction: {
615+ 'url': raw_text_query.changeSearchQuery(correction).getFullQuery(),
616+ 'title': correction
617+ },
618+ result_container.corrections))
613619 #
614620 return render(
615621 'results.html',
@@ -622,7 +628,7 @@ def index():
622628 advanced_search=advanced_search,
623629 suggestions=suggestion_urls,
624630 answers=result_container.answers,
625− corrections=result_container.corrections,
631+ corrections=correction_urls,
626632 infoboxes=result_container.infoboxes,
627633 paging=result_container.paging,
628634 unresponsive_engines=result_container.unresponsive_engines,