Browse Source

Merge pull request #188 from Cqoicebordel/general-cookies

General cookies
Adam Tauber 10 years ago
parent
commit
549dcac588

File diff suppressed because it is too large
+ 0 - 0
searx/static/themes/courgette/css/style.css


+ 10 - 8
searx/static/themes/courgette/less/style.less

@@ -1,5 +1,6 @@
 
 @color-main: #3498DB;
+@color-focus: #0665A2;
 @color-other-links: #666;
 @color-fonts: #333;
 @center-width: 70em;
@@ -39,11 +40,12 @@ a {
 }
 
 .title h1 {
-	background: url(../img/searx.png) no-repeat;
-	width: 319px;
-	height: 62px;
-	text-indent: -9999px;
-	margin: 0.5em auto 1em;
+	font-size:7em;
+	color:@color-main;
+	margin:0 auto;
+	line-height:100px;
+	margin-top:-20px;
+	padding-bottom:20px;
 }
 
 .center {
@@ -240,7 +242,7 @@ a {
 
 #search_submit:hover,
 #search_submit:focus {
-	background-color: #0665A2;
+	background-color: @color-focus;
 }
 
 #sidebar {
@@ -310,7 +312,7 @@ a {
 #sidebar input[type="submit"]:hover,
 #sidebar input[type="submit"]:focus {
 	color: #FFF;
-	background-color: #0665A2;
+	background-color: @color-focus;
 }
 
 #results {
@@ -432,7 +434,7 @@ input[type="submit"] {
 
 input[type="submit"]:hover,
 input[type="submit"]:focus {
-	background: #0665A2;
+	background: @color-focus;
 }
 
 .row {

+ 5 - 0
searx/templates/courgette/base.html

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

+ 34 - 0
searx/templates/courgette/color.css

@@ -0,0 +1,34 @@
+ .autocompleter-choices li:hover,
+.checkbox_container label:hover,
+.checkbox_container input[type="checkbox"]:checked + label,
+#sidebar,
+#suggestions input[type="submit"]:hover,
+#suggestions input[type="submit"]:focus,
+input[type="submit"],
+.engine_checkbox label,
+.engine_checkbox .deny,
+#search_submit{
+	background-color: {{ cookies['courgette-color'].split()[0] }};
+}
+
+.result_title a,
+.row a,
+.title h1{
+	color: {{ cookies['courgette-color'].split()[0] }};
+}
+
+#answers {
+	border-color: {{ cookies['courgette-color'].split()[0] }};
+}
+
+#search_submit:hover,
+#search_submit:focus,
+#sidebar input[type="submit"]:hover,
+#sidebar input[type="submit"]:focus {
+	background-color: {{ cookies['courgette-color'].split()[1] }};
+}
+
+input[type="submit"]:hover,
+input[type="submit"]:focus {
+	background: {{ cookies['courgette-color'].split()[1] }};
+}

+ 13 - 0
searx/templates/courgette/preferences.html

@@ -69,6 +69,19 @@
             </select>
         </p>
     </fieldset>
+    <fieldset>
+        <legend>{{ _('Color') }}</legend>
+        <p>
+            <select name="courgette-color">
+                <option value="#3498DB #0665A2" {% if cookies['courgette-color'] and cookies['courgette-color'] == '#3498DB #0665A2' %}selected="selected"{% endif %}>{{ _('Blue (default)') }}</option>
+                <option value="#6F5499 #563D7C" {% if cookies['courgette-color'] and cookies['courgette-color'] == '#6F5499 #563D7C' %}selected="selected"{% endif %}>{{ _('Violet') }}</option>
+                <option value="#5CB85C #449D44" {% if cookies['courgette-color'] and cookies['courgette-color'] == '#5CB85C #449D44' %}selected="selected"{% endif %}>{{ _('Green') }}</option>
+                <option value="#5BC0DE #31B0D5" {% if cookies['courgette-color'] and cookies['courgette-color'] == '#5BC0DE #31B0D5' %}selected="selected"{% endif %}>{{ _('Cyan') }}</option>
+                <option value="#F0AD4E #EC971F" {% if cookies['courgette-color'] and cookies['courgette-color'] == '#F0AD4E #EC971F' %}selected="selected"{% endif %}>{{ _('Orange') }}</option>
+                <option value="#D9534F #C9302C" {% if cookies['courgette-color'] and cookies['courgette-color'] == '#D9534F #C9302C' %}selected="selected"{% endif %}>{{ _('Red') }}</option>
+            </select>
+        </p>
+    </fieldset>
     <fieldset>
         <legend>{{ _('Currently used search engines') }}</legend>
 

+ 6 - 2
searx/webapp.py

@@ -277,6 +277,8 @@ def render(template_name, override_theme=None, **kwargs):
 
     kwargs['template_name'] = template_name
 
+    kwargs['cookies'] = request.cookies
+
     return render_template(
         '{}/{}'.format(kwargs['theme'], template_name), **kwargs)
 
@@ -471,6 +473,8 @@ def preferences():
 
     blocked_engines = []
 
+    resp = make_response(redirect(url_for('index')))
+
     if request.method == 'GET':
         blocked_engines = request.cookies.get('blocked_engines', '').split(',')
     else:  # on save
@@ -502,8 +506,8 @@ def preferences():
                     blocked_engines.append(engine_name)
             elif pd_name == 'theme':
                 theme = pd if pd in themes else default_theme
-
-        resp = make_response(redirect(url_for('index')))
+            else:
+                resp.set_cookie(pd_name, pd, max_age=cookie_max_age)
 
         user_blocked_engines = request.cookies.get('blocked_engines', '').split(',')  # noqa
 

Some files were not shown because too many files changed in this diff