Przeglądaj źródła

Merge pull request #188 from Cqoicebordel/general-cookies

General cookies
Adam Tauber 10 lat temu
rodzic
commit
549dcac588

+ 1
- 1
searx/static/themes/courgette/css/style.css
Plik diff jest za duży
Wyświetl plik


+ 10
- 8
searx/static/themes/courgette/less/style.less Wyświetl plik

@@ -1,5 +1,6 @@
1 1
 
2 2
 @color-main: #3498DB;
3
+@color-focus: #0665A2;
3 4
 @color-other-links: #666;
4 5
 @color-fonts: #333;
5 6
 @center-width: 70em;
@@ -39,11 +40,12 @@ a {
39 40
 }
40 41
 
41 42
 .title h1 {
42
-	background: url(../img/searx.png) no-repeat;
43
-	width: 319px;
44
-	height: 62px;
45
-	text-indent: -9999px;
46
-	margin: 0.5em auto 1em;
43
+	font-size:7em;
44
+	color:@color-main;
45
+	margin:0 auto;
46
+	line-height:100px;
47
+	margin-top:-20px;
48
+	padding-bottom:20px;
47 49
 }
48 50
 
49 51
 .center {
@@ -240,7 +242,7 @@ a {
240 242
 
241 243
 #search_submit:hover,
242 244
 #search_submit:focus {
243
-	background-color: #0665A2;
245
+	background-color: @color-focus;
244 246
 }
245 247
 
246 248
 #sidebar {
@@ -310,7 +312,7 @@ a {
310 312
 #sidebar input[type="submit"]:hover,
311 313
 #sidebar input[type="submit"]:focus {
312 314
 	color: #FFF;
313
-	background-color: #0665A2;
315
+	background-color: @color-focus;
314 316
 }
315 317
 
316 318
 #results {
@@ -432,7 +434,7 @@ input[type="submit"] {
432 434
 
433 435
 input[type="submit"]:hover,
434 436
 input[type="submit"]:focus {
435
-	background: #0665A2;
437
+	background: @color-focus;
436 438
 }
437 439
 
438 440
 .row {

+ 5
- 0
searx/templates/courgette/base.html Wyświetl plik

@@ -8,6 +8,11 @@
8 8
         <meta name="viewport" content="width=device-width, maximum-scale=1.0, user-scalable=1" />
9 9
         <title>{% block title %}{% endblock %}searx</title>
10 10
         <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" type="text/css" media="screen" />
11
+        {% if cookies['courgette-color'] %}
12
+        <style type="text/css">
13
+        {% include 'courgette/color.css' %}
14
+        </style>
15
+        {% endif %}
11 16
         <link rel="shortcut icon" href="{{ url_for('static', filename='img/favicon.png') }}?v=2" />
12 17
         {% block styles %}
13 18
         {% endblock %}

+ 34
- 0
searx/templates/courgette/color.css Wyświetl plik

@@ -0,0 +1,34 @@
1
+ .autocompleter-choices li:hover,
2
+.checkbox_container label:hover,
3
+.checkbox_container input[type="checkbox"]:checked + label,
4
+#sidebar,
5
+#suggestions input[type="submit"]:hover,
6
+#suggestions input[type="submit"]:focus,
7
+input[type="submit"],
8
+.engine_checkbox label,
9
+.engine_checkbox .deny,
10
+#search_submit{
11
+	background-color: {{ cookies['courgette-color'].split()[0] }};
12
+}
13
+
14
+.result_title a,
15
+.row a,
16
+.title h1{
17
+	color: {{ cookies['courgette-color'].split()[0] }};
18
+}
19
+
20
+#answers {
21
+	border-color: {{ cookies['courgette-color'].split()[0] }};
22
+}
23
+
24
+#search_submit:hover,
25
+#search_submit:focus,
26
+#sidebar input[type="submit"]:hover,
27
+#sidebar input[type="submit"]:focus {
28
+	background-color: {{ cookies['courgette-color'].split()[1] }};
29
+}
30
+
31
+input[type="submit"]:hover,
32
+input[type="submit"]:focus {
33
+	background: {{ cookies['courgette-color'].split()[1] }};
34
+}

+ 13
- 0
searx/templates/courgette/preferences.html Wyświetl plik

@@ -70,6 +70,19 @@
70 70
         </p>
71 71
     </fieldset>
72 72
     <fieldset>
73
+        <legend>{{ _('Color') }}</legend>
74
+        <p>
75
+            <select name="courgette-color">
76
+                <option value="#3498DB #0665A2" {% if cookies['courgette-color'] and cookies['courgette-color'] == '#3498DB #0665A2' %}selected="selected"{% endif %}>{{ _('Blue (default)') }}</option>
77
+                <option value="#6F5499 #563D7C" {% if cookies['courgette-color'] and cookies['courgette-color'] == '#6F5499 #563D7C' %}selected="selected"{% endif %}>{{ _('Violet') }}</option>
78
+                <option value="#5CB85C #449D44" {% if cookies['courgette-color'] and cookies['courgette-color'] == '#5CB85C #449D44' %}selected="selected"{% endif %}>{{ _('Green') }}</option>
79
+                <option value="#5BC0DE #31B0D5" {% if cookies['courgette-color'] and cookies['courgette-color'] == '#5BC0DE #31B0D5' %}selected="selected"{% endif %}>{{ _('Cyan') }}</option>
80
+                <option value="#F0AD4E #EC971F" {% if cookies['courgette-color'] and cookies['courgette-color'] == '#F0AD4E #EC971F' %}selected="selected"{% endif %}>{{ _('Orange') }}</option>
81
+                <option value="#D9534F #C9302C" {% if cookies['courgette-color'] and cookies['courgette-color'] == '#D9534F #C9302C' %}selected="selected"{% endif %}>{{ _('Red') }}</option>
82
+            </select>
83
+        </p>
84
+    </fieldset>
85
+    <fieldset>
73 86
         <legend>{{ _('Currently used search engines') }}</legend>
74 87
 
75 88
         <table>

+ 6
- 2
searx/webapp.py Wyświetl plik

@@ -277,6 +277,8 @@ def render(template_name, override_theme=None, **kwargs):
277 277
 
278 278
     kwargs['template_name'] = template_name
279 279
 
280
+    kwargs['cookies'] = request.cookies
281
+
280 282
     return render_template(
281 283
         '{}/{}'.format(kwargs['theme'], template_name), **kwargs)
282 284
 
@@ -471,6 +473,8 @@ def preferences():
471 473
 
472 474
     blocked_engines = []
473 475
 
476
+    resp = make_response(redirect(url_for('index')))
477
+
474 478
     if request.method == 'GET':
475 479
         blocked_engines = request.cookies.get('blocked_engines', '').split(',')
476 480
     else:  # on save
@@ -502,8 +506,8 @@ def preferences():
502 506
                     blocked_engines.append(engine_name)
503 507
             elif pd_name == 'theme':
504 508
                 theme = pd if pd in themes else default_theme
505
-
506
-        resp = make_response(redirect(url_for('index')))
509
+            else:
510
+                resp.set_cookie(pd_name, pd, max_age=cookie_max_age)
507 511
 
508 512
         user_blocked_engines = request.cookies.get('blocked_engines', '').split(',')  # noqa
509 513