瀏覽代碼

Merge pull request #188 from Cqoicebordel/general-cookies

General cookies
Adam Tauber 10 年之前
父節點
當前提交
549dcac588

+ 1
- 1
searx/static/themes/courgette/css/style.css
文件差異過大導致無法顯示
查看文件


+ 10
- 8
searx/static/themes/courgette/less/style.less 查看文件

1
 
1
 
2
 @color-main: #3498DB;
2
 @color-main: #3498DB;
3
+@color-focus: #0665A2;
3
 @color-other-links: #666;
4
 @color-other-links: #666;
4
 @color-fonts: #333;
5
 @color-fonts: #333;
5
 @center-width: 70em;
6
 @center-width: 70em;
39
 }
40
 }
40
 
41
 
41
 .title h1 {
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
 .center {
51
 .center {
240
 
242
 
241
 #search_submit:hover,
243
 #search_submit:hover,
242
 #search_submit:focus {
244
 #search_submit:focus {
243
-	background-color: #0665A2;
245
+	background-color: @color-focus;
244
 }
246
 }
245
 
247
 
246
 #sidebar {
248
 #sidebar {
310
 #sidebar input[type="submit"]:hover,
312
 #sidebar input[type="submit"]:hover,
311
 #sidebar input[type="submit"]:focus {
313
 #sidebar input[type="submit"]:focus {
312
 	color: #FFF;
314
 	color: #FFF;
313
-	background-color: #0665A2;
315
+	background-color: @color-focus;
314
 }
316
 }
315
 
317
 
316
 #results {
318
 #results {
432
 
434
 
433
 input[type="submit"]:hover,
435
 input[type="submit"]:hover,
434
 input[type="submit"]:focus {
436
 input[type="submit"]:focus {
435
-	background: #0665A2;
437
+	background: @color-focus;
436
 }
438
 }
437
 
439
 
438
 .row {
440
 .row {

+ 5
- 0
searx/templates/courgette/base.html 查看文件

8
         <meta name="viewport" content="width=device-width, maximum-scale=1.0, user-scalable=1" />
8
         <meta name="viewport" content="width=device-width, maximum-scale=1.0, user-scalable=1" />
9
         <title>{% block title %}{% endblock %}searx</title>
9
         <title>{% block title %}{% endblock %}searx</title>
10
         <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" type="text/css" media="screen" />
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
         <link rel="shortcut icon" href="{{ url_for('static', filename='img/favicon.png') }}?v=2" />
16
         <link rel="shortcut icon" href="{{ url_for('static', filename='img/favicon.png') }}?v=2" />
12
         {% block styles %}
17
         {% block styles %}
13
         {% endblock %}
18
         {% endblock %}

+ 34
- 0
searx/templates/courgette/color.css 查看文件

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 查看文件

70
         </p>
70
         </p>
71
     </fieldset>
71
     </fieldset>
72
     <fieldset>
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
         <legend>{{ _('Currently used search engines') }}</legend>
86
         <legend>{{ _('Currently used search engines') }}</legend>
74
 
87
 
75
         <table>
88
         <table>

+ 6
- 2
searx/webapp.py 查看文件

277
 
277
 
278
     kwargs['template_name'] = template_name
278
     kwargs['template_name'] = template_name
279
 
279
 
280
+    kwargs['cookies'] = request.cookies
281
+
280
     return render_template(
282
     return render_template(
281
         '{}/{}'.format(kwargs['theme'], template_name), **kwargs)
283
         '{}/{}'.format(kwargs['theme'], template_name), **kwargs)
282
 
284
 
471
 
473
 
472
     blocked_engines = []
474
     blocked_engines = []
473
 
475
 
476
+    resp = make_response(redirect(url_for('index')))
477
+
474
     if request.method == 'GET':
478
     if request.method == 'GET':
475
         blocked_engines = request.cookies.get('blocked_engines', '').split(',')
479
         blocked_engines = request.cookies.get('blocked_engines', '').split(',')
476
     else:  # on save
480
     else:  # on save
502
                     blocked_engines.append(engine_name)
506
                     blocked_engines.append(engine_name)
503
             elif pd_name == 'theme':
507
             elif pd_name == 'theme':
504
                 theme = pd if pd in themes else default_theme
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
         user_blocked_engines = request.cookies.get('blocked_engines', '').split(',')  # noqa
512
         user_blocked_engines = request.cookies.get('blocked_engines', '').split(',')  # noqa
509
 
513