on master help sign in
[fix] links in new tabs without js ++ noopener bug fix - closes #674
b4b0231Adam Tauber
searx/preferences.py+2−1
@@ -227,7 +227,8 @@ class Preferences(object):
227 'safesearch': MapSetting(settings['search']['safe_search'], map={'0': 0,
227 'safesearch': MapSetting(settings['search']['safe_search'], map={'0': 0,
228 '1': 1,
228 '1': 1,
229 '2': 2}),
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 self.engines = EnginesSetting('engines', choices=engines)
233 self.engines = EnginesSetting('engines', choices=engines)
233 self.plugins = PluginsSetting('plugins', choices=plugins)
234 self.plugins = PluginsSetting('plugins', choices=plugins)
searx/templates/courgette/result_templates/code.html+2−2
@@ -1,8 +1,8 @@
1<div class="result {{ result.class }}">
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 {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span>{% endif %}
3 {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span>{% endif %}
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>
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 <div dir="ltr">
6 <div dir="ltr">
7 {{ result.codelines|code_highlighter(result.code_language)|safe }}
7 {{ result.codelines|code_highlighter(result.code_language)|safe }}
8 </div>
8 </div>
searx/templates/courgette/result_templates/default.html+1−1
@@ -5,7 +5,7 @@
5 {% endif %}
5 {% endif %}
6
6
7 <div>
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 {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span>{% endif %}
9 {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span>{% endif %}
10 <p class="content">{% if result.content %}{{ result.content|safe }}<br />{% endif %}</p>
10 <p class="content">{% if result.content %}{{ result.content|safe }}<br />{% endif %}</p>
11 <p class="url">{{ result.pretty_url }}&lrm;</p>
11 <p class="url">{{ result.pretty_url }}&lrm;</p>
searx/templates/courgette/result_templates/images.html+2−2
@@ -1,6 +1,6 @@
1<div class="image_result">
1<div class="image_result">
2 <p>
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>
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 }}" rel="noreferrer" class="small_font">{{ _('original context') }}</a></span>
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 </p>
5 </p>
6</div>
6</div>
searx/templates/courgette/result_templates/map.html+1−1
@@ -5,7 +5,7 @@
5 {% endif %}
5 {% endif %}
6
6
7 <div>
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 {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span>{% endif %}
9 {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span>{% endif %}
10 <p class="content">{% if result.content %}{{ result.content|safe }}<br />{% endif %}</p>
10 <p class="content">{% if result.content %}{{ result.content|safe }}<br />{% endif %}</p>
11 <p class="url">{{ result.pretty_url }}&lrm;</p>
11 <p class="url">{{ result.pretty_url }}&lrm;</p>
searx/templates/courgette/result_templates/torrent.html+2−2
@@ -2,12 +2,12 @@
2 {% if "icon_"~result.engine~".ico" in favicons %}
2 {% if "icon_"~result.engine~".ico" in favicons %}
3 <img width="14" height="14" class="favicon" src="{{ url_for('static', filename='img/icons/icon_'+result.engine+'.ico') }}" alt="{{result.engine}}" />
3 <img width="14" height="14" class="favicon" src="{{ url_for('static', filename='img/icons/icon_'+result.engine+'.ico') }}" alt="{{result.engine}}" />
4 {% endif %}
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 {% if result.content %}<span class="content">{{ result.content|safe }}</span><br />{% endif %}
6 {% if result.content %}<span class="content">{{ result.content|safe }}</span><br />{% endif %}
7 <span class="stats">{{ _('Seeder') }} : {{ result.seed }}, {{ _('Leecher') }} : {{ result.leech }}</span><br />
7 <span class="stats">{{ _('Seeder') }} : {{ result.seed }}, {{ _('Leecher') }} : {{ result.leech }}</span><br />
8 <span>
8 <span>
9 {% if result.magnetlink %}<a href="{{ result.magnetlink }}" class="magnetlink">{{ _('magnet link') }}</a>{% endif %}
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 </span>
11 </span>
12 <p class="url">{{ result.pretty_url }}&lrm;</p>
12 <p class="url">{{ result.pretty_url }}&lrm;</p>
13</div>
13</div>
searx/templates/courgette/result_templates/videos.html+2−2
@@ -3,8 +3,8 @@
3 <img width="14" height="14" class="favicon" src="{{ url_for('static', filename='img/icons/icon_'+result.engine+'.ico') }}" alt="{{result.engine}}" />
3 <img width="14" height="14" class="favicon" src="{{ url_for('static', filename='img/icons/icon_'+result.engine+'.ico') }}" alt="{{result.engine}}" />
4 {% endif %}
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 {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span><br />{% endif %}
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 <p class="url">{{ result.pretty_url }}&lrm;</p>
9 <p class="url">{{ result.pretty_url }}&lrm;</p>
10</div>
10</div>
searx/templates/default/infobox.html+1−1
@@ -24,7 +24,7 @@
24 <div class="urls">
24 <div class="urls">
25 <ul>
25 <ul>
26 {% for url in infobox.urls %}
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 {% endfor %}
28 {% endfor %}
29 </ul>
29 </ul>
30 </div>
30 </div>
searx/templates/default/preferences.html+9
@@ -80,6 +80,15 @@
80 </select>
80 </select>
81 </p>
81 </p>
82 </fieldset>
82 </fieldset>
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>
83 <fieldset>
92 <fieldset>
84 <legend>{{ _('Currently used search engines') }}</legend>
93 <legend>{{ _('Currently used search engines') }}</legend>
85
94
searx/templates/default/result_templates/code.html+3−3
@@ -1,9 +1,9 @@
1<div class="result {{ result.class }}">
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− <p class="url">{{ result.pretty_url }}&lrm; <a class="cache_link" href="https://web.archive.org/web/{{ result.url }}" rel="noreferrer">{{ _('cached') }}</a></p>
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 {% if result.publishedDate %}<p class="published_date">{{ result.publishedDate }}</p>{% endif %}
4 {% if result.publishedDate %}<p class="published_date">{{ result.publishedDate }}</p>{% endif %}
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>
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 <div dir="ltr">
8 <div dir="ltr">
9 {{ result.codelines|code_highlighter(result.code_language)|safe }}
9 {{ result.codelines|code_highlighter(result.code_language)|safe }}
searx/templates/default/result_templates/default.html+2−2
@@ -1,6 +1,6 @@
1<div class="result {{ result.class }}">
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>
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 }}" rel="noreferrer">{{ _('cached') }}</a>
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 {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span>{% endif %}</p>
4 {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span>{% endif %}</p>
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>
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</div>
6</div>
searx/templates/default/result_templates/images.html+2−2
@@ -1,6 +1,6 @@
1<div class="image_result">
1<div class="image_result">
2 <p>
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>
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 }}" rel="noreferrer" class="small_font">{{ _('original context') }}</a></span>
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 </p>
5 </p>
6</div>
6</div>
searx/templates/default/result_templates/map.html+2−2
@@ -5,8 +5,8 @@
5 {% endif %}
5 {% endif %}
6
6
7 <div>
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− <p class="url">{{ result.pretty_url }}&lrm; <a class="cache_link" href="https://web.archive.org/web/{{ result.url }}" rel="noreferrer">{{ _('cached') }}</a>
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 {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span>{% endif %}</p>
10 {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span>{% endif %}</p>
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>
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 </div>
12 </div>
searx/templates/default/result_templates/torrent.html+2−2
@@ -2,12 +2,12 @@
2 {% if "icon_"~result.engine~".ico" in favicons %}
2 {% if "icon_"~result.engine~".ico" in favicons %}
3 <img width="14" height="14" class="favicon" src="{{ url_for('static', filename='img/icons/icon_'+result.engine+'.ico') }}" alt="{{result.engine}}" />
3 <img width="14" height="14" class="favicon" src="{{ url_for('static', filename='img/icons/icon_'+result.engine+'.ico') }}" alt="{{result.engine}}" />
4 {% endif %}
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 <p class="url">{{ result.pretty_url }}&lrm;</p>
6 <p class="url">{{ result.pretty_url }}&lrm;</p>
7 {% if result.content %}<p class="content">{{ result.content|safe }}</p>{% endif %}
7 {% if result.content %}<p class="content">{{ result.content|safe }}</p>{% endif %}
8 <p>
8 <p>
9 {% if result.magnetlink %}<a href="{{ result.magnetlink }}" class="magnetlink">{{ _('magnet link') }}</a>{% endif %}
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 <span class="stats">{{ _('Seeder') }} : {{ result.seed }}, {{ _('Leecher') }} : {{ result.leech }}</span>
11 <span class="stats">{{ _('Seeder') }} : {{ result.seed }}, {{ _('Leecher') }} : {{ result.leech }}</span>
12 </p>
12 </p>
13</div>
13</div>
searx/templates/default/result_templates/videos.html+2−2
@@ -1,6 +1,6 @@
1<div class="result">
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 {% if result.publishedDate %}<span class="published_date">{{ result.publishedDate }}</span><br />{% endif %}
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 <p class="url">{{ result.url }}&lrm;</p>
5 <p class="url">{{ result.url }}&lrm;</p>
6</div>
6</div>
searx/templates/oscar/infobox.html+2−1
@@ -1,3 +1,4 @@
1+{% from 'oscar/macros.html' import result_link with context %}
1<div class="panel panel-default infobox">
2<div class="panel panel-default infobox">
2 <div class="panel-heading">
3 <div class="panel-heading">
3 <h4 class="panel-title infobox_part"><bdi>{{ infobox.infobox }}</bdi></h4>
4 <h4 class="panel-title infobox_part"><bdi>{{ infobox.infobox }}</bdi></h4>
@@ -25,7 +26,7 @@
25 <div class="infobox_part">
26 <div class="infobox_part">
26 <bdi>
27 <bdi>
27 {% for url in infobox.urls %}
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 {% endfor %}
30 {% endfor %}
30 </bdi>
31 </bdi>
31 </div>
32 </div>
searx/templates/oscar/macros.html+10−6
@@ -9,16 +9,20 @@
9 <img width="32" height="32" class="favicon" src="static/themes/oscar/img/icons/{{ favicon }}.png" alt="{{ favicon }}" />
9 <img width="32" height="32" class="favicon" src="static/themes/oscar/img/icons/{{ favicon }}.png" alt="{{ favicon }}" />
10{%- endmacro %}
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<!-- Draw result header -->
16<!-- Draw result header -->
13−{% macro result_header(result, favicons) -%}
17+{% 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>
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{%- endmacro %}
19{%- endmacro %}
16
20
17<!-- Draw result sub header -->
21<!-- Draw result sub header -->
18{% macro result_sub_header(result) -%}
22{% macro result_sub_header(result) -%}
19 {% if result.publishedDate %}<time class="text-muted" datetime="{{ result.pubdate }}" >{{ result.publishedDate }}</time>{% endif %}
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 %}
24+ {% if result.magnetlink %}<small> &bull; {{ result_link(result.magnetlink, icon('magnet') + _('magnet link'), "magnetlink") }}</small>{% endif %}
21− {% if result.torrentfile %}<small> &bull; <a href="{{ result.torrentfile }}" class="torrentfile" rel="noreferrer">{{ icon('download-alt') }} {{ _('torrent file') }}</a></small>{% endif %}
25+ {% if result.torrentfile %}<small> &bull; {{ result_link(result.torrentfile, icon('download-alt') + _('torrent file'), "torrentfile") }}</small>{% endif %}
22{%- endmacro %}
26{%- endmacro %}
23
27
24<!-- Draw result footer -->
28<!-- Draw result footer -->
@@ -28,7 +32,7 @@
28 {% for engine in result.engines %}
32 {% for engine in result.engines %}
29 <span class="label label-default">{{ engine }}</span>
33 <span class="label label-default">{{ engine }}</span>
30 {% endfor %}
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</div>
36</div>
33 <div class="text-muted"><small>{{ result.pretty_url }}</small></div>
37 <div class="text-muted"><small>{{ result.pretty_url }}</small></div>
34{%- endmacro %}
38{%- endmacro %}
@@ -39,7 +43,7 @@
39 {% for engine in result.engines %}
43 {% for engine in result.engines %}
40 <span class="label label-default">{{ engine }}</span>
44 <span class="label label-default">{{ engine }}</span>
41 {% endfor %}
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 <div class="text-muted"><small>{{ result.pretty_url }}</small></div>
47 <div class="text-muted"><small>{{ result.pretty_url }}</small></div>
44{%- endmacro %}
48{%- endmacro %}
45
49
searx/templates/oscar/preferences.html+9
@@ -117,6 +117,15 @@
117 <option value="pointhi" {% if cookies['oscar-style'] == 'pointhi' %}selected="selected"{% endif %}>Pointhi</option>
117 <option value="pointhi" {% if cookies['oscar-style'] == 'pointhi' %}selected="selected"{% endif %}>Pointhi</option>
118 </select>
118 </select>
119 {{ preferences_item_footer(_('Choose style for this theme'), _('Style'), rtl) }}
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 </div>
129 </div>
121 </fieldset>
130 </fieldset>
122 </div>
131 </div>
searx/templates/oscar/result_templates/code.html+1−1
@@ -5,7 +5,7 @@
5
5
6{% if result.content %}<p class="result-content">{{ result.content|safe }}</p>{% endif %}
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<div dir="ltr">
10<div dir="ltr">
11{{ result.codelines|code_highlighter(result.code_language)|safe }}
11{{ result.codelines|code_highlighter(result.code_language)|safe }}
searx/templates/oscar/result_templates/default.html+1−1
@@ -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{{ result_header(result, favicons) }}
3{{ result_header(result, favicons) }}
4{{ result_sub_header(result) }}
4{{ result_sub_header(result) }}
searx/templates/oscar/result_templates/images.html+3−3
@@ -1,6 +1,6 @@
1{% from 'oscar/macros.html' import draw_favicon %}
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 <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">
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</a>
5</a>
6
6
@@ -20,8 +20,8 @@
20 <span class="label label-default pull-right">{{ result.engine }}</span>
20 <span class="label label-default pull-right">{{ result.engine }}</span>
21 <p class="text-muted pull-left">{{ result.pretty_url }}</p>
21 <p class="text-muted pull-left">{{ result.pretty_url }}</p>
22 <div class="clearfix"></div>
22 <div class="clearfix"></div>
23− <a href="{{ result.img_src }}" rel="noreferrer" class="btn btn-default">{{ _('Get image') }}</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 }}" rel="noreferrer" class="btn btn-default">{{ _('View source') }}</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 </div>
25 </div>
26 </div>
26 </div>
27 </div>
27 </div>
searx/templates/oscar/result_templates/videos.html+1−1
@@ -15,7 +15,7 @@
15
15
16<div class="container-fluid">
16<div class="container-fluid">
17 <div class="row">
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 {% if result.content %}<p class="col-xs-12 col-sm-8 col-md-8 result-content">{{ result.content|safe }}</p>{% endif %}
19 {% if result.content %}<p class="col-xs-12 col-sm-8 col-md-8 result-content">{{ result.content|safe }}</p>{% endif %}
20 </div>
20 </div>
21</div>
21</div>
searx/webapp.py+8−1
@@ -320,6 +320,8 @@ def render(template_name, override_theme=None, **kwargs):
320
320
321 kwargs['instance_name'] = settings['general']['instance_name']
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 kwargs['scripts'] = set()
325 kwargs['scripts'] = set()
324 for plugin in request.user_plugins:
326 for plugin in request.user_plugins:
325 for script in plugin.js_dependencies:
327 for script in plugin.js_dependencies:
@@ -338,7 +340,11 @@ def render(template_name, override_theme=None, **kwargs):
338def pre_request():
340def pre_request():
339 # merge GET, POST vars
341 # merge GET, POST vars
340 preferences = Preferences(themes, categories.keys(), engines, plugins)
342 preferences = Preferences(themes, categories.keys(), engines, plugins)
343+ try:
341− preferences.parse_cookies(request.cookies)
344+ preferences.parse_cookies(request.cookies)
345+ except:
346+ # TODO throw error message to the user
347+ logger.warning('Invalid config')
342 request.preferences = preferences
348 request.preferences = preferences
343
349
344 request.form = dict(request.form.items())
350 request.form = dict(request.form.items())
@@ -553,6 +559,7 @@ def preferences():
553 lang = request.preferences.get_value('language')
559 lang = request.preferences.get_value('language')
554 disabled_engines = request.preferences.engines.get_disabled()
560 disabled_engines = request.preferences.engines.get_disabled()
555 allowed_plugins = request.preferences.plugins.get_enabled()
561 allowed_plugins = request.preferences.plugins.get_enabled()
562+ results_on_new_tab = request.preferences.get_value('results_on_new_tab')
556
563
557 # stats for preferences page
564 # stats for preferences page
558 stats = {}
565 stats = {}