Browse Source

Merge branch 'master' of https://github.com/asciimoo/searx

potato 8 years ago
parent
commit
9d08c81f47

+ 1
- 1
requirements.txt View File

@@ -9,4 +9,4 @@ pygments==2.1.3
9 9
 pyopenssl==0.15.1
10 10
 python-dateutil==2.5.3
11 11
 pyyaml==3.11
12
-requests==2.10.0
12
+requests[socks]==2.10.0

+ 4
- 2
searx/search.py View File

@@ -19,6 +19,7 @@ import gc
19 19
 import threading
20 20
 from thread import start_new_thread
21 21
 from time import time
22
+from uuid import uuid4
22 23
 import searx.poolrequests as requests_lib
23 24
 from searx.engines import (
24 25
     categories, engines
@@ -56,19 +57,20 @@ def search_request_wrapper(fn, url, engine_name, **kwargs):
56 57
 def threaded_requests(requests):
57 58
     timeout_limit = max(r[2]['timeout'] for r in requests)
58 59
     search_start = time()
60
+    search_id = uuid4().__str__()
59 61
     for fn, url, request_args, engine_name in requests:
60 62
         request_args['timeout'] = timeout_limit
61 63
         th = threading.Thread(
62 64
             target=search_request_wrapper,
63 65
             args=(fn, url, engine_name),
64 66
             kwargs=request_args,
65
-            name='search_request',
67
+            name=search_id,
66 68
         )
67 69
         th._engine_name = engine_name
68 70
         th.start()
69 71
 
70 72
     for th in threading.enumerate():
71
-        if th.name == 'search_request':
73
+        if th.name == search_id:
72 74
             remaining_time = max(0.0, timeout_limit - (time() - search_start))
73 75
             th.join(remaining_time)
74 76
             if th.isAlive():

+ 1
- 1
searx/settings.yml View File

@@ -25,7 +25,7 @@ outgoing: # communication with search engines
25 25
     pool_maxsize : 10 # Number of simultaneous requests by host
26 26
 # uncomment below section if you want to use a proxy
27 27
 # see http://docs.python-requests.org/en/latest/user/advanced/#proxies
28
-# SOCKS proxies are not supported : see https://github.com/kennethreitz/requests/pull/478
28
+# SOCKS proxies are also supported: see http://docs.python-requests.org/en/master/user/advanced/#socks
29 29
 #    proxies :
30 30
 #        http : http://127.0.0.1:8080
31 31
 #        https: http://127.0.0.1:8080

+ 1
- 1
searx/static/themes/oscar/css/logicodev.min.css
File diff suppressed because it is too large
View File


+ 1
- 1
searx/static/themes/oscar/css/pointhi.min.css
File diff suppressed because it is too large
View File


+ 21
- 4
searx/static/themes/oscar/less/logicodev/results.less View File

@@ -6,7 +6,7 @@
6 6
     .favicon {
7 7
         margin-bottom:-3px;
8 8
     }
9
-    
9
+
10 10
     a {
11 11
         color: @black;
12 12
         text-decoration: none;
@@ -18,7 +18,7 @@
18 18
         &:visited{
19 19
             color: @violet;
20 20
         }
21
-        
21
+
22 22
         .highlight {
23 23
             background-color: @dim-gray;
24 24
             // Chrome hack: bold is different size than normal
@@ -64,10 +64,9 @@
64 64
     float: left !important;
65 65
     width: 24%;
66 66
     margin: .5%;
67
-    a{
67
+    a {
68 68
         display: block;
69 69
         width: 100%;
70
-        height: 170px;
71 70
         background-size: cover;
72 71
     }
73 72
 }
@@ -148,3 +147,21 @@
148 147
     color: @gray;
149 148
     background: transparent;
150 149
 }
150
+
151
+.result .text-muted small {
152
+    word-wrap: break-word;
153
+}
154
+
155
+.modal-wrapper {
156
+    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
157
+}
158
+
159
+.modal-wrapper {
160
+    background-clip: padding-box;
161
+    background-color: #fff;
162
+    border: 1px solid rgba(0, 0, 0, 0.2);
163
+    border-radius: 6px;
164
+    box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
165
+    outline: 0 none;
166
+    position: relative;
167
+}

+ 20
- 2
searx/static/themes/oscar/less/pointhi/results.less View File

@@ -6,10 +6,10 @@
6 6
     .favicon {
7 7
         margin-bottom:-3px;
8 8
     }
9
-    
9
+
10 10
     a {
11 11
         vertical-align: bottom;
12
-        
12
+
13 13
         .highlight {
14 14
             font-weight:bold;
15 15
         }
@@ -81,3 +81,21 @@
81 81
     color: #AAA;
82 82
     background: #FFF;
83 83
 }
84
+
85
+.result .text-muted small {
86
+    word-wrap: break-word;
87
+}
88
+
89
+.modal-wrapper {
90
+    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
91
+}
92
+
93
+.modal-wrapper {
94
+    background-clip: padding-box;
95
+    background-color: #fff;
96
+    border: 1px solid rgba(0, 0, 0, 0.2);
97
+    border-radius: 6px;
98
+    box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
99
+    outline: 0 none;
100
+    position: relative;
101
+}

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

@@ -6,7 +6,7 @@
6 6
 
7 7
 <div class="modal fade" id="modal-{{ index }}" tabindex="-1" role="dialog" aria-hidden="true">
8 8
     <div class="modal-dialog">
9
-        <div class="modal-content">
9
+        <div class="modal-wrapper">
10 10
             <div class="modal-header">
11 11
                 <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
12 12
                 <h4 class="modal-title">{% if result.engine~".png" in favicons %}{{ draw_favicon(result.engine) }} {% endif %}{{ result.title|striptags }}</h4>
@@ -20,8 +20,14 @@
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 }}" {% 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>
23
+				<div class="row">
24
+                    <div class="col-md-6">
25
+                        <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>
26
+                    </div>
27
+                    <div class="col-md-6">
28
+                        <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>
29
+                    </div>
30
+                </div>
25 31
             </div>
26 32
         </div>
27 33
     </div>

+ 5
- 7
searx/webapp.py View File

@@ -395,11 +395,9 @@ def index():
395 395
             search.paging = True
396 396
 
397 397
         if search.request_data.get('format', 'html') == 'html':
398
-            if 'content' in result:
399
-                result['content'] = highlight_content(result['content'],
400
-                                                      search.query.encode('utf-8'))  # noqa
401
-            result['title'] = highlight_content(result['title'],
402
-                                                search.query.encode('utf-8'))
398
+            if 'content' in result and result['content']:
399
+                result['content'] = highlight_content(result['content'][:1024], search.query.encode('utf-8'))
400
+            result['title'] = highlight_content(result['title'], search.query.encode('utf-8'))
403 401
         else:
404 402
             if result.get('content'):
405 403
                 result['content'] = html_to_text(result['content']).strip()
@@ -559,7 +557,6 @@ def preferences():
559 557
     lang = request.preferences.get_value('language')
560 558
     disabled_engines = request.preferences.engines.get_disabled()
561 559
     allowed_plugins = request.preferences.plugins.get_enabled()
562
-    results_on_new_tab = request.preferences.get_value('results_on_new_tab')
563 560
 
564 561
     # stats for preferences page
565 562
     stats = {}
@@ -732,7 +729,8 @@ def run():
732 729
         debug=settings['general']['debug'],
733 730
         use_debugger=settings['general']['debug'],
734 731
         port=settings['server']['port'],
735
-        host=settings['server']['bind_address']
732
+        host=settings['server']['bind_address'],
733
+        threaded=True
736 734
     )
737 735
 
738 736