瀏覽代碼

Merge branch 'rtl' of github.com:Cqoicebordel/searx

Adam Tauber 10 年之前
父節點
當前提交
df9cf9d09b

+ 2
- 0
Makefile 查看文件

@@ -46,7 +46,9 @@ minimal: bin/buildout minimal.cfg setup.py
46 46
 
47 47
 styles:
48 48
 	@lessc -x searx/static/themes/default/less/style.less > searx/static/themes/default/css/style.css
49
+	@lessc -x searx/static/themes/default/less/style-rtl.less > searx/static/themes/default/css/style-rtl.css
49 50
 	@lessc -x searx/static/themes/courgette/less/style.less > searx/static/themes/courgette/css/style.css
51
+	@lessc -x searx/static/themes/courgette/less/style-rtl.less > searx/static/themes/courgette/css/style-rtl.css
50 52
 	@lessc -x searx/static/less/bootstrap/bootstrap.less > searx/static/css/bootstrap.min.css
51 53
 	@lessc -x searx/static/themes/oscar/less/oscar/oscar.less > searx/static/themes/oscar/css/oscar.min.css
52 54
 

+ 1
- 0
searx/static/themes/courgette/css/style-rtl.css 查看文件

@@ -0,0 +1 @@
1
+.q{padding:.5em 1em .5em 3em}#search_submit{left:0;right:auto}.result .favicon{float:right;margin-left:.5em;margin-right:0}#sidebar{right:auto;left:0}#results{padding:0 32px 0 272px}.search.center{padding-right:0;padding-left:17em}.right{right:auto;left:0}#pagination form+form{float:left;margin-top:-2em}

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


+ 38
- 0
searx/static/themes/courgette/less/style-rtl.less 查看文件

@@ -0,0 +1,38 @@
1
+.q {
2
+	padding: 0.5em 1em 0.5em 3em;
3
+}
4
+
5
+#search_submit {
6
+	left: 0;
7
+	right:auto;
8
+}
9
+
10
+.result .favicon { 
11
+	float: right;
12
+	margin-left: 0.5em;
13
+	margin-right: 0;
14
+}
15
+
16
+#sidebar {
17
+	right: auto;
18
+	left: 0;
19
+}
20
+
21
+#results {
22
+	padding: 0px 32px 0px 272px;
23
+}
24
+
25
+.search.center { 
26
+	padding-right: 0;
27
+	padding-left: 17em;
28
+}
29
+
30
+.right {
31
+	right: auto;
32
+	left: 0;
33
+}
34
+
35
+#pagination form + form {
36
+	float: left;
37
+	margin-top: -2em;
38
+}

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

@@ -278,7 +278,7 @@ a {
278 278
 }
279 279
 
280 280
 #preferences {
281
-	background: url(../img/preference-icon.png) no-repeat right 0 / 12% auto; 
281
+	background: url("../img/preference-icon.png") no-repeat right center / 12% auto; 
282 282
 	padding-right: 1.8em;
283 283
 }
284 284
 

+ 1
- 0
searx/static/themes/default/css/style-rtl.css 查看文件

@@ -0,0 +1 @@
1
+#search_submit{left:1px;right:auto}.result .favicon{float:right;margin-left:.5em;margin-right:0}

+ 11
- 0
searx/static/themes/default/less/style-rtl.less 查看文件

@@ -0,0 +1,11 @@
1
+#search_submit {
2
+	left: 1px;
3
+	right:auto;
4
+}
5
+
6
+.result .favicon { 
7
+	float: right;
8
+	margin-left: 0.5em;
9
+	margin-right: 0;
10
+}
11
+

+ 4
- 1
searx/templates/courgette/base.html 查看文件

@@ -1,5 +1,5 @@
1 1
 <!DOCTYPE html>
2
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
2
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"{% if rtl %} dir="rtl"{% endif %}>
3 3
     <head>
4 4
         <meta charset="UTF-8" />
5 5
         <meta name="description" content="Searx - a privacy-respecting, hackable metasearch engine" />
@@ -8,6 +8,9 @@
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 rtl %}
12
+        <link rel="stylesheet" href="{{ url_for('static', filename='css/style-rtl.css') }}" type="text/css" media="screen" />
13
+        {% endif %}
11 14
         {% if cookies['courgette-color'] %}
12 15
         <style type="text/css">
13 16
         {% include 'courgette/color.css' %}

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

@@ -5,8 +5,13 @@
5 5
     <div class="title"><h1>searx</h1></div>
6 6
     {% include 'courgette/search.html' %}
7 7
     <p class="top_margin">
8
+    	{% if rtl %}
9
+    	<a href="{{ url_for('preferences') }}" class="hmarg">{{ _('preferences') }}</a>
10
+    	{% endif %}
8 11
         <a href="{{ url_for('about') }}" class="hmarg">{{ _('about') }}</a>
12
+        {% if not rtl %}
9 13
         <a href="{{ url_for('preferences') }}" class="hmarg">{{ _('preferences') }}</a>
