Skip to content

Commit

Permalink
Merge pull request searx#1681 from MarcAbonce/index_refactor
Browse files Browse the repository at this point in the history
[mod] Separate index and search routes
  • Loading branch information
asciimoo authored Nov 3, 2020
2 parents 45f58a4 + 8d71420 commit 9c3382d
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 42 deletions.
2 changes: 1 addition & 1 deletion searx/static/plugins/js/infinite_scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function loadNextPage() {
$('#pagination').html('<div class="loading-spinner"></div>');
$.ajax({
type: "POST",
url: './',
url: $('#search_form').prop('action'),
data: formData,
dataType: 'html',
success: function(data) {
Expand Down
4 changes: 2 additions & 2 deletions searx/templates/__common__/opensearch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<Image>{{ urljoin(host, url_for('static', filename='img/favicon.png')) }}</Image>
<LongName>searx metasearch</LongName>
{% if opensearch_method == 'get' %}
<Url rel="results" type="text/html" method="get" template="{{ host }}?q={searchTerms}"/>
<Url rel="results" type="text/html" method="get" template="{{ url_for('search', _external=True) }}?q={searchTerms}"/>
{% else %}
<Url rel="results" type="text/html" method="post" template="{{ host }}">
<Url rel="results" type="text/html" method="post" template="{{ url_for('search', _external=True) }}">
<Param name="q" value="{searchTerms}" />
</Url>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion searx/templates/__common__/opensearch_response_rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Searx search: {{ q|e }}</title>
<link>{{ base_url }}?q={{ q|e }}</link>
<link>{{ url_for('search', _external=True) }}?q={{ q|e }}</link>
<description>Search results for "{{ q|e }}" - searx</description>
<opensearch:totalResults>{{ number_of_results }}</opensearch:totalResults>
<opensearch:startIndex>1</opensearch:startIndex>
Expand Down
12 changes: 6 additions & 6 deletions searx/templates/courgette/results.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "courgette/base.html" %}
{% block title %}{{ q|e }} - {% endblock %}
{% block meta %}<link rel="alternate" type="application/rss+xml" title="Searx search: {{ q|e }}" href="{{ url_for('index') }}?q={{ q|urlencode }}&amp;format=rss&amp;{% for category in selected_categories %}category_{{ category }}=1&amp;{% endfor %}pageno={{ pageno }}">{% endblock %}
{% block meta %}<link rel="alternate" type="application/rss+xml" title="Searx search: {{ q|e }}" href="{{ url_for('search', _external=True) }}?q={{ q|urlencode }}&amp;format=rss&amp;{% for category in selected_categories %}category_{{ category }}=1&amp;{% endfor %}pageno={{ pageno }}">{% endblock %}
{% block content %}
<div class="right"><a href="{{ url_for('preferences') }}" id="preferences"><span>{{ _('preferences') }}</span></a></div>
<div class="small search center">
Expand All @@ -10,12 +10,12 @@
<div id="sidebar">
<div id="search_url">
{{ _('Search URL') }}:
<input type="text" value="{{ base_url }}?q={{ q|urlencode }}{% if selected_categories %}&amp;categories={{ selected_categories|join(",") | replace(' ','+') }}{% endif %}{% if pageno > 1 %}&amp;pageno={{ pageno }}{% endif %}" readonly />
<input type="text" value="{{ url_for('search', _external=True) }}?q={{ q|urlencode }}{% if selected_categories %}&amp;categories={{ selected_categories|join(",") | replace(' ','+') }}{% endif %}{% if pageno > 1 %}&amp;pageno={{ pageno }}{% endif %}" readonly />
</div>
<div id="apis">
{{ _('Download results') }}<br />
{% for output_type in ('csv', 'json', 'rss') %}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}">
<div class="left">
<input type="hidden" name="q" value="{{ q|e }}" />
<input type="hidden" name="format" value="{{ output_type }}" />
Expand All @@ -41,7 +41,7 @@
{% if suggestions %}
<div id="suggestions"><span>{{ _('Suggestions') }}</span>
{% for suggestion in suggestions %}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}">
<input type="hidden" name="q" value="{{ suggestion.url }}">
<input type="submit" value="{{ suggestion.title }}" />
</form>
Expand All @@ -60,7 +60,7 @@
{% if paging %}
<div id="pagination">
{% if pageno > 1 %}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}">
<div class="left">
<input type="hidden" name="q" value="{{ q|e }}" />
{% for category in selected_categories %}
Expand All @@ -71,7 +71,7 @@
</div>
</form>
{% endif %}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}">
<div class="left">
{% for category in selected_categories %}
<input type="hidden" name="category_{{ category }}" value="1"/>
Expand Down
4 changes: 2 additions & 2 deletions searx/templates/courgette/search.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" id="search_form">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" id="search_form">
<div id="search_wrapper">
<input type="text" autofocus placeholder="{{ _('Search for...') }}" id="q" class="q" name="q" tabindex="1" autocomplete="off" {% if q %}value="{{ q }}"{% endif %}/>
<input type="submit" value="search" id="search_submit" />
</div>
{% include 'courgette/categories.html' %}
</form>
</form>
2 changes: 1 addition & 1 deletion searx/templates/legacy/infobox.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h2><bdi>{{ infobox.infobox }}</bdi></h2>
<div>
<h3><bdi>{{ topic.name }}</bdi></h3>
{% for suggestion in topic.suggestions %}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}">
<input type="hidden" name="q" value="{{ suggestion }}">
<input type="submit" value="{{ suggestion }}" />
</form>
Expand Down
12 changes: 6 additions & 6 deletions searx/templates/legacy/results.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "legacy/base.html" %}
{% block title %}{{ q|e }} - {% endblock %}
{% block meta %}<link rel="alternate" type="application/rss+xml" title="Searx search: {{ q|e }}" href="{{ url_for('index') }}?q={{ q|urlencode }}&amp;format=rss&amp;{% for category in selected_categories %}category_{{ category }}=1&amp;{% endfor %}pageno={{ pageno }}">{% endblock %}
{% block meta %}<link rel="alternate" type="application/rss+xml" title="Searx search: {{ q|e }}" href="{{ url_for('search', _external=True) }}?q={{ q|urlencode }}&amp;format=rss&amp;{% for category in selected_categories %}category_{{ category }}=1&amp;{% endfor %}pageno={{ pageno }}">{% endblock %}
{% block content %}
<div class="preferences_container right"><a href="{{ url_for('preferences') }}" id="preferences"><span>preferences</span></a></div>
<div class="small search center">
Expand All @@ -11,12 +11,12 @@

