Merge pull request #188 from Cqoicebordel/general-cookies

General cookies
This commit is contained in:
Adam Tauber 2015-01-20 17:17:13 +01:00
commit 549dcac588
6 changed files with 69 additions and 11 deletions

File diff suppressed because one or more lines are too long

View File

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

View File

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

View File

@ -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] }};
}

View File

@ -69,6 +69,19 @@
</select> </select>
</p> </p>
</fieldset> </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> <fieldset>
<legend>{{ _('Currently used search engines') }}</legend> <legend>{{ _('Currently used search engines') }}</legend>

View File

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