Parcourir la source

oscar template: implement search input, index page,...

Thomas Pointhuber il y a 10 ans
Parent
révision
a538bed745

BIN
searx/static/oscar/img/searx.png Voir le fichier


BIN
searx/static/oscar/img/searx_logo.png Voir le fichier


+ 17
- 7
searx/static/oscar/js/scripts.js Voir le fichier

@@ -12,15 +12,11 @@ $(document).ready(function(){
12 12
         var btnClass = 'btn-' + $(this).data('btn-class');
13 13
         var btnLabelDefault = $(this).data('btn-label-default');
14 14
         var btnLabelToggled = $(this).data('btn-label-toggled');
15
-        if(btnLabelToggled != '')
16
-        {
17
-            if($(this).hasClass('btn-default'))
18
-            {
15
+        if(btnLabelToggled != '') {
16
+            if($(this).hasClass('btn-default')) {
19 17
                 
20 18
                 var html = $(this).html().replace(btnLabelDefault, btnLabelToggled);
21
-            }
22
-            else
23
-            {
19
+            } else {
24 20
                 var html = $(this).html().replace(btnLabelToggled, btnLabelDefault);
25 21
             }
26 22
             $(this).html(html);
@@ -28,4 +24,18 @@ $(document).ready(function(){
28 24
         $(this).toggleClass(btnClass);
29 25
         $(this).toggleClass('btn-default');
30 26
     });
27
+
28
+    $('.btn-collapse').click(function() {
29
+        var btnTextCollapsed = $(this).data('btn-text-collapsed');
30
+        var btnTextNotCollapsed = $(this).data('btn-text-not-collapsed');
31
+        
32
+        if(btnTextCollapsed != '' && btnTextNotCollapsed != '') {
33
+            if($(this).hasClass('collapsed')) {
34
+                var html = $(this).html().replace(btnTextCollapsed, btnTextNotCollapsed);
35
+            } else {
36
+                var html = $(this).html().replace(btnTextNotCollapsed, btnTextCollapsed);
37
+            }
38
+            $(this).html(html);
39
+        }
40
+    });
31 41
 });

+ 11
- 2
searx/templates/oscar/index.html Voir le fichier

@@ -1,6 +1,15 @@
1 1
 {% extends "oscar/base.html" %}
2 2
 {% block content %}
3
-<div class="center">
4
-    <div class="title"><h1>searx</h1></div>
3
+<div class="container-fluid">
4
+    <div class="row">
5
+        <div class="text-center col-sm-12 col-md-12">
6
+            <h1 class="text-hide center-block"><img class="center-block img-responsive" src="{{ url_for('static', filename='img/searx_logo.png') }}" alt="searx logo"/>searx</h1>
7
+        </div>
8
+    </div>
9
+    <div class="row">
10
+        <div class="text-center col-sm-12 col-md-12">
11
+            {% include 'oscar/search.html' %}
12
+        </div>
13
+    </div>
5 14
 </div>
6 15
 {% endblock %}

+ 3
- 0
searx/templates/oscar/macros.html Voir le fichier

@@ -0,0 +1,3 @@
1
+{% macro icon(action) -%}
2
+    <span class="glyphicon glyphicon-{{ action }}"></span>
3
+{%- endmacro %}

+ 17
- 0
searx/templates/oscar/search.html Voir le fichier

@@ -0,0 +1,17 @@
1
+{% from 'oscar/macros.html' import icon %}
2
+
3
+<form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" id="search_form" role="search">
4
+    <div class="input-group col-md-8 col-md-offset-2">
5
+        <input type="search" name="q" class="form-control input-lg" id="q" placeholder="{{ _('Search for...') }}" autocomplete="off" value="{{ q }}">
6
+        <span class="input-group-btn">
7
+            <button type="submit" class="btn btn-default input-lg">{{ icon('search') }}<span class="sr-only">{{ _('Start search') }}</span></button>
8
+        </span>
9
+    </div>
10
+
11
+    <button type="button" class="btn btn-link btn-collapse center-block collapsed" data-toggle="collapse" data-target="#search_categories" data-btn-text-collapsed="{{ _('Show search filters') }}" data-btn-text-not-collapsed="{{ _('Hide search filters') }}">{{ _('Show search filters') }}</button>
12
+    <div class="row collapse" id="search_categories">
13
+        <div class="col-md-12 text-center">
14
+            {% include 'oscar/categories.html' %}
15
+        </div>
16
+    </div><!-- / #search_categories -->
17
+</form><!-- / #search_form_full -->