Browse Source

Merge branch 'master' of https://github.com/asciimoo/searx into feature/seedpeer-engine-integration

Pydo 8 years ago
parent
commit
41ce76e9c9

+ 2
- 1
searx/preferences.py View File

@@ -227,7 +227,8 @@ class Preferences(object):
227 227
                                    'safesearch': MapSetting(settings['search']['safe_search'], map={'0': 0,
228 228
                                                                                                     '1': 1,
229 229
                                                                                                     '2': 2}),
230
-                                   'theme': EnumStringSetting(settings['ui']['default_theme'], choices=themes)}
230
+                                   'theme': EnumStringSetting(settings['ui']['default_theme'], choices=themes),
231
+                                   'results_on_new_tab': MapSetting(False, map={'0': False, '1': True})}
231 232
 
232 233
         self.engines = EnginesSetting('engines', choices=engines)
233 234
         self.plugins = PluginsSetting('plugins', choices=plugins)

+ 3
- 1
searx/templates/courgette/404.html View File

@@ -2,6 +2,8 @@
2 2
 {% block content %}
3 3
 <div class="center">
4 4
     <h1>{{ _('Page not found') }}</h1>
5
-    <p>{{ _('Go to <a href="/">search page</a>.') }}</p>
5
+    {% autoescape false %}
6
+    <p>{{ _('Go to %(search_page)s.', search_page='<a href="{}">{}</a>'.decode('utf-8').format(url_for('index'), _('search page'))) }}</p>
7
+    {% endautoescape %}
6 8
 </div>
7 9
 {% endblock %}

+ 2
- 2
searx/templates/courgette/result_templates/code.html View File

@@ -1,8 +1,8 @@
1 1
 <div class="result {{ result.class }}">
2
-    <h3 class="result_title">{% if result['favicon'] %}<img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" alt="{{result['favicon']}}" />{% endif %}<a href="{{ result.url }}" rel="noreferrer">{{ result.title|safe }}</a></h3>
2
+    <h3 class="result_title">{% if result['favicon'] %}<img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" alt="{{result['favicon']}}" />{% endif %}<a href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ result.title|safe }}</a></h3>
3 3
     {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span>{% endif %}
4 4
     <p class="content">{% if result.img_src %}<img src="{{ image_proxify(result.img_src) }}" class="image" />{% endif %}{% if result.content %}{{ result.content|safe }}<br class="last"/>{% endif %}</p>
5
-    {% if result.repository %}<p class="content"><a href="{{ result.repository|safe }}" rel="noreferrer">{{ result.repository }}</a></p>{% endif %}
5
+    {% if result.repository %}<p class="content"><a href="{{ result.repository|safe }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ result.repository }}</a></p>{% endif %}
6 6
     <div dir="ltr">
7 7
     {{ result.codelines|code_highlighter(result.code_language)|safe }}
8 8
 	</div>

+ 1
- 1
searx/templates/courgette/result_templates/default.html View File

@@ -5,7 +5,7 @@
5 5
     {% endif %}
6 6
 
7 7
     <div>
8
-        <h3 class="result_title"><a href="{{ result.url }}" rel="noreferrer">{{ result.title|safe }}</a></h3>
8
+        <h3 class="result_title"><a href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ result.title|safe }}</a></h3>
9 9
         {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span>{% endif %}
10 10
         <p class="content">{% if result.content %}{{ result.content|safe }}<br />{% endif %}</p>
11 11
         <p class="url">{{ result.pretty_url }}&lrm;</p>

+ 2
- 2
searx/templates/courgette/result_templates/images.html View File

@@ -1,6 +1,6 @@
1 1
 <div class="image_result">
2 2
     <p>
3
-        <a href="{{ result.img_src }}" rel="noreferrer"><img src="{% if result.thumbnail_src %}{{ image_proxify(result.thumbnail_src) }}{% else %}{{ image_proxify(result.img_src) }}{% endif %}" title="{{ result.title|striptags }}" alt="{{ result.title|striptags }}"/></a>
4
-        <span class="url"><a href="{{ result.url }}" rel="noreferrer" class="small_font">{{ _('original context') }}</a></span>
3
+        <a href="{{ result.img_src }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}><img src="{% if result.thumbnail_src %}{{ image_proxify(result.thumbnail_src) }}{% else %}{{ image_proxify(result.img_src) }}{% endif %}" title="{{ result.title|striptags }}" alt="{{ result.title|striptags }}"/></a>
4
+        <span class="url"><a href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %} class="small_font">{{ _('original context') }}</a></span>
5 5
     </p>