14
+        {% endif %}
10 15
     </p>
11 16
 </div>
12 17
 {% endblock %}

+ 1
- 1
searx/templates/courgette/preferences.html 查看文件

@@ -106,7 +106,7 @@
106 106
 
107 107
                 {% if not search_engine.private %}
108 108
                 <tr>
109
-                    <td>{{ search_engine.name }} ({{ shortcuts[search_engine.name] }})</td>
109
+                    <td>{{ search_engine.name }} ({{ shortcuts[search_engine.name] }})&lrm;</td>
110 110
                     <td>{{ _(categ) }}</td>
111 111
                     <td class="engine_checkbox">
112 112
                         <input type="checkbox" id="engine_{{ categ|replace(' ', '_') }}_{{ search_engine.name|replace(' ', '_') }}" name="engine_{{ search_engine.name }}__{{ categ }}"{% if (search_engine.name, categ) in blocked_engines %} checked="checked"{% endif %} />

+ 0
- 1
searx/templates/courgette/results.html 查看文件

@@ -8,7 +8,6 @@
8 8
 </div>
9 9
 <div id="results">
10 10
     <div id="sidebar">
11
-
12 11
         <div id="search_url">
13 12
             {{ _('Search URL') }}:
14 13
             <input type="text" value="{{ base_url }}?q={{ q|urlencode }}&amp;pageno={{ pageno }}{% if selected_categories %}&amp;category_{{ selected_categories|join("&category_")|replace(' ','+') }}{% endif %}" readonly />

+ 4
- 1
searx/templates/default/base.html 查看文件

@@ -1,5 +1,5 @@
1 1
 <!DOCTYPE html>
2
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
2
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"{% if rtl %} dir="rtl"{% endif %}>
3 3
     <head>
4 4
         <meta charset="UTF-8" />
5 5
         <meta name="description" content="Searx - a privacy-respecting, hackable metasearch engine" />
@@ -8,6 +8,9 @@
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 rtl %}
12
+        <link rel="stylesheet" href="{{ url_for('static', filename='css/style-rtl.css') }}" type="text/css" media="screen" />
13
+        {% endif %}
11 14
         <link rel="shortcut icon" href="{{ url_for('static', filename='img/favicon.png') }}?v=2" />
12 15
         {% block styles %}
13 16
         {% endblock %}

+ 5
- 0
searx/templates/default/index.html 查看文件

@@ -4,8 +4,13 @@
4 4
     <div class="title"><h1>searx</h1></div>
5 5
     {% include 'default/search.html' %}
6 6
     <p class="top_margin">
7
+    	{% if rtl %}
8
+    	<a href="{{ url_for('preferences') }}" class="hmarg">{{ _('preferences') }}</a>
9
+    	{% endif %}
7 10
         <a href="{{ url_for('about') }}" class="hmarg">{{ _('about') }}</a>
11
+        {% if not rtl %}
8 12
         <a href="{{ url_for('preferences') }}" class="hmarg">{{ _('preferences') }}</a>
13
+        {% endif %}
9 14
     </p>
10 15
 </div>
11 16
 {% include 'default/github_ribbon.html' %}

+ 2
- 2
searx/templates/default/preferences.html 查看文件

@@ -94,7 +94,7 @@
94 94
 
95 95
             {% if not search_engine.private %}
96 96
             <tr>
97
-                <td>{{ search_engine.name }} ({{ shortcuts[search_engine.name] }})</td>
97
+                <td>{{ search_engine.name }} ({{ shortcuts[search_engine.name] }})&lrm;</td>
98 98
                 <td>{{ _(categ) }}</td>
99 99
                 <td class="engine_checkbox">
100 100
                     <input type="checkbox" id="engine_{{ categ|replace(' ', '_') }}_{{ search_engine.name|replace(' ', '_') }}" name="engine_{{ search_engine.name }}__{{ categ }}"{% if (search_engine.name, categ) in blocked_engines %} checked="checked"{% endif %} />
@@ -113,7 +113,7 @@
113 113
     </p>
114 114
 
115 115
     <input type="submit" value="{{ _('save') }}" />
116
-    <div class="right preferences_back"><a href="{{ url_for('index') }}">{{ _('back') }}</a></div>
116
+    <div class="{% if rtl %}left{% else %}right{% endif %} preferences_back"><a href="{{ url_for('index') }}">{{ _('back') }}</a></div>
117 117
     </form>    
118 118
 </div>
119 119
 {% endblock %}

+ 2
- 2
searx/templates/default/results.html 查看文件

@@ -72,7 +72,7 @@
72 72
     <div id="pagination">
73 73
         {% if pageno > 1 %}
74 74
             <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
75
-                <div class="left">
75
+                <div class="{% if rtl %}right{% else %}left{% endif %}">
76 76
                 <input type="hidden" name="q" value="{{ q }}" />
77 77
                 {% for category in selected_categories %}
78 78
                 <input type="hidden" name="category_{{ category }}" value="1"/>
