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

+ 1
- 1
searx/settings.yml View File

25
     pool_maxsize : 10 # Number of simultaneous requests by host
25
     pool_maxsize : 10 # Number of simultaneous requests by host
26
 # uncomment below section if you want to use a proxy
26
 # uncomment below section if you want to use a proxy
27
 # see http://docs.python-requests.org/en/latest/user/advanced/#proxies
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
 #    proxies :
29
 #    proxies :
30
 #        http : http://127.0.0.1:8080
30
 #        http : http://127.0.0.1:8080
31
 #        https: http://127.0.0.1:8080
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
     .favicon {
6
     .favicon {
7
         margin-bottom:-3px;
7
         margin-bottom:-3px;
8
     }
8
     }
9
-    
9
+
10
     a {
10
     a {
11
         color: @black;
11
         color: @black;
12
         text-decoration: none;
12
         text-decoration: none;
18
         &:visited{
18
         &:visited{
19
             color: @violet;
19
             color: @violet;
20
         }
20
         }
21
-        
21
+
22
         .highlight {
22
         .highlight {
23
             background-color: @dim-gray;
23
             background-color: @dim-gray;
24
             // Chrome hack: bold is different size than normal
24
             // Chrome hack: bold is different size than normal
64
     float: left !important;
64
     float: left !important;
65
     width: 24%;
65
     width: 24%;
66
     margin: .5%;
66
     margin: .5%;
67
-    a{
67
+    a {
68
         display: block;
68
         display: block;
69
         width: 100%;
69
         width: 100%;
70
-        height: 170px;
71
         background-size: cover;
70
         background-size: cover;
72
     }
71
     }
73
 }
72
 }
148
     color: @gray;
147
     color: @gray;
149
     background: transparent;
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
     .favicon {
6
     .favicon {
7
         margin-bottom:-3px;
7
         margin-bottom:-3px;
8
     }
8
     }
9
-    
9
+
10
     a {
10
     a {
11
         vertical-align: bottom;
11
         vertical-align: bottom;
12
-        
12
+
13
         .highlight {
13
         .highlight {
14
             font-weight:bold;
14
             font-weight:bold;
15
         }
15
         }
81
     color: #AAA;
81
     color: #AAA;
82
     background: #FFF;
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
 
6
 
7
 <div class="modal fade" id="modal-{{ index }}" tabindex="-1" role="dialog" aria-hidden="true">
7
 <div class="modal fade" id="modal-{{ index }}" tabindex="-1" role="dialog" aria-hidden="true">
8
     <div class="modal-dialog">
8
     <div class="modal-dialog">
9
-        <div class="modal-content">
9
+        <div class="modal-wrapper">
10
             <div class="modal-header">
10
             <div class="modal-header">
11
                 <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
11
                 <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
12
                 <h4 class="modal-title">{% if result.engine~".png" in favicons %}{{ draw_favicon(result.engine) }} {% endif %}{{ result.title|striptags }}</h4>
12
                 <h4 class="modal-title">{% if result.engine~".png" in favicons %}{{ draw_favicon(result.engine) }} {% endif %}{{ result.title|striptags }}</h4>
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 }}" {% 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
             </div>
31
             </div>
26
         </div>
32
         </div>
27
     </div>
33
     </div>

+ 5
- 7
searx/webapp.py View File

395
             search.paging = True
395
             search.paging = True
396
 
396
 
397
         if search.request_data.get('format', 'html') == 'html':
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
         else:
401
         else:
404
             if result.get('content'):
402
             if result.get('content'):
405
                 result['content'] = html_to_text(result['content']).strip()
403
                 result['content'] = html_to_text(result['content']).strip()
559
     lang = request.preferences.get_value('language')
557
     lang = request.preferences.get_value('language')
560
     disabled_engines = request.preferences.engines.get_disabled()
558
     disabled_engines = request.preferences.engines.get_disabled()
561
     allowed_plugins = request.preferences.plugins.get_enabled()
559
     allowed_plugins = request.preferences.plugins.get_enabled()
562
-    results_on_new_tab = request.preferences.get_value('results_on_new_tab')
563
 
560
 
564
     # stats for preferences page
561
     # stats for preferences page
565
     stats = {}
562
     stats = {}
732
         debug=settings['general']['debug'],
729
         debug=settings['general']['debug'],
733
         use_debugger=settings['general']['debug'],
730
         use_debugger=settings['general']['debug'],
734
         port=settings['server']['port'],
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