6 6
 </div>

+ 1
- 1
searx/templates/courgette/result_templates/map.html View File

@@ -5,7 +5,7 @@
5 5
     {% endif %}
6 6
 
7 7
     <div>
8
-        <h3 class="result_title"><a href="{{ result.url }}" rel="noreferrer">{{ result.title|safe }}</a></h3>
8
+        <h3 class="result_title"><a href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ result.title|safe }}</a></h3>
9 9
         {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span>{% endif %}
10 10
         <p class="content">{% if result.content %}{{ result.content|safe }}<br />{% endif %}</p>
11 11
         <p class="url">{{ result.pretty_url }}&lrm;</p>

+ 2
- 2
searx/templates/courgette/result_templates/torrent.html View File

@@ -2,12 +2,12 @@
2 2
     {% if "icon_"~result.engine~".ico" in favicons %}
3 3
     <img width="14" height="14" class="favicon" src="{{ url_for('static', filename='img/icons/icon_'+result.engine+'.ico') }}" alt="{{result.engine}}" />
4 4
     {% endif %}
5
-    <h3 class="result_title"><a href="{{ result.url }}" rel="noreferrer">{{ result.title|safe }}</a></h3>
5
+    <h3 class="result_title"><a href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ result.title|safe }}</a></h3>
6 6
     {% if result.content %}<span class="content">{{ result.content|safe }}</span><br />{% endif %}
7 7
     <span class="stats">{{ _('Seeder') }} : {{ result.seed }}, {{ _('Leecher') }} : {{ result.leech }}</span><br />
8 8
     <span>
9 9
         {% if result.magnetlink %}<a href="{{ result.magnetlink }}" class="magnetlink">{{ _('magnet link') }}</a>{% endif %} 
10
-        {% if result.torrentfile %}<a href="{{ result.torrentfile }}" class="torrentfile" rel="noreferrer">{{ _('torrent file') }}</a>{% endif %}
10
+        {% if result.torrentfile %}<a href="{{ result.torrentfile }}" class="torrentfile" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ _('torrent file') }}</a>{% endif %}
11 11
     </span>
12 12
     <p class="url">{{ result.pretty_url }}&lrm;</p>
13 13
 </div>

+ 2
- 2
searx/templates/courgette/result_templates/videos.html View File

@@ -3,8 +3,8 @@
3 3
     <img width="14" height="14" class="favicon" src="{{ url_for('static', filename='img/icons/icon_'+result.engine+'.ico') }}" alt="{{result.engine}}" />
4 4
 	{% endif %}
5 5
 
6
-    <h3 class="result_title"><a href="{{ result.url }}" rel="noreferrer">{{ result.title|safe }}</a></h3>
6
+    <h3 class="result_title"><a href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ result.title|safe }}</a></h3>
7 7
     {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span><br />{% endif %}
8
-    <a href="{{ result.url }}" rel="noreferrer"><img width="400" src="{{ image_proxify(result.thumbnail) }}" title="{{ result.title|striptags }}" alt="{{ result.title|striptags }}"/></a>
8
+    <a href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}><img width="400" src="{{ image_proxify(result.thumbnail) }}" title="{{ result.title|striptags }}" alt="{{ result.title|striptags }}"/></a>
9 9
     <p class="url">{{ result.pretty_url }}&lrm;</p>
10 10
 </div>

+ 3
- 1
searx/templates/default/404.html View File

@@ -2,6 +2,8 @@
2 2
 {% block content %}
3 3
 <div class="center">
4 4
     <h1>{{ _('Page not found') }}</h1>
5
-    <p>{{ _('Go to <a href="/">search page</a>.') }}</p>
5
+    {% autoescape false %}
6
+    <p>{{ _('Go to %(search_page)s.', search_page='<a href="{}">{}</a>'.decode('utf-8').format(url_for('index'), _('search page'))) }}</p>
7
+    {% endautoescape %}
6 8
 </div>
7 9
 {% endblock %}

+ 1
- 1
searx/templates/default/infobox.html View File

