From 8d71420b4511fdac63c39f33d93c7add1ea7716d Mon Sep 17 00:00:00 2001 From: Marc Abonce Seguin Date: Mon, 29 Jul 2019 21:25:05 -0700 Subject: [PATCH] [mod] separate index and search routes This makes it easier to separately handle search and index requests from a web server or from a reverse proxy. If a request to index contains a query, a permanent redirect HTTP response is returned. This should give some level of backwards compatibility for users that have set a searx instance in their browser's search bar. --- searx/static/plugins/js/infinite_scroll.js | 2 +- searx/templates/__common__/opensearch.xml | 4 ++-- .../__common__/opensearch_response_rss.xml | 2 +- searx/templates/courgette/results.html | 12 ++++++------ searx/templates/courgette/search.html | 4 ++-- searx/templates/legacy/infobox.html | 2 +- searx/templates/legacy/results.html | 12 ++++++------ searx/templates/legacy/search.html | 2 +- searx/templates/oscar/results.html | 16 ++++++++-------- searx/templates/oscar/search.html | 2 +- searx/templates/oscar/search_full.html | 2 +- searx/templates/pix-art/search.html | 2 +- searx/templates/simple/infobox.html | 2 +- searx/templates/simple/results.html | 14 +++++++------- searx/templates/simple/search.html | 2 +- searx/webapp.py | 16 ++++++++++++++-- tests/unit/test_webapp.py | 16 ++++++++++++++++ 17 files changed, 70 insertions(+), 42 deletions(-) diff --git a/searx/static/plugins/js/infinite_scroll.js b/searx/static/plugins/js/infinite_scroll.js index 9930880e3..cd8096571 100644 --- a/searx/static/plugins/js/infinite_scroll.js +++ b/searx/static/plugins/js/infinite_scroll.js @@ -9,7 +9,7 @@ function loadNextPage() { $('#pagination').html('
'); $.ajax({ type: "POST", - url: './', + url: $('#search_form').prop('action'), data: formData, dataType: 'html', success: function(data) { diff --git a/searx/templates/__common__/opensearch.xml b/searx/templates/__common__/opensearch.xml index e76a14aff..2476258c0 100644 --- a/searx/templates/__common__/opensearch.xml +++ b/searx/templates/__common__/opensearch.xml @@ -6,9 +6,9 @@ {{ urljoin(host, url_for('static', filename='img/favicon.png')) }} searx metasearch {% if opensearch_method == 'get' %} - + {% else %} - + {% endif %} diff --git a/searx/templates/__common__/opensearch_response_rss.xml b/searx/templates/__common__/opensearch_response_rss.xml index 686443c49..82d3f7c4e 100644 --- a/searx/templates/__common__/opensearch_response_rss.xml +++ b/searx/templates/__common__/opensearch_response_rss.xml @@ -4,7 +4,7 @@ xmlns:atom="http://www.w3.org/2005/Atom"> Searx search: {{ q|e }} - {{ base_url }}?q={{ q|e }} + {{ url_for('search', _external=True) }}?q={{ q|e }} Search results for "{{ q|e }}" - searx {{ number_of_results }} 1 diff --git a/searx/templates/courgette/results.html b/searx/templates/courgette/results.html index aa983e666..716ea4d95 100644 --- a/searx/templates/courgette/results.html +++ b/searx/templates/courgette/results.html @@ -1,6 +1,6 @@ {% extends "courgette/base.html" %} {% block title %}{{ q|e }} - {% endblock %} -{% block meta %}{% endblock %} +{% block meta %}{% endblock %} {% block content %}