@@ -83,7 +83,7 @@
83 83
             </form>
84 84
         {% endif %}
85 85
         <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}">
86
-            <div class="right">
86
+            <div class="{% if rtl %}left{% else %}right{% endif %}">
87 87
                 {% for category in selected_categories %}
88 88
                 <input type="hidden" name="category_{{ category }}" value="1"/>
89 89
                 {% endfor %}

+ 1
- 1
searx/templates/oscar/base.html 查看文件

@@ -1,5 +1,5 @@
1 1
 <!DOCTYPE html>
2
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
2
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"{% if rtl %} dir="rtl"{% endif %}>
3 3
 <head>
4 4
     <meta charset="UTF-8" />
5 5
     <meta name="description" content="Searx - a privacy-respecting, hackable metasearch engine" />

+ 21
- 1
searx/templates/oscar/categories.html 查看文件

@@ -1,6 +1,16 @@
1 1
 <!-- used if scripts are disabled -->
2 2
 <noscript>
3 3
 <div id="categories" class="btn-group btn-toggle">
4
+{% if rtl %}
5
+{% for category in categories | reverse %}
6
+    <!--<div class="checkbox">-->
7
+        <input class="hidden" type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}_nojs" name="category_{{ category }}" {% if category in selected_categories %}checked="checked"{% endif %} />
8
+        <label class="btn btn-sm btn-primary active label_hide_if_not_checked" for="checkbox_{{ category|replace(' ', '_') }}_nojs">{{ _(category) }}</label>
9
+        <label class="btn btn-sm btn-default label_hide_if_checked" for="checkbox_{{ category|replace(' ', '_') }}_nojs">{{ _(category) }}</label>
10
+    <!--</div>-->
11
+    {% if category in selected_categories %}<input class="hidden" type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}_dis_activation" name="category_{{ category }}" value="off" checked="checked"/>{% endif %}
12
+{% endfor %}
13
+{% else %}
4 14
 {% for category in categories %}
5 15
     <!--<div class="checkbox">-->
6 16
         <input class="hidden" type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}_nojs" name="category_{{ category }}" {% if category in selected_categories %}checked="checked"{% endif %} />
@@ -9,14 +19,24 @@
9 19
     <!--</div>-->
10 20
     {% if category in selected_categories %}<input class="hidden" type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}_dis_activation" name="category_{{ category }}" value="off" checked="checked"/>{% endif %}
11 21
 {% endfor %}
22
+{% endif %}
12 23
 </div>
13 24
 </noscript>
14 25
 
15 26
 <div id="categories" class="btn-group btn-toggle hide_if_nojs" data-toggle="buttons">
27
+{% if rtl %}
28
+{% for category in categories | reverse %}
29
+	<label class="btn btn-sm {% if category in selected_categories %}btn-primary active{% else %}btn-default{% endif %}" data-btn-class="primary">
30
+        <input class="hidden" type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}" name="category_{{ category }}" {% if category in selected_categories %}checked="checked"{% endif %} />{{ _(category) }}
31
+    </label>
32
+{% endfor %}
33
+{% else %}
16 34
 {% for category in categories %}
17 35
     <label class="btn btn-sm {% if category in selected_categories %}btn-primary active{% else %}btn-default{% endif %}" data-btn-class="primary">
18
-        <input class="hidden" type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}" name="category_{{ category }}" {% if category in selected_categories %}checked="checked"{% endif %} />{{ _(category) }}</label>
36
+        <input class="hidden" type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}" name="category_{{ category }}" {% if category in selected_categories %}checked="checked"{% endif %} />{{ _(category) }}
37
+    </label>
19 38
 {% endfor %}
39
+{% endif %}
20 40
 </div>
21 41
 
22 42
 

+ 31
- 0
searx/templates/oscar/macros.html 查看文件

@@ -28,3 +28,34 @@
28 28
     <span class="label label-default pull-right">{{ result.engine }}</span>
29 29
     <p class="text-muted">{{ result.pretty_url }}</p>
30 30
 {%- endmacro %}
31
+
32
+<!-- Draw result footer -->
33
+{% macro result_footer_rtl(result) -%}
34
+    <div class="clearfix"></div>
35
+    <span class="label label-default pull-left">{{ result.engine }}</span>
36
+    <p class="text-muted">{{ result.pretty_url }}</p>
37
+{%- endmacro %}
38
+
39
+{% macro preferences_item_header(info, label) -%}
40
+    {% if not rtl %}
41
+    <div class="row form-group">
42
+        <label class="col-sm-3 col-md-2">{{ label }}</label>
43
+        <div class="col-sm-4 col-md-4">
44
+    {% else %}
45
+    <div class="row form-group">
46
+        <span class="col-sm-5 col-md-6 help-block">{{ info }}</span>
47
+        <div class="col-sm-4 col-md-4">
48
+    {% endif %}
49
+{%- endmacro %}
50
+
51
+{% macro preferences_item_footer(info, label) -%}
52
+    {% if not rtl %}
53
+        </div>
54
+        <span class="col-sm-5 col-md-6 help-block">{{ info }}</span>
55
+    </div>
56
+    {% else %}
57
+        </div>
58
+        <label class="col-sm-3 col-md-2">{{ label }}</label>
59
+    </div>
60
+    {% endif %}
61
+{%- endmacro %}