@@ -24,7 +24,7 @@
24 24
     <div class="urls">
25 25
         <ul>
26 26
             {% for url in infobox.urls %}
27
-            <li class="url"><bdi><a href="{{ url.url }}" rel="noreferrer">{{ url.title }}</a></bdi></li>
27
+            <li class="url"><bdi><a href="{{ url.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ url.title }}</a></bdi></li>
28 28
             {% endfor %}
29 29
         </ul>
30 30
     </div>

+ 9
- 0
searx/templates/default/preferences.html View File

@@ -81,6 +81,15 @@
81 81
         </p>
82 82
     </fieldset>
83 83
     <fieldset>
84
+        <legend>{{ _('Results on new tabs') }}</legend>
85
+        <p>
86
+            <select name='results_on_new_tab'>
87
+                <option value="1" {% if results_on_new_tab %}selected="selected"{% endif %}>{{ _('On') }}</option>
88
+                <option value="0" {% if not results_on_new_tab %}selected="selected"{% endif %}>{{ _('Off')}}</option>
89
+            </select>
90
+        </p>
91
+    </fieldset>
92
+    <fieldset>
84 93
     <legend>{{ _('Currently used search engines') }}</legend>
85 94
 
86 95
     <table>

+ 3
- 3
searx/templates/default/result_templates/code.html View File

@@ -1,9 +1,9 @@
1 1
 <div class="result {{ result.class }}">
2
-    <h3 class="result_title"> {% if result['favicon'] %}<img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" alt="{{result['favicon']}}" />{% endif %}<a href="{{ result.url }}" rel="noreferrer">{{ result.title|safe }}</a></h3>
3
-    <p class="url">{{ result.pretty_url }}&lrm; <a class="cache_link" href="https://web.archive.org/web/{{ result.url }}" rel="noreferrer">{{ _('cached') }}</a></p>
2
+    <h3 class="result_title"> {% if result['favicon'] %}<img width="14" height="14" class="favicon" src="static/{{theme}}/img/icon_{{result['favicon']}}.ico" alt="{{result['favicon']}}" />{% endif %}<a href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ result.title|safe }}</a></h3>
3
+    <p class="url">{{ result.pretty_url }}&lrm; <a class="cache_link" href="https://web.archive.org/web/{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ _('cached') }}</a></p>
4 4
     {% if result.publishedDate %}<p class="published_date">{{ result.publishedDate }}</p>{% endif %}
5 5
     <p class="content">{% if result.img_src %}<img src="{{ image_proxify(result.img_src) }}" class="image" />{% endif %}{% if result.content %}{{ result.content|safe }}<br class="last"/>{% endif %}</p>
6
-    {% if result.repository %}<p class="result-content"><a href="{{ result.repository|safe }}" rel="noreferrer">{{ result.repository }}</a></p>{% endif %}
6
+    {% if result.repository %}<p class="result-content"><a href="{{ result.repository|safe }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ result.repository }}</a></p>{% endif %}
7 7
     
8 8
     <div dir="ltr">
9 9
     {{ result.codelines|code_highlighter(result.code_language)|safe }}

+ 2
- 2
searx/templates/default/result_templates/default.html View File

@@ -1,6 +1,6 @@
1 1
 <div class="result {{ result.class }}">
