浏览代码

oscar template: improve result page

* add paging support
* add suggestion panel
* add links panel
Thomas Pointhuber 10 年前
父节点
当前提交
b91b77e335
共有 2 个文件被更改,包括 88 次插入6 次删除
  1. 13
    1
      searx/static/oscar/css/oscar.css
  2. 75
    5
      searx/templates/oscar/results.html

+ 13
- 1
searx/static/oscar/css/oscar.css 查看文件

@@ -15,7 +15,7 @@ body {
15 15
   bottom: 0;
16 16
   width: 100%;
17 17
   /* Set the fixed height of the footer here */
18
-  height: 40px;
18
+  height: 60px;
19 19
 }
20 20
 
21 21
 input[type=checkbox]:checked ~ .label_hide_if_checked {
@@ -51,3 +51,15 @@ input[type=checkbox]:not(:checked) ~ .label_hide_if_not_checked {
51 51
     max-height: 128px;
52 52
     min-height: 128px;
53 53
 }
54
+
55
+.suggestion_item {
56
+    margin: 2px 5px;
57
+}
58
+
59
+.result_download {
60
+    margin-right: 5px;
61
+}
62
+
63
+#pagination {
64
+    margin-top: 30px;
65
+}

+ 75
- 5
searx/templates/oscar/results.html 查看文件

@@ -5,18 +5,88 @@
5 5
         <div class="col-sm-8" id="main_results">
6 6
             <h1 class="sr-only">{{ _('Search results') }}</h1>
7 7
             {% include 'oscar/search.html' %}
8
-            
8
+
9 9
             {% for result in results %}
10 10
             <div class="result {% if result['template'] %}result-{{ result.template|replace('.html', '') }}{% else %}result-default{% endif %}">
11 11
                 {% set index = loop.index %}
12 12
                 {% if result.template %}{% include 'oscar/result_templates/'+result['template'] %}{% else %}{% include 'oscar/result_templates/default.html' %}{% endif %}
13 13
             </div>
14 14
             {% endfor %}
15
-            
15
+
16 16
             <div class="clearfix"></div>
17
-    
18
-        </div>
17
+
18
+            {% if paging %}
19
+            <div id="pagination">
20
+                <div class="pull-left">
21
+                    <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" class="pull-left">
22
+                        <input type="hidden" name="q" value="{{ q }}" />
23
+                        {% for category in selected_categories %}<input type="hidden" name="category_{{ category }}" value="1"/>{% endfor %}
24
+                        <input type="hidden" name="pageno" value="{{ pageno-1 }}" />
25
+                        <button type="submit" class="btn btn-default" {% if pageno == 1 %}disabled{% endif %}><span class="glyphicon glyphicon-backward"></span> {{ _('previous page') }}</button>
26
+                    </form>
27
+                </div>
28
+                <div class="pull-right">
29
+                    <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}"  class="pull-left">
30
+                        {% for category in selected_categories %}<input type="hidden" name="category_{{ category }}" value="1"/>{% endfor %}
31
+                        <input type="hidden" name="q" value="{{ q }}" />
32
+                        <input type="hidden" name="pageno" value="{{ pageno+1 }}" />
33
+                        <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-forward"></span> {{ _('next page') }}</button>
34
+                    </form>
35
+                </div>
36
+            </div><!-- /#pagination -->
37
+            <div class="clearfix"></div>
38
+            {% endif %}
39
+        </div><!-- /#main_results -->
40
+
19 41
         <div class="col-sm-4" id="sidebar_results">
20
-        </div>
42
+
43
+            {% if suggestions %}
44
+            <div class="panel panel-default">
45
+                <div class="panel-heading">
46
+                    <h4 class="panel-title">
47
+                        <a data-toggle="collapse" data-parent="#accordion" href="#suggestions">{{ _('Suggestions') }}</a>
48
+                    </h4>
49
+                </div>
50
+                <div class="panel-body">
51
+                    {% for suggestion in suggestions %}
52
+                    <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" role="navigation" class="form-inline pull-left suggestion_item">
53
+                        <input type="hidden" name="q" value="{{ suggestion }}">
54
+                        <button type="submit" class="btn btn-default btn-xs">{{ suggestion }}</button>
55
+                    </form>
56
+                    {% endfor %}
57
+                </div>
58
+            </div>
59
+            {% endif %}
60
+
61
+            <div class="panel panel-default">
62
+                <div class="panel-heading">
63
+                    <h4 class="panel-title">
64
+                        <a data-toggle="collapse" data-parent="#accordion" href="#links">{{ _('Links') }}</a>
65
+                    </h4>
66
+                </div>
67
+                <div class="panel-body">
68
+                    <form role="form">
69
+                        <div class="form-group">
70
+                            <label for="search_url">{{ _('Search URL') }}</label>
71
+                            <input type="url" class="form-control" name="search_url" value="{{ base_url }}?q={{ q|urlencode }}&pageno={{ pageno }}{% if selected_categories %}&category_{{ selected_categories|join("&category_") }}{% endif %}">
72
+                        </div>
73
+                    </form>
74
+                    
75
+                    <label>{{ _('Download results') }}</label>
76
+                    <div class="clearfix"></div>
77
+                    {% for output_type in ('csv', 'json', 'rss') %}
78
+                    <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" class="form-inline pull-left result_download">
79
+                        <input type="hidden" name="q" value="{{ q }}">
80
+                        <input type="hidden" name="format" value="{{ output_type }}">
81
+                        {% for category in selected_categories %}<input type="hidden" name="category_{{ category }}" value="1">{% endfor %}
82
+                        <input type="hidden" name="pageno" value="{{ pageno }}">
83
+                        <button type="submit" class="btn btn-default">{{ output_type }}</button>
84
+                    </form>
85
+                    {% endfor %} 
86
+                    <div class="clearfix"></div>
87
+                </div>
88
+            </div>
89
+        
90
+        </div><!-- /#sidebar_results -->
21 91
     </div>
22 92
 {% endblock %}