+ 19
- 0
searx/templates/oscar/navbar.html 查看文件

@@ -1,6 +1,24 @@
1 1
 <!-- Static navbar -->
2 2
 <div class="navbar navbar-default" role="navigation">
3 3
     <div class="container-fluid">
4
+        {% if rtl %}
5
+        <div class="navbar-collapse collapse navbar-left">
6
+            <ul class="nav navbar-nav navbar-left"> <!-- results.html -->
7
+                <li{% if template_name == 'preferences.html' %} class="active"{% endif %}><a href="{{ url_for('preferences') }}" class="hmarg">{{ _('preferences') }}</a></li>
8
+                <li{% if template_name == 'about.html' %} class="active"{% endif %}><a href="{{ url_for('about') }}" class="hmarg">{{ _('about') }}</a></li>
9
+                <li{% if template_name == 'index.html' %} class="active"{% endif %}><a href="{{ url_for('index') }}" class="hmarg">{{ _('home') }}</a></li>
10
+            </ul>
11
+        </div>
12
+        <div class="navbar-header navbar-right">
13
+            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
14
+                <span class="sr-only">{{ _('Toggle navigation') }}</span>
15
+                <span class="icon-bar"></span>
16
+                <span class="icon-bar"></span>
17
+                <span class="icon-bar"></span>
18
+            </button>
19
+            <a class="navbar-brand" href="{{ url_for('index') }}">searx</a>
20
+        </div>
21
+        {% else %}
4 22
         <div class="navbar-header">
5 23
             <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
6 24
                 <span class="sr-only">{{ _('Toggle navigation') }}</span>
@@ -17,5 +35,6 @@
17 35
                 <li{% if template_name == 'preferences.html' %} class="active"{% endif %}><a href="{{ url_for('preferences') }}" class="hmarg">{{ _('preferences') }}</a></li>
18 36
             </ul>
19 37
         </div><!--/.nav-collapse -->
38
+        {% endif %}
20 39
     </div><!--/.container-fluid -->
21 40
 </div>

+ 83
- 80
searx/templates/oscar/preferences.html 查看文件

@@ -1,3 +1,4 @@
1
+{% from 'oscar/macros.html' import preferences_item_header, preferences_item_header_rtl, preferences_item_footer, preferences_item_footer_rtl %}
1 2
 {% extends "oscar/base.html" %}
2 3
 {% block title %}{{ _('preferences') }} - {% endblock %}
3 4
 {% block site_alert_warning_nojs %}
@@ -12,7 +13,7 @@
12 13
     <form method="post" action="{{ url_for('preferences') }}" id="search_form">
13 14
 
14 15
     <!-- Nav tabs -->
15
-    <ul class="nav nav-tabs hide_if_nojs" role="tablist" style="margin-bottom:20px;">
16
+    <ul class="nav nav-tabs nav-justified hide_if_nojs" role="tablist" style="margin-bottom:20px;">
16 17
       <li class="active"><a href="#tab_general" role="tab" data-toggle="tab">{{ _('General') }}</a></li>
17 18
       <li><a href="#tab_engine" role="tab" data-toggle="tab">{{ _('Engines') }}</a></li>
18 19
     </ul>
@@ -26,96 +27,94 @@
26 27
             <fieldset>
27 28
             <div class="container-fluid">
28 29
                 <div class="row form-group">
29
-                    <label class="col-sm-3 col-md-2">{{ _('Default categories') }}</label>
30
+                    {% if rtl %}
30 31
                     <div class="col-sm-11 col-md-10">
31 32
                         {% include 'oscar/categories.html' %}
32 33
                     </div>
33
-                </div>
34
-                <div class="row form-group">
35
-                    <label class="col-sm-3 col-md-2">{{ _('Search language') }}</label>
36
-                    <div class="col-sm-4 col-md-4">
37
-                        <select class="form-control" name='language'>
38
-                            <option value="all" {% if current_language == 'all' %}selected="selected"{% endif %}>{{ _('Automatic') }}</option>
39
-                            {% for lang_id,lang_name,country_name in language_codes %}
40
-                            <option value="{{ lang_id }}" {% if lang_id == current_language %}selected="selected"{% endif %}>{{ lang_name }} ({{ country_name }}) - {{ lang_id }}</option>
41
-                            {% endfor %}
42
-                        </select>
43
-                    </div>
44
-                    <span class="col-sm-5 col-md-6 help-block">{{ _('What language do you prefer for search?') }}</span>
45
-                </div>
46
-                <div class="row form-group">
47
-                    <label class="col-sm-3 col-md-2">{{ _('Interface language') }}</label>
48
-                    <div class="col-sm-4 col-md-4">
49
-                        <select class="form-control" name='locale'>
50
-                            {% for locale_id,locale_name in locales.items() %}
51
-                            <option value="{{ locale_id }}" {% if locale_id == current_locale %}selected="selected"{% endif %}>{{ locale_name }}</option>
52
-                            {% endfor %}
53
-                        </select>
34
+                    <label class="col-sm-3 col-md-2">{{ _('Default categories') }}</label>
35
+                    {% else %}
36
+                    <label class="col-sm-3 col-md-2">{{ _('Default categories') }}</label>
37
+                    <div class="col-sm-11 col-md-10">
38
+                        {% include 'oscar/categories.html' %}
54 39
                     </div>
