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-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 {

View file

@ -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 %}

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>
</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>

View file

@ -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