<div id="search_url">
{{ _('Search URL') }}:
<input type="text" value="{{ base_url }}?q={{ q|urlencode }}{% if selected_categories %}&amp;categories={{ selected_categories|join(",") | replace(' ','+') }}{% endif %}{% if pageno > 1 %}&amp;pageno={{ pageno }}{% endif %}" readonly />
<input type="text" value="{{ url_for('search', _external=True) }}?q={{ q|urlencode }}{% if selected_categories %}&amp;categories={{ selected_categories|join(",") | replace(' ','+') }}{% endif %}{% if pageno > 1 %}&amp;pageno={{ pageno }}{% endif %}" readonly />
</div>
<div id="apis">
{{ _('Download results') }}
{% for output_type in ('csv', 'json', 'rss') %}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}">
<div class="left">
<input type="hidden" name="q" value="{{ q|e }}" />
<input type="hidden" name="format" value="{{ output_type }}" />
Expand Down Expand Up @@ -47,7 +47,7 @@
<div id="suggestions"><span id="suggestions-title">{{ _('Suggestions') }} : </span>
{% set first = true %}
{% for suggestion in suggestions %}
{% if not first %} &bull; {% endif %}<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
{% if not first %} &bull; {% endif %}<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}">
<input type="hidden" name="q" value="{{ suggestion.url }}">
<input type="submit" class="suggestion" value="{{ suggestion.title }}" />
</form>
Expand Down Expand Up @@ -75,7 +75,7 @@
{% if paging %}
<div id="pagination">
{% if pageno > 1 %}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}">
<div class="{% if rtl %}right{% else %}left{% endif %}">
<input type="hidden" name="q" value="{{ q|e }}" />
{% for category in selected_categories %}
Expand All @@ -86,7 +86,7 @@
</div>
</form>
{% endif %}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}">
<div class="{% if rtl %}left{% else %}right{% endif %}">
{% for category in selected_categories %}
<input type="hidden" name="category_{{ category }}" value="1"/>
Expand Down
2 changes: 1 addition & 1 deletion searx/templates/legacy/search.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" id="search_form">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" id="search_form">
<div id="search_wrapper">
<input type="text" autofocus placeholder="{{ _('Search for...') }}" id="q" class="q" name="q" tabindex="1" autocomplete="off" size="100" {% if q %}value="{{ q }}"{% endif %}/>
<input type="submit" value="search" id="search_submit" />
Expand Down
16 changes: 8 additions & 8 deletions searx/templates/oscar/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<input type="hidden" name="language" value="{{ current_language }}" />{{- "" -}}
{% if timeout_limit %}<input type="hidden" name="timeout_limit" value="{{ timeout_limit|e }}" />{% endif -%}
{%- endmacro %}
{%- macro search_url() %}{{ base_url }}?q={{ q|urlencode }}{% if selected_categories %}&amp;categories={{ selected_categories|join(",") | replace(' ','+') }}{% endif %}{% if pageno > 1 %}&amp;pageno={{ pageno }}{% endif %}{% if time_range %}&amp;time_range={{ time_range }}{% endif %}{% if current_language != 'all' %}&amp;language={{ current_language }}{% endif %}{% endmacro -%}
{%- macro search_url() %}{{ url_for('search', _external=True) }}?q={{ q|urlencode }}{% if selected_categories %}&amp;categories={{ selected_categories|join(",") | replace(' ','+') }}{% endif %}{% if pageno > 1 %}&amp;pageno={{ pageno }}{% endif %}{% if time_range %}&amp;time_range={{ time_range }}{% endif %}{% if current_language != 'all' %}&amp;language={{ current_language }}{% endif %}{% endmacro -%}