55
-                    <span class="col-sm-5 col-md-6 help-block">{{ _('Change the language of the layout') }}</span>
40
+                    {% endif %}
56 41
                 </div>
57
-                <div class="row form-group">
58
-                    <label class="col-sm-3 col-md-2">{{ _('Autocomplete') }}</label>
59
-                    <div class="col-sm-4 col-md-4">
42
+                {% set language_label = _('Search language') %}
43
+                {% set language_info = _('What language do you prefer for search?') %}
44
+                {{ preferences_item_header(language_info, language_label) }}
45
+                    <select class="form-control" name='language'>
46
+                        <option value="all" {% if current_language == 'all' %}selected="selected"{% endif %}>{{ _('Automatic') }}</option>
47
+                        {% for lang_id,lang_name,country_name in language_codes %}
48
+                        <option value="{{ lang_id }}" {% if lang_id == current_language %}selected="selected"{% endif %}>{{ lang_name }} ({{ country_name }}) - {{ lang_id }}</option>
49
+                        {% endfor %}
50
+                    </select>
51
+                {{ preferences_item_footer(language_info, language_label) }}
60 52
 
61
-                        <select class="form-control" name="autocomplete">
62
-                            <option value=""> - </option>
63
-                            {% for backend in autocomplete_backends %}
64
-                            <option value="{{ backend }}" {% if backend == autocomplete %}selected="selected"{% endif %}>{{ backend }}</option>
65
-                            {% endfor %}
66
-                        </select>
67
-                    </div>
68
-                    <span class="col-sm-5 col-md-6 help-block">{{ _('Find stuff as you type') }}</span>
69
-                </div>
70
-                <div class="row form-group">
71
-                    <label class="col-sm-3 col-md-2">{{ _('Image proxy') }}</label>
72
-                    <div class="col-sm-4 col-md-4">
73
-                        <select class="form-control" name='image_proxy'>
74
-                            <option value="1" {% if image_proxy  %}selected="selected"{% endif %}>{{ _('Enabled') }}</option>
75
-                            <option value="" {% if not image_proxy %}selected="selected"{% endif %}>{{ _('Disabled')}}</option>
76
-                        </select>
77
-                    </div>
78
-                    <span class="col-sm-5 col-md-6 help-block">{{ _('Proxying image results through searx') }}</span>
79
-                </div>
80
-                <div class="row form-group">
81
-                    <label class="col-sm-3 col-md-2">{{ _('Method') }}</label>
82
-                    <div class="col-sm-4 col-md-4">
83
-                        <select class="form-control" name='method'>
84
-                            <option value="POST" {% if method == 'POST' %}selected="selected"{% endif %}>POST</option>
85
-                            <option value="GET" {% if method == 'GET' %}selected="selected"{% endif %}>GET</option>
86
-                        </select>
87
-                    </div>
88
-                    <span class="col-sm-5 col-md-6 help-block">{{ _('Change how forms are submited, <a href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods" rel="external">learn more about request methods</a>') }}</span>
89
-                </div>
90
-                <div class="row form-group">
91
-                    <label class="col-sm-3 col-md-2">{{ _('SafeSearch') }}</label>
92
-                    <div class="col-sm-4 col-md-4">
93
-                        <select class="form-control" name='safesearch'>
94
-                            <option value="2" {% if safesearch == '2' %}selected="selected"{% endif %}>{{ _('Strict') }}</option>
95
-                            <option value="1" {% if safesearch == '1' %}selected="selected"{% endif %}>{{ _('Moderate') }}</option>
96
-                            <option value="0" {% if safesearch == '0' %}selected="selected"{% endif %}>{{ _('None') }}</option>
97
-                        </select>
98
-                    </div>
99
-                    <span class="col-sm-5 col-md-6 help-block">{{ _('Filter explicite content') }}</span>
100
-                </div>
101
-                <div class="row form-group">
102
-                    <label class="col-sm-3 col-md-2">{{ _('Themes') }}</label>
103
-                    <div class="col-sm-4 col-md-4">
104
-                        <select class="form-control" name="theme">
105
-                            {% for name in themes %}
106
-                            <option value="{{ name }}" {% if name == theme %}selected="selected"{% endif %}>{{ name }}</option>
107
-                            {% endfor %}
108
-                        </select>
109
-                    </div>
110
-                    <span class="col-sm-5 col-md-6 help-block">{{ _('Change searx layout') }}</span>
111
-                </div>
53
+                {% set locale_label = _('Interface language') %}
54
+                {% set locale_info = _('Change the language of the layout') %}
55
+                {{ preferences_item_header(locale_info, locale_label) }}
56
+                    <select class="form-control" name='locale'>
57
+                        {% for locale_id,locale_name in locales.items() %}
58
+                        <option value="{{ locale_id }}" {% if locale_id == current_locale %}selected="selected"{% endif %}>{{ locale_name }}</option>
59
+                        {% endfor %}
60
+                    </select>
61
+                {{ preferences_item_footer(locale_info, locale_label) }}
62
+
63
+                {% set autocomplete_label = _('Autocomplete') %}
64
+                {% set autocomplete_info = _('Find stuff as you type') %}
65
+                {{ preferences_item_header(autocomplete_info, autocomplete_label) }}
66
+                    <select class="form-control" name="autocomplete">
67
+                        <option value=""> - </option>
68
+                        {% for backend in autocomplete_backends %}
69
+                        <option value="{{ backend }}" {% if backend == autocomplete %}selected="selected"{% endif %}>{{ backend }}</option>
70
+                        {% endfor %}
71
+                    </select>
72
+                {{ preferences_item_footer(autocomplete_info, autocomplete_label) }}
73
+
74
+                {% set image_proxy_label = _('Image proxy') %}
75
+                {% set image_proxy_info = _('Proxying image results through searx') %}
76
+                {{ preferences_item_header(image_proxy_info, image_proxy_label) }}
77
+                    <select class="form-control" name='image_proxy'>
78
+                        <option value="1" {% if image_proxy  %}selected="selected"{% endif %}>{{ _('Enabled') }}</option>
79
+                        <option value="" {% if not image_proxy %}selected="selected"{% endif %}>{{ _('Disabled')}}</option>
80
+                    </select>
81
+                {{ preferences_item_footer(image_proxy_info, image_proxy_label) }}
82
+
83
+                {% set method_label = _('Method') %}
84
+                {% set method_info = _('Change how forms are submited, <a href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods" rel="external">learn more about request methods</a>') %}
85
+                {{ preferences_item_header(method_info, method_label) }}
86
+                    <select class="form-control" name='method'>
87
+                        <option value="POST" {% if method == 'POST' %}selected="selected"{% endif %}>POST</option>
88
+                        <option value="GET" {% if method == 'GET' %}selected="selected"{% endif %}>GET</option>
89
+                    </select>
90
+                {{ preferences_item_footer(method_info, method_label) }}
91
+
92
+                {% set safesearch_label = _('SafeSearch') %}
93
+                {% set safesearch_info = _('Filter content') %}
94
+                {{ preferences_item_header(safesearch_info, safesearch_label) }}
95
+                    <select class="form-control" name='safesearch'>
96
+                        <option value="2" {% if safesearch == '2' %}selected="selected"{% endif %}>{{ _('Strict') }}</option>
97
+                        <option value="1" {% if safesearch == '1' %}selected="selected"{% endif %}>{{ _('Moderate') }}</option>
98
+                        <option value="0" {% if safesearch == '0' %}selected="selected"{% endif %}>{{ _('None') }}</option>
99
+                    </select>
100
+                {{ preferences_item_footer(safesearch_info, safesearch_label) }}
101
+
102
+                {% set theme_label = _('Themes') %}
103
+                {% set theme_info = _('Change searx layout') %}
104
+                {{ preferences_item_header(theme_info, theme_label) }}
105
+                    <select class="form-control" name="theme">
106
+                        {% for name in themes %}
107
+                        <option value="{{ name }}" {% if name == theme %}selected="selected"{% endif %}>{{ name }}</option>
108
+                        {% endfor %}
109
+                    </select>
110
+                {{ preferences_item_footer(theme_info, theme_label) }}
112 111
             </div>
