Sfoglia il codice sorgente

[enh] propagate all search properties to the results page's components

Adam Tauber 8 anni fa
parent
commit
14b96b8824
1 ha cambiato i file con 17 aggiunte e 23 eliminazioni
  1. 17
    23
      searx/templates/oscar/results.html

+ 17
- 23
searx/templates/oscar/results.html Vedi File

1
 {% extends "oscar/base.html" %}
1
 {% extends "oscar/base.html" %}
2
+{% macro search_form_attrs() -%}
3
+    {% for category in selected_categories %}<input type="hidden" name="category_{{ category }}" value="1"/>{% endfor %}
4
+    <input type="hidden" name="q" value="{{ q|e }}" />
5
+    <input type="hidden" name="pageno" value="{{ pageno+1 }}" />
6
+    <input type="hidden" name="time_range" value="{{ time_range }}" />
7
+    <input type="hidden" name="language" value="{{ current_language }}" />
8
+{%- endmacro %}
9
+{%- 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 -%}
10
+
2
 {% block title %}{{ q|e }} - {% endblock %}
11
 {% block title %}{{ q|e }} - {% endblock %}
3
-{% 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 }}&amp;time_range={{ time_range }}">{% endblock %}
12
+{% block meta %}<link rel="alternate" type="application/rss+xml" title="Searx search: {{ q|e }}" href="{{ search_url() }}&amp;format=rss">{% endblock %}
4
 {% block content %}
13
 {% block content %}
5
     <div class="row">
14
     <div class="row">
6
         <div class="col-sm-8" id="main_results">
15
         <div class="col-sm-8" id="main_results">
36
             {% if rtl %}
45
             {% if rtl %}
37
             <div id="pagination">
46
             <div id="pagination">
38
                 <div class="pull-left">
47
                 <div class="pull-left">
39
-                    <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" class="pull-left">
40
-                        <input type="hidden" name="q" value="{{ q|e }}" />
41
-                        {% for category in selected_categories %}<input type="hidden" name="category_{{ category }}" value="1"/>{% endfor %}
42
-                        <input type="hidden" name="q" value="{{ q|e }}" />
43
-                        <input type="hidden" name="pageno" value="{{ pageno+1 }}" />
44
-                        <input type="hidden" name="time_range" value="{{ time_range }}" />
48
+                  <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" class="pull-left">
49
+                        {{ search_form_attrs() }}
45
                         <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-backward"></span> {{ _('next page') }}</button>
50
                         <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-backward"></span> {{ _('next page') }}</button>
46
                     </form>
51
                     </form>
47
                 </div>
52
                 </div>
48
                 <div class="pull-right">
53
                 <div class="pull-right">
49
                     <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}"  class="pull-left">
54
                     <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}"  class="pull-left">
50
-                        {% for category in selected_categories %}<input type="hidden" name="category_{{ category }}" value="1"/>{% endfor %}
51
-                        <input type="hidden" name="pageno" value="{{ pageno-1 }}" />
52
-                        <input type="hidden" name="time_range" value="{{ time_range }}" />
55
+                        {{ search_form_attrs() }}
53
                         <button type="submit" class="btn btn-default" {% if pageno == 1 %}disabled{% endif %}><span class="glyphicon glyphicon-forward"></span> {{ _('previous page') }}</button>
56
                         <button type="submit" class="btn btn-default" {% if pageno == 1 %}disabled{% endif %}><span class="glyphicon glyphicon-forward"></span> {{ _('previous page') }}</button>
54
                     </form>
57
                     </form>
55
                 </div>
58
                 </div>
59
             <div id="pagination">
62
             <div id="pagination">
60
                 <div class="pull-left">
63
                 <div class="pull-left">
61
                     <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" class="pull-left">
64
                     <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" class="pull-left">
62
-                        <input type="hidden" name="q" value="{{ q|e }}" />
63
-                        {% for category in selected_categories %}<input type="hidden" name="category_{{ category }}" value="1"/>{% endfor %}
64
-                        <input type="hidden" name="pageno" value="{{ pageno-1 }}" />
65
-                        <input type="hidden" name="time_range" value="{{ time_range }}" />
65
+                        {{ search_form_attrs() }}
66
                         <button type="submit" class="btn btn-default" {% if pageno == 1 %}disabled{% endif %}><span class="glyphicon glyphicon-backward"></span> {{ _('previous page') }}</button>
66
                         <button type="submit" class="btn btn-default" {% if pageno == 1 %}disabled{% endif %}><span class="glyphicon glyphicon-backward"></span> {{ _('previous page') }}</button>
67
                     </form>
67
                     </form>
68
                 </div>
68
                 </div>
69
                 <div class="pull-right">
69
                 <div class="pull-right">
70
                     <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}"  class="pull-left">
70
                     <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}"  class="pull-left">
71
-                        {% for category in selected_categories %}<input type="hidden" name="category_{{ category }}" value="1"/>{% endfor %}
72
-                        <input type="hidden" name="q" value="{{ q|e }}" />
73
-                        <input type="hidden" name="pageno" value="{{ pageno+1 }}" />
74
-                        <input type="hidden" name="time_range" value="{{ time_range }}" />
71
+                        {{ search_form_attrs() }}
75
                         <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-forward"></span> {{ _('next page') }}</button>
72
                         <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-forward"></span> {{ _('next page') }}</button>
76
                     </form>
73
                     </form>
77
                 </div>
74
                 </div>
122
                     <form role="form">
119
                     <form role="form">
123
                         <div class="form-group">
120
                         <div class="form-group">
124
                             <label for="search_url">{{ _('Search URL') }}</label>
121
                             <label for="search_url">{{ _('Search URL') }}</label>
125
-                            <input id="search_url" type="url" class="form-control select-all-on-click cursor-text" name="search_url" value="{{ 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 %}" readonly>
122
+                            <input id="search_url" type="url" class="form-control select-all-on-click cursor-text" name="search_url" value="{{ search_url() }}" readonly>
126
                         </div>
123
                         </div>
127
                     </form>
124
                     </form>
128
 
125
 
130
                     <div class="clearfix"></div>
127
                     <div class="clearfix"></div>
131
                     {% for output_type in ('csv', 'json', 'rss') %}
128
                     {% for output_type in ('csv', 'json', 'rss') %}
132
                     <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" class="form-inline pull-{% if rtl %}right{% else %}left{% endif %} result_download">
129
                     <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" class="form-inline pull-{% if rtl %}right{% else %}left{% endif %} result_download">
133
-                        <input type="hidden" name="q" value="{{ q|e }}">
130
+                        {{ search_form_attrs() }}
134
                         <input type="hidden" name="format" value="{{ output_type }}">
131
                         <input type="hidden" name="format" value="{{ output_type }}">
135
-                        {% for category in selected_categories %}<input type="hidden" name="category_{{ category }}" value="1">{% endfor %}
136
-                        <input type="hidden" name="pageno" value="{{ pageno }}">
137
-                        <input type="hidden" name="time_range" value="{{ time_range }}" />
138
                         <button type="submit" class="btn btn-default">{{ output_type }}</button>
132
                         <button type="submit" class="btn btn-default">{{ output_type }}</button>
139
                     </form>
133
                     </form>
140
                     {% endfor %}
134
                     {% endfor %}