{% block title %}{{ q|e }} - {% endblock %}
{% block meta %}{{" "}}<link rel="alternate" type="application/rss+xml" title="Searx search: {{ q|e }}" href="{{ search_url() }}&amp;format=rss">{% endblock %}
Expand Down Expand Up @@ -42,7 +42,7 @@ <h4 class="panel-title">{{ _('Suggestions') }}</h4>
</div>
<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">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" role="navigation" class="form-inline pull-{% if rtl %}right{% else %}left{% endif %} suggestion_item">
{% if current_language != 'all' %}
<input type="hidden" name="language" value="{{ current_language }}">
{% endif %}
Expand Down Expand Up @@ -71,7 +71,7 @@ <h4 class="panel-title">{{ _('Links') }}</h4>{{- "" -}}
<label>{{ _('Download results') }}</label>
<div class="clearfix"></div>
{% for output_type in ('csv', 'json', 'rss') %}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" class="form-inline pull-{% if rtl %}right{% else %}left{% endif %} result_download">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" class="form-inline pull-{% if rtl %}right{% else %}left{% endif %} result_download">
{{- search_form_attrs(pageno) -}}
<input type="hidden" name="format" value="{{ output_type }}">{{- "" -}}
<button type="submit" class="btn btn-default">{{ output_type }}</button>{{- "" -}}
Expand All @@ -92,7 +92,7 @@ <h1 class="sr-only">{{ _('Search results') }}</h1>
<div class="clearfix">
<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">{{- "" -}}
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" role="navigation" class="form-inline pull-left suggestion_item">{{- "" -}}
{% if current_language != 'all' %}
<input type="hidden" name="language" value="{{ current_language }}">
{% endif %}
Expand Down Expand Up @@ -140,13 +140,13 @@ <h1 class="sr-only">{{ _('Search results') }}</h1>
{% if rtl %}
<div id="pagination">
<div class="pull-left">{{- "" -}}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" class="pull-left">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" class="pull-left">
{{- search_form_attrs(pageno+1) -}}
<button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-backward"></span> {{ _('next page') }}</button>{{- "" -}}
</form>{{- "" -}}
</div>
<div class="pull-right">{{- "" -}}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" class="pull-left">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" class="pull-left">
{{- search_form_attrs(pageno-1) -}}
<button type="submit" class="btn btn-default" {% if pageno == 1 %}disabled{% endif %}><span class="glyphicon glyphicon-forward"></span> {{ _('previous page') }}</button>{{- "" -}}
</form>{{- "" -}}
Expand All @@ -156,13 +156,13 @@ <h1 class="sr-only">{{ _('Search results') }}</h1>
{% else %}
<div id="pagination">
<div class="pull-left">{{- "" -}}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" class="pull-left">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" class="pull-left">
{{- search_form_attrs(pageno-1) -}}
<button type="submit" class="btn btn-default" {% if pageno == 1 %}disabled{% endif %}><span class="glyphicon glyphicon-backward"></span> {{ _('previous page') }}</button>{{- "" -}}
</form>{{- "" -}}
</div>
<div class="pull-right">{{- "" -}}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" class="pull-left">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" class="pull-left">
{{- search_form_attrs(pageno+1) -}}
<button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-forward"></span> {{ _('next page') }}</button>{{- "" -}}
</form>{{- "" -}}
Expand Down
2 changes: 1 addition & 1 deletion searx/templates/oscar/search.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% from 'oscar/macros.html' import icon %}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" id="search_form" role="search">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" id="search_form" role="search">
<div class="row">
<div class="col-xs-12 col-md-8">
<div class="input-group search-margin">
Expand Down
2 changes: 1 addition & 1 deletion searx/templates/oscar/search_full.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% from 'oscar/macros.html' import icon %}

<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" id="search_form" role="search">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" id="search_form" role="search">
{% if rtl %}
<div class="input-group">
{% else %}
Expand Down
2 changes: 1 addition & 1 deletion searx/templates/pix-art/search.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" id="search_form">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}" id="search_form">
<div id="search_wrapper">
<input type="text" autofocus placeholder="{{ _('Search for...') }}" id="q" class="q" name="q" tabindex="1" size="100" {% if q %}value="{{ q }}"{% endif %}/>
<input type="submit" value="" id="search_submit" />
Expand Down
2 changes: 1 addition & 1 deletion searx/templates/simple/infobox.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h2><bdi>{{ infobox.infobox }}</bdi></h2>
<div>
<h3><bdi>{{ topic.name }}</bdi></h3>
{% for suggestion in topic.suggestions %}
<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
<form method="{{ method or 'POST' }}" action="{{ url_for('search') }}">
<input type="hidden" name="q" value="{{ suggestion }}">
<input type="hidden" name="time_range" value="{{ time_range }}">
<input type="hidden" name="language" value="{{ current_language }}">
Expand Down
Loading

0 comments on commit 9c3382d

Please sign in to comment.