113 112
             </fieldset>
114 113
         </div>
115 114
         <div class="tab-pane active_if_nojs" id="tab_engine">
116 115
 
117 116
             <!-- Nav tabs -->
118
-            <ul class="nav nav-tabs hide_if_nojs" role="tablist" style="margin-bottom:20px;">
117
+            <ul class="nav nav-tabs nav-justified hide_if_nojs" role="tablist" style="margin-bottom:20px;">
119 118
                 {% for (categ,search_engines) in categs %}
120 119
                 <li{% if loop.first %} class="active"{% endif %}><a href="#tab_engine_{{ categ|replace(' ', '_') }}" role="tab" data-toggle="tab">{{ _(categ) }}</a></li>
121 120
                 {% endfor %}
@@ -136,7 +135,9 @@
136 135
                     {% for search_engine in search_engines %}
137 136
                         {% if not search_engine.private %}
138 137
                             <div class="row">
138
+                                {% if not rtl %}
139 139
                                 <div class="col-xs-6 col-sm-4 col-md-4">{{ search_engine.name }} ({{ shortcuts[search_engine.name] }})</div>
140
+                                {% endif %}
140 141
                                 <div class="col-xs-6 col-sm-4 col-md-4">
141 142
                                     <div class="checkbox">
142 143
                                     <input class="hidden" type="checkbox" id="engine_{{ categ|replace(' ', '_') }}_{{ search_engine.name|replace(' ', '_') }}" name="engine_{{ search_engine.name }}__{{ categ }}"{% if (search_engine.name, categ) in blocked_engines %} checked="checked"{% endif %} />