2
-    <h3 class="result_title">{% if "icon_"~result.engine~".ico" in favicons %}<img width="14" height="14" class="favicon" src="{{ url_for('static', filename='img/icons/icon_'+result.engine+'.ico') }}" alt="{{result.engine}}" />{% endif %}<a href="{{ result.url }}" rel="noreferrer">{{ result.title|safe }}</a></h3>
3
-    <p class="url">{{ result.pretty_url }}&lrm; <a class="cache_link" href="https://web.archive.org/web/{{ result.url }}" rel="noreferrer">{{ _('cached') }}</a>
2
+    <h3 class="result_title">{% if "icon_"~result.engine~".ico" in favicons %}<img width="14" height="14" class="favicon" src="{{ url_for('static', filename='img/icons/icon_'+result.engine+'.ico') }}" alt="{{result.engine}}" />{% endif %}<a href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ result.title|safe }}</a></h3>
3
+    <p class="url">{{ result.pretty_url }}&lrm; <a class="cache_link" href="https://web.archive.org/web/{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ _('cached') }}</a>
4 4
     {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span>{% endif %}</p>
5 5
     <p class="content">{% if result.img_src %}<img src="{{ image_proxify(result.img_src) }}" class="image" />{% endif %}{% if result.content %}{{ result.content|safe }}<br class="last"/>{% endif %}</p>
6 6
 </div>

+ 2
- 2
searx/templates/default/result_templates/images.html View File

@@ -1,6 +1,6 @@
1 1
 <div class="image_result">
2 2
     <p>
3
-        <a href="{{ result.img_src }}" rel="noreferrer"><img src="{% if result.thumbnail_src %}{{ image_proxify(result.thumbnail_src) }}{% else %}{{ image_proxify(result.img_src) }}{% endif %}" title="{{ result.title|striptags }}" alt="{{ result.title|striptags }}" /></a>
4
-        <span class="url"><a href="{{ result.url }}" rel="noreferrer" class="small_font">{{ _('original context') }}</a></span>
3
+        <a href="{{ result.img_src }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}><img src="{% if result.thumbnail_src %}{{ image_proxify(result.thumbnail_src) }}{% else %}{{ image_proxify(result.img_src) }}{% endif %}" title="{{ result.title|striptags }}" alt="{{ result.title|striptags }}" /></a>
4
+        <span class="url"><a href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %} class="small_font">{{ _('original context') }}</a></span>
5 5
     </p>
6 6
 </div>

+ 2
- 2
searx/templates/default/result_templates/map.html View File

@@ -5,8 +5,8 @@
5 5
     {% endif %}
6 6
 
7 7
     <div>
8
-        <h3 class="result_title"><a href="{{ result.url }}" rel="noreferrer">{{ result.title|safe }}</a></h3>
9
-        <p class="url">{{ result.pretty_url }}&lrm; <a class="cache_link" href="https://web.archive.org/web/{{ result.url }}" rel="noreferrer">{{ _('cached') }}</a>
8
+        <h3 class="result_title"><a href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ result.title|safe }}</a></h3>
9
+        <p class="url">{{ result.pretty_url }}&lrm; <a class="cache_link" href="https://web.archive.org/web/{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ _('cached') }}</a>
10 10
         {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span>{% endif %}</p>
11 11
         <p class="content">{% if result.img_src %}<img src="{{ image_proxify(result.img_src) }}" class="image" />{% endif %}{% if result.content %}{{ result.content|safe }}<br class="last"/>{% endif %}</p>
12 12
     </div>

+ 2
- 2
searx/templates/default/result_templates/torrent.html View File

@@ -2,12 +2,12 @@
2 2
   {% if "icon_"~result.engine~".ico" in favicons %}
3 3
     <img width="14" height="14" class="favicon" src="{{ url_for('static', filename='img/icons/icon_'+result.engine+'.ico') }}" alt="{{result.engine}}" />
4 4
   {% endif %}
5
-    <h3 class="result_title"><a href="{{ result.url }}" rel="noreferrer">{{ result.title|safe }}</a></h3>
5
+    <h3 class="result_title"><a href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ result.title|safe }}</a></h3>
6 6
     <p class="url">{{ result.pretty_url }}&lrm;</p>
7 7
     {% if result.content %}<p class="content">{{ result.content|safe }}</p>{% endif %}
8 8
     <p>
9 9
         {% if result.magnetlink %}<a href="{{ result.magnetlink }}" class="magnetlink">{{ _('magnet link') }}</a>{% endif %} 
10
-        {% if result.torrentfile %}<a href="{{ result.torrentfile }}" rel="noreferrer" class="torrentfile">{{ _('torrent file') }}</a>{% endif %} - 
10
+        {% if result.torrentfile %}<a href="{{ result.torrentfile }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %} class="torrentfile">{{ _('torrent file') }}</a>{% endif %} - 
11 11
         <span class="stats">{{ _('Seeder') }} : {{ result.seed }}, {{ _('Leecher') }} : {{ result.leech }}</span>
12 12
     </p>
13 13
 </div>

+ 2
- 2
searx/templates/default/result_templates/videos.html View File

@@ -1,6 +1,6 @@
1 1
 <div class="result">
2
-    <h3 class="result_title">{% if "icon_"~result.engine~".ico" in favicons %}<img width="14" height="14" class="favicon" src="{{ url_for('static', filename='img/icons/icon_'+result.engine+'.ico') }}" alt="{{result.engine}}" />{% endif %}<a href="{{ result.url }}" rel="noreferrer">{{ result.title|safe }}</a></h3>
2
+    <h3 class="result_title">{% if "icon_"~result.engine~".ico" in favicons %}<img width="14" height="14" class="favicon" src="{{ url_for('static', filename='img/icons/icon_'+result.engine+'.ico') }}" alt="{{result.engine}}" />{% endif %}<a href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ result.title|safe }}</a></h3>
3 3
     {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span><br />{% endif %}
4
-    <a href="{{ result.url }}" rel="noreferrer"><img class="thumbnail" src="{{ image_proxify(result.thumbnail) }}" title="{{ result.title|striptags }}" alt="{{ result.title|striptags }}"/></a>
4
+    <a href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}><img class="thumbnail" src="{{ image_proxify(result.thumbnail) }}" title="{{ result.title|striptags }}" alt="{{ result.title|striptags }}"/></a>
5 5
     <p class="url">{{ result.url }}&lrm;</p>
6 6
 </div>

+ 3
- 1
searx/templates/oscar/404.html View File

@@ -2,6 +2,8 @@
2 2
 {% block content %}
3 3
 <div class="text-center">
4 4
     <h1>{{ _('Page not found') }}</h1>
5
-    <p>{{ _('Go to <a href="/">search page</a>.') }}</p>
5
+    {% autoescape false %}
6
+    <p>{{ _('Go to %(search_page)s.', search_page='<a href="{}">{}</a>'.decode('utf-8').format(url_for('index'), _('search page'))) }}</p>
7
+    {% endautoescape %}
6 8
 </div>
7 9
 {% endblock %}

+ 2
- 1
searx/templates/oscar/infobox.html View File

@@ -1,3 +1,4 @@
1
+{% from 'oscar/macros.html' import result_link with context %}
1 2
 <div class="panel panel-default infobox">
2 3
     <div class="panel-heading">
3 4
         <h4 class="panel-title infobox_part"><bdi>{{ infobox.infobox }}</bdi></h4>
@@ -25,7 +26,7 @@
25 26
         <div class="infobox_part">
26 27
             <bdi>
27 28
             {% for url in infobox.urls %}
28
-            <p class="btn btn-default btn-xs"><a href="{{ url.url }}" rel="noreferrer">{{ url.title }}</a></p>
29
+            <p class="btn btn-default btn-xs">{{ result_link(url.url, url.title) }}</a></p>
29 30
             {% endfor %}
30 31
             </bdi>
31 32
         </div>

+ 10
- 6
searx/templates/oscar/macros.html View File

@@ -9,16 +9,20 @@
9 9
     <img width="32" height="32" class="favicon" src="static/themes/oscar/img/icons/{{ favicon }}.png" alt="{{ favicon }}" />
10 10
 {%- endmacro %}
11 11
 
12
+{%- macro result_link(url, title, classes='') -%}
13
+<a href="{{ url }}" {% if classes %}class="{{ classes }} "{% endif %}{% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ title }}</a>
14
+{%- endmacro -%}
15
+
12 16
 <!-- Draw result header -->
13
-{% macro result_header(result, favicons) -%} 
14
-    <h4 class="result_header">{% if result.engine~".png" in favicons %}{{ draw_favicon(result.engine) }} {% endif %}<a href="{{ result.url }}" rel="noreferrer">{{ result.title|safe }}</a></h4>
17
+{% macro result_header(result, favicons) -%}
18
+<h4 class="result_header">{% if result.engine~".png" in favicons %}{{ draw_favicon(result.engine) }} {% endif %}{{ result_link(result.url, result.title|safe) }}</h4>
15 19
 {%- endmacro %}
16 20
 
17 21
 <!-- Draw result sub header -->
18 22
 {% macro result_sub_header(result) -%}
