浏览代码

[enh] new plugin to open results on new browser tabs

Adam Tauber 9 年前
父节点
当前提交
ab6a7601cb

+ 2
- 0
searx/plugins/__init__.py 查看文件

@@ -20,6 +20,7 @@ from searx import logger
20 20
 logger = logger.getChild('plugins')
21 21
 
22 22
 from searx.plugins import (https_rewrite,
23
+                           open_results_on_new_tab,
23 24
                            self_info,
24 25
                            search_on_category_select,
25 26
                            tracker_url_remover)
@@ -72,6 +73,7 @@ class PluginStore():
72 73
 
73 74
 plugins = PluginStore()
74 75
 plugins.register(https_rewrite)
76
+plugins.register(open_results_on_new_tab)
75 77
 plugins.register(self_info)
76 78
 plugins.register(search_on_category_select)
77 79
 plugins.register(tracker_url_remover)

+ 24
- 0
searx/plugins/open_results_on_new_tab.py 查看文件

@@ -0,0 +1,24 @@
1
+'''
2
+searx is free software: you can redistribute it and/or modify
3
+it under the terms of the GNU Affero General Public License as published by
4
+the Free Software Foundation, either version 3 of the License, or
5
+(at your option) any later version.
6
+
7
+searx is distributed in the hope that it will be useful,
8
+but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
+GNU Affero General Public License for more details.
11
+
12
+You should have received a copy of the GNU Affero General Public License
13
+along with searx. If not, see < http://www.gnu.org/licenses/ >.
14
+
15
+(C) 2016 by Adam Tauber, <asciimoo@gmail.com>
16
+'''
17
+from flask.ext.babel import gettext
18
+name = gettext('Open result links on new browser tabs')
19
+description = gettext('Results are opened in the same window by default. '
20
+                      'This plugin overwrites the default behaviour to open links on new tabs/windows. '
21
+                      '(JavaScript required)')
22
+default_on = False
23
+
24
+js_dependencies = ('plugins/js/open_results_on_new_tab.js',)

+ 3
- 0
searx/static/plugins/js/open_results_on_new_tab.js 查看文件

@@ -0,0 +1,3 @@
1
+$(document).ready(function() {
2
+    $('.result_header > a').attr('target', '_blank');
3
+});