@@ -144,6 +145,9 @@
144 145
                                     <label class="btn btn-danger label_hide_if_not_checked" for="engine_{{ categ|replace(' ', '_') }}_{{ search_engine.name|replace(' ', '_') }}">{{ _('Allow') }}</label>
145 146
                                     </div>
146 147
                                 </div>
148
+                                {% if rtl %}
149
+                                <div class="col-xs-6 col-sm-4 col-md-4">{{ search_engine.name }} ({{ shortcuts[search_engine.name] }})&lrm;</div>
150
+                                {% endif %}
147 151
                             </div>
148 152
                         {% endif %}
149 153
                     {% endfor %}
@@ -154,7 +158,6 @@
154 158
             </div>
155 159
         </div>
156 160
     </div>
157
-
158 161
     <p class="text-muted" style="margin:20px 0;">{{ _('These settings are stored in your cookies, this allows us not to store this data about you.') }}
159 162
     <br />
160 163
     {{ _("These cookies serve your sole convenience, we don't use these cookies to track you.") }}

+ 5
- 1
searx/templates/oscar/result_templates/code.html 查看文件

@@ -1,4 +1,4 @@
1
-{% from 'oscar/macros.html' import result_header, result_sub_header, result_footer, icon %}
1
+{% from 'oscar/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon %}
2 2
 
3 3
 {{ result_header(result, favicons) }}
4 4
 {{ result_sub_header(result) }}
@@ -9,4 +9,8 @@
9 9
 
10 10
 {{ result.codelines|code_highlighter(result.code_language)|safe }}
11 11
 
12
+{% if rtl %}
13
+{{ result_footer_rtl(result) }}
14
+{% else %}
12 15
 {{ result_footer(result) }}
16
+{% endif %}

+ 5
- 1
searx/templates/oscar/result_templates/default.html 查看文件

@@ -1,4 +1,4 @@
1
-{% from 'oscar/macros.html' import result_header, result_sub_header, result_footer, icon %}
1
+{% from 'oscar/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon %}
2 2
 
3 3
 {{ result_header(result, favicons) }}
4 4
 {{ result_sub_header(result) }}
@@ -15,4 +15,8 @@
15 15
 
16 16
 {% if result.content %}<p class="result-content">{{ result.content|safe }}</p>{% endif %}
17 17
 
18
+{% if rtl %}
19
+{{ result_footer_rtl(result) }}
20
+{% else %}
18 21
 {{ result_footer(result) }}
22
+{% endif %}

+ 5
- 1
searx/templates/oscar/result_templates/map.html 查看文件

@@ -1,4 +1,4 @@
1
-{% from 'oscar/macros.html' import result_header, result_sub_header, result_footer, icon %}
1
+{% from 'oscar/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon %}
2 2
 
3 3
 {{ result_header(result, favicons) }}
4 4
 {{ result_sub_header(result) }}
@@ -65,4 +65,8 @@
65 65
     </div>
66 66
 {% endif %}
67 67
 
68
+{% if rtl %}
69
+{{ result_footer_rtl(result) }}
70
+{% else %}
68 71
 {{ result_footer(result) }}
72
+{% endif %}

+ 5
- 1
searx/templates/oscar/result_templates/torrent.html 查看文件

@@ -1,4 +1,4 @@
1
-{% from 'oscar/macros.html' import result_header, result_sub_header, result_footer, icon %}
1
+{% from 'oscar/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon %}
2 2
 
3 3
 {{ result_header(result, favicons) }}
4 4
 {{ result_sub_header(result) }}
@@ -18,4 +18,8 @@
18 18
 
19 19
 </p>
20 20
 
21
+{% if rtl %}
22
+{{ result_footer_rtl(result) }}
23
+{% else %}
21 24
 {{ result_footer(result) }}
25
+{% endif %}

+ 4
- 0
searx/templates/oscar/result_templates/videos.html 查看文件

@@ -20,4 +20,8 @@
20 20
     </div>
21 21
 </div>
22 22
 
23
+{% if rtl %}
24
+{{ result_footer_rtl(result) }}
25
+{% else %}
23 26
 {{ result_footer(result) }}
27
+{% endif %}

+ 22
- 0
searx/templates/oscar/results.html 查看文件

@@ -33,6 +33,27 @@
33 33
             <div class="clearfix"></div>
34 34
 
35 35
             {% if paging %}
36
+            {% if rtl %}
37
+            <div id="pagination">
38
+                <div class="pull-left">
39
+                    <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" class="pull-left">
40
+                        <input type="hidden" name="q" value="{{ q }}" />
41
+                        {% for category in selected_categories %}<input type="hidden" name="category_{{ category }}" value="1"/>{% endfor %}
42
+                        <input type="hidden" name="q" value="{{ q }}" />
43
+                        <input type="hidden" name="pageno" value="{{ pageno+1 }}" />
44
+                        <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-backward"></span> {{ _('next page') }}</button>
45
+                    </form>
46
+                </div>
47
+                <div class="pull-right">
48
+                    <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}"  class="pull-left">
49
+                        {% for category in selected_categories %}<input type="hidden" name="category_{{ category }}" value="1"/>{% endfor %}
50
+                        <input type="hidden" name="pageno" value="{{ pageno-1 }}" />
51
+                        <button type="submit" class="btn btn-default" {% if pageno == 1 %}disabled{% endif %}><span class="glyphicon glyphicon-forward"></span> {{ _('previous page') }}</button>
52
+                    </form>
53
+                </div>
54
+            </div><!-- /#pagination -->
55
+            <div class="clearfix"></div>
56
+            {% else %}
36 57
             <div id="pagination">
37 58
                 <div class="pull-left">
38 59
                     <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" class="pull-left">
@@ -53,6 +74,7 @@
53 74
             </div><!-- /#pagination -->
54 75
             <div class="clearfix"></div>
55 76
             {% endif %}
77
+            {% endif %}
56 78
         </div><!-- /#main_results -->
57 79
 
58 80
         <div class="col-sm-4" id="sidebar_results">

+ 4
- 0
searx/templates/oscar/search_full.html 查看文件

@@ -1,7 +1,11 @@
1 1
 {% from 'oscar/macros.html' import icon %}
2 2
 
3 3
 <form method="{{ method or 'POST' }}" action="{{ url_for('index') }}" id="search_form" role="search">
4
+    {% if rtl %}
5
+    <div class="input-group">
6
+    {% else %}
4 7
     <div class="input-group col-md-8 col-md-offset-2">
8
+    {% endif %}
5 9
         <input type="search" name="q" class="form-control input-lg autofocus" id="q" placeholder="{{ _('Search for...') }}" autocomplete="off" value="{{ q }}">
6 10
         <span class="input-group-btn">
7 11
             <button type="submit" class="btn btn-default input-lg"><span class="hide_if_nojs">{{ icon('search') }}</span><span class="hidden active_if_nojs">{{ _('Start search') }}</span></button>

+ 10
- 3
searx/webapp.py 查看文件

@@ -20,7 +20,7 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
20 20
 if __name__ == '__main__':
21 21
     from sys import path
22 22
     from os.path import realpath, dirname
23
-    path.append(realpath(dirname(realpath(__file__))+'/../'))
23
+    path.append(realpath(dirname(realpath(__file__)) + '/../'))
24 24
 
25 25
 import json
26 26
 import cStringIO
@@ -85,10 +85,13 @@ app.secret_key = settings['server']['secret_key']
85 85
 
86 86
 babel = Babel(app)
87 87
 
88
+rtl_locales = ['ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'glk', 'he',
89
+               'ku', 'mzn', 'pnb'', ''ps', 'sd', 'ug', 'ur', 'yi']
90
+
88 91
 global_favicons = []
89 92
 for indice, theme in enumerate(themes):
90 93
     global_favicons.append([])
91
-    theme_img_path = searx_dir+"/static/themes/"+theme+"/img/icons/"
94
+    theme_img_path = searx_dir + "/static/themes/" + theme + "/img/icons/"
92 95
     for (dirpath, dirnames, filenames) in os.walk(theme_img_path):
93 96
         global_favicons[indice].extend(filenames)
94 97
 
@@ -262,6 +265,9 @@ def render(template_name, override_theme=None, **kwargs):
262 265
     if 'autocomplete' not in kwargs:
263 266
         kwargs['autocomplete'] = autocomplete
264 267
 
268
+    if get_locale() in rtl_locales and 'rtl' not in kwargs:
269
+        kwargs['rtl'] = True
270
+
265 271
     kwargs['searx_version'] = VERSION_STRING
266 272
 
267 273
     kwargs['method'] = request.cookies.get('method', 'POST')
@@ -396,6 +402,7 @@ def about():
396 402
     """Render about page"""
397 403
     return render(
398 404
         'about.html',
405
+        rtl=False,
399 406
     )
400 407
 
401 408
 
@@ -592,7 +599,7 @@ def image_proxy():
592 599
     img = ''
593 600
     chunk_counter = 0
594 601
 
595
-    for chunk in resp.iter_content(1024*1024):
602
+    for chunk in resp.iter_content(1024 * 1024):
596 603
         chunk_counter += 1
597 604
         if chunk_counter > 5:
598 605
             return '', 502  # Bad gateway - file is too big (>5M)