19 23
     {% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
20
-    {% if result.magnetlink %}<small> &bull; <a href="{{ result.magnetlink }}" class="magnetlink">{{ icon('magnet') }} {{ _('magnet link') }}</a></small>{% endif %}
21
-    {% if result.torrentfile %}<small> &bull; <a href="{{ result.torrentfile }}" class="torrentfile" rel="noreferrer">{{ icon('download-alt') }} {{ _('torrent file') }}</a></small>{% endif %}
24
+    {% if result.magnetlink %}<small> &bull; {{ result_link(result.magnetlink, icon('magnet') + _('magnet link'), "magnetlink") }}</small>{% endif %}
25
+    {% if result.torrentfile %}<small> &bull; {{ result_link(result.torrentfile, icon('download-alt') + _('torrent file'), "torrentfile") }}</small>{% endif %}
22 26
 {%- endmacro %}
23 27
 
24 28
 <!-- Draw result footer -->
@@ -28,7 +32,7 @@
28 32
     {% for engine in result.engines %}
29 33
         <span class="label label-default">{{ engine }}</span>
30 34
     {% endfor %}
31
-    <small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}" rel="noreferrer">{{ icon('link') }} {{ _('cached') }}</a></small>
35
+    <small>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info") }}</small>
32 36
 </div>
33 37
     <div class="text-muted"><small>{{ result.pretty_url }}</small></div>
34 38
 {%- endmacro %}
@@ -39,7 +43,7 @@
39 43
     {% for engine in result.engines %}
40 44
         <span class="label label-default">{{ engine }}</span>
41 45
     {% endfor %}
42
-    <small><a class="text-info" href="https://web.archive.org/web/{{ result.url }}" rel="noreferrer">{{ icon('link') }} {{ _('cached') }}</a></small>
46
+    <small>{{ result_link("https://web.archive.org/web/" + result.url, icon('link') + _('cached'), "text-info") }}</small>
43 47
     <div class="text-muted"><small>{{ result.pretty_url }}</small></div>
44 48
 {%- endmacro %}
45 49
 

+ 9
- 0
searx/templates/oscar/preferences.html View File

@@ -117,6 +117,15 @@
117 117
                             <option value="pointhi" {% if cookies['oscar-style'] == 'pointhi' %}selected="selected"{% endif %}>Pointhi</option>
118 118
                         </select>
119 119
                     {{ preferences_item_footer(_('Choose style for this theme'), _('Style'), rtl) }}
120
+
121
+                    {% set label = _('Results on new tabs') %}
122
+                    {% set info = _('Open result links on new browser tabs') %}
123
+                    {{ preferences_item_header(info, label, rtl) }}
124
+                        <select class="form-control" name='results_on_new_tab'>
125
+                            <option value="1" {% if results_on_new_tab %}selected="selected"{% endif %}>{{ _('On') }}</option>
126
+                            <option value="0" {% if not results_on_new_tab %}selected="selected"{% endif %}>{{ _('Off')}}</option>
127
+                        </select>
128
+                    {{ preferences_item_footer(info, label, rtl) }}
120 129
                 </div>
121 130
                 </fieldset>
122 131
             </div>

+ 1
- 1
searx/templates/oscar/result_templates/code.html View File

@@ -5,7 +5,7 @@
5 5
 
6 6
 {% if result.content %}<p class="result-content">{{ result.content|safe }}</p>{% endif %}
7 7
 
8
-{% if result.repository %}<p class="result-content">{{ icon('file') }} <a href="{{ result.repository|safe }}" rel="noreferrer">{{ result.repository }}</a></p>{% endif %}
8
+{% if result.repository %}<p class="result-content">{{ icon('file') }} <a href="{{ result.repository }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}>{{ result.repository }}</a></p>{% endif %}
9 9
 
10 10
 <div dir="ltr">
11 11
 {{ result.codelines|code_highlighter(result.code_language)|safe }}

+ 1
- 1
searx/templates/oscar/result_templates/default.html View File

@@ -1,4 +1,4 @@
1
-{% from 'oscar/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon %}
1
+{% from 'oscar/macros.html' import result_header, result_sub_header, result_footer, result_footer_rtl, icon with context %}
2 2
 
3 3
 {{ result_header(result, favicons) }}
4 4
 {{ result_sub_header(result) }}

+ 3
- 3
searx/templates/oscar/result_templates/images.html View File

@@ -1,6 +1,6 @@
1 1
 {% from 'oscar/macros.html' import draw_favicon %}
2 2
 
3
-<a href="{{ result.img_src }}" rel="noreferrer" data-toggle="modal" data-target="#modal-{{ index }}">
3
+<a href="{{ result.img_src }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %} data-toggle="modal" data-target="#modal-{{ index }}">
4 4
     <img src="{% if result.thumbnail_src %}{{ image_proxify(result.thumbnail_src) }}{% else %}{{ image_proxify(result.img_src) }}{% endif %}" alt="{{ result.title|striptags }}" title="{{ result.title|striptags }}" class="img-thumbnail">
5 5
 </a>
6 6
 
@@ -20,8 +20,8 @@
20 20
                 <span class="label label-default pull-right">{{ result.engine }}</span>
21 21
                 <p class="text-muted pull-left">{{ result.pretty_url }}</p>
22 22
                 <div class="clearfix"></div>
23
-                <a href="{{ result.img_src }}" rel="noreferrer" class="btn btn-default">{{ _('Get image') }}</a>
24
-                <a href="{{ result.url }}" rel="noreferrer" class="btn btn-default">{{ _('View source') }}</a>
23
+                <a href="{{ result.img_src }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %} class="btn btn-default">{{ _('Get image') }}</a>
24
+                <a href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %} class="btn btn-default">{{ _('View source') }}</a>
25 25
             </div>
26 26
         </div>
27 27
     </div>

+ 1
- 1
searx/templates/oscar/result_templates/videos.html View File

@@ -15,7 +15,7 @@
15 15
 
16 16
 <div class="container-fluid">
17 17
     <div class="row">
18
-        <a href="{{ result.url }}" rel="noreferrer"><img class="thumbnail col-xs-6 col-sm-4 col-md-4 result-content" src="{{ image_proxify(result.thumbnail) }}" alt="{{ result.title|striptags }} {{ result.engine }}" /></a>
18
+        <a href="{{ result.url }}" {% if results_on_new_tab %}target="_blank" rel="noopener noreferrer"{% else %}rel="noreferrer"{% endif %}><img class="thumbnail col-xs-6 col-sm-4 col-md-4 result-content" src="{{ image_proxify(result.thumbnail) }}" alt="{{ result.title|striptags }} {{ result.engine }}" /></a>
19 19
         {% if result.content %}<p class="col-xs-12 col-sm-8 col-md-8 result-content">{{ result.content|safe }}</p>{% endif %}
20 20
     </div>
21 21
 </div>

+ 3
- 1
searx/templates/pix-art/404.html View File

@@ -2,6 +2,8 @@
2 2
 {% block content %}
3 3
 <div class="center">
4 4
     <h1>{{ _('Page not found') }}</h1>
5
-    <p>{{ _('Go to <a href="/">search page</a>.') }}</p>
5
+    {% autoescape false %}
6
+    <p>{{ _('Go to %(search_page)s.', search_page='<a href="{}">{}</a>'.decode('utf-8').format(url_for('index'), _('search page'))) }}</p>
7
+    {% endautoescape %}
6 8
 </div>
7 9
 {% endblock %}

+ 8
- 1
searx/webapp.py View File

@@ -320,6 +320,8 @@ def render(template_name, override_theme=None, **kwargs):
320 320
 
321 321
     kwargs['instance_name'] = settings['general']['instance_name']
322 322
 
323
+    kwargs['results_on_new_tab'] = request.preferences.get_value('results_on_new_tab')
324
+
323 325
     kwargs['scripts'] = set()
324 326
     for plugin in request.user_plugins:
325 327
         for script in plugin.js_dependencies:
@@ -338,7 +340,11 @@ def render(template_name, override_theme=None, **kwargs):
338 340
 def pre_request():
339 341
     # merge GET, POST vars
340 342
     preferences = Preferences(themes, categories.keys(), engines, plugins)
341
-    preferences.parse_cookies(request.cookies)
343
+    try:
344
+        preferences.parse_cookies(request.cookies)
345
+    except:
346
+        # TODO throw error message to the user
347
+        logger.warning('Invalid config')
342 348
     request.preferences = preferences
343 349
 
344 350
     request.form = dict(request.form.items())
@@ -553,6 +559,7 @@ def preferences():
553 559
     lang = request.preferences.get_value('language')
554 560
     disabled_engines = request.preferences.engines.get_disabled()
555 561
     allowed_plugins = request.preferences.plugins.get_enabled()
562
+    results_on_new_tab = request.preferences.get_value('results_on_new_tab')
556 563
 
557 564
     # stats for preferences page
558 565
     stats = {}