mirror of
				https://github.com/searxng/searxng
				synced 2024-01-01 19:24:07 +01:00 
			
		
		
		
	Merge branch 'master' of https://github.com/asciimoo/searx
This commit is contained in:
		
						commit
						9d08c81f47
					
				
					 9 changed files with 63 additions and 22 deletions
				
			
		|  | @ -9,4 +9,4 @@ pygments==2.1.3 | |||
| pyopenssl==0.15.1 | ||||
| python-dateutil==2.5.3 | ||||
| pyyaml==3.11 | ||||
| requests==2.10.0 | ||||
| requests[socks]==2.10.0 | ||||
|  |  | |||
|  | @ -19,6 +19,7 @@ import gc | |||
| import threading | ||||
| from thread import start_new_thread | ||||
| from time import time | ||||
| from uuid import uuid4 | ||||
| import searx.poolrequests as requests_lib | ||||
| from searx.engines import ( | ||||
|     categories, engines | ||||
|  | @ -56,19 +57,20 @@ def search_request_wrapper(fn, url, engine_name, **kwargs): | |||
| def threaded_requests(requests): | ||||
|     timeout_limit = max(r[2]['timeout'] for r in requests) | ||||
|     search_start = time() | ||||
|     search_id = uuid4().__str__() | ||||
|     for fn, url, request_args, engine_name in requests: | ||||
|         request_args['timeout'] = timeout_limit | ||||
|         th = threading.Thread( | ||||
|             target=search_request_wrapper, | ||||
|             args=(fn, url, engine_name), | ||||
|             kwargs=request_args, | ||||
|             name='search_request', | ||||
|             name=search_id, | ||||
|         ) | ||||
|         th._engine_name = engine_name | ||||
|         th.start() | ||||
| 
 | ||||
|     for th in threading.enumerate(): | ||||
|         if th.name == 'search_request': | ||||
|         if th.name == search_id: | ||||
|             remaining_time = max(0.0, timeout_limit - (time() - search_start)) | ||||
|             th.join(remaining_time) | ||||
|             if th.isAlive(): | ||||
|  |  | |||
|  | @ -25,7 +25,7 @@ outgoing: # communication with search engines | |||
|     pool_maxsize : 10 # Number of simultaneous requests by host | ||||
| # uncomment below section if you want to use a proxy | ||||
| # see http://docs.python-requests.org/en/latest/user/advanced/#proxies | ||||
| # SOCKS proxies are not supported : see https://github.com/kennethreitz/requests/pull/478 | ||||
| # SOCKS proxies are also supported: see http://docs.python-requests.org/en/master/user/advanced/#socks | ||||
| #    proxies : | ||||
| #        http : http://127.0.0.1:8080 | ||||
| #        https: http://127.0.0.1:8080 | ||||
|  |  | |||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							|  | @ -6,7 +6,7 @@ | |||
|     .favicon { | ||||
|         margin-bottom:-3px; | ||||
|     } | ||||
|      | ||||
| 
 | ||||
|     a { | ||||
|         color: @black; | ||||
|         text-decoration: none; | ||||
|  | @ -18,7 +18,7 @@ | |||
|         &:visited{ | ||||
|             color: @violet; | ||||
|         } | ||||
|          | ||||
| 
 | ||||
|         .highlight { | ||||
|             background-color: @dim-gray; | ||||
|             // Chrome hack: bold is different size than normal | ||||
|  | @ -64,10 +64,9 @@ | |||
|     float: left !important; | ||||
|     width: 24%; | ||||
|     margin: .5%; | ||||
|     a{ | ||||
|     a { | ||||
|         display: block; | ||||
|         width: 100%; | ||||
|         height: 170px; | ||||
|         background-size: cover; | ||||
|     } | ||||
| } | ||||
|  | @ -148,3 +147,21 @@ | |||
|     color: @gray; | ||||
|     background: transparent; | ||||
| } | ||||
| 
 | ||||
| .result .text-muted small { | ||||
|     word-wrap: break-word; | ||||
| } | ||||
| 
 | ||||
| .modal-wrapper { | ||||
|     box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5); | ||||
| } | ||||
| 
 | ||||
| .modal-wrapper { | ||||
|     background-clip: padding-box; | ||||
|     background-color: #fff; | ||||
|     border: 1px solid rgba(0, 0, 0, 0.2); | ||||
|     border-radius: 6px; | ||||
|     box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5); | ||||
|     outline: 0 none; | ||||
|     position: relative; | ||||
| } | ||||
|  |  | |||
|  | @ -6,10 +6,10 @@ | |||
|     .favicon { | ||||
|         margin-bottom:-3px; | ||||
|     } | ||||
|      | ||||
| 
 | ||||
|     a { | ||||
|         vertical-align: bottom; | ||||
|          | ||||
| 
 | ||||
|         .highlight { | ||||
|             font-weight:bold; | ||||
|         } | ||||
|  | @ -81,3 +81,21 @@ | |||
|     color: #AAA; | ||||
|     background: #FFF; | ||||
| } | ||||
| 
 | ||||
| .result .text-muted small { | ||||
|     word-wrap: break-word; | ||||
| } | ||||
| 
 | ||||
| .modal-wrapper { | ||||
|     box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5); | ||||
| } | ||||
| 
 | ||||
| .modal-wrapper { | ||||
|     background-clip: padding-box; | ||||
|     background-color: #fff; | ||||
|     border: 1px solid rgba(0, 0, 0, 0.2); | ||||
|     border-radius: 6px; | ||||
|     box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5); | ||||
|     outline: 0 none; | ||||
|     position: relative; | ||||
| } | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ | |||
| 
 | ||||
| <div class="modal fade" id="modal-{{ index }}" tabindex="-1" role="dialog" aria-hidden="true"> | ||||
|     <div class="modal-dialog"> | ||||
|         <div class="modal-content"> | ||||
|         <div class="modal-wrapper"> | ||||
|             <div class="modal-header"> | ||||
|                 <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> | ||||
|                 <h4 class="modal-title">{% if result.engine~".png" in favicons %}{{ draw_favicon(result.engine) }} {% endif %}{{ result.title|striptags }}</h4> | ||||
|  | @ -20,8 +20,14 @@ | |||
|                 <span class="label label-default pull-right">{{ result.engine }}</span> | ||||
|                 <p class="text-muted pull-left">{{ result.pretty_url }}</p> | ||||
|                 <div class="clearfix"></div> | ||||
|                 <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> | ||||
|                 <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> | ||||
| 				<div class="row"> | ||||
|                     <div class="col-md-6"> | ||||
|                         <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> | ||||
|                     </div> | ||||
|                     <div class="col-md-6"> | ||||
|                         <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> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  |  | |||
|  | @ -395,11 +395,9 @@ def index(): | |||
|             search.paging = True | ||||
| 
 | ||||
|         if search.request_data.get('format', 'html') == 'html': | ||||
|             if 'content' in result: | ||||
|                 result['content'] = highlight_content(result['content'], | ||||
|                                                       search.query.encode('utf-8'))  # noqa | ||||
|             result['title'] = highlight_content(result['title'], | ||||
|                                                 search.query.encode('utf-8')) | ||||
|             if 'content' in result and result['content']: | ||||
|                 result['content'] = highlight_content(result['content'][:1024], search.query.encode('utf-8')) | ||||
|             result['title'] = highlight_content(result['title'], search.query.encode('utf-8')) | ||||
|         else: | ||||
|             if result.get('content'): | ||||
|                 result['content'] = html_to_text(result['content']).strip() | ||||
|  | @ -559,7 +557,6 @@ def preferences(): | |||
|     lang = request.preferences.get_value('language') | ||||
|     disabled_engines = request.preferences.engines.get_disabled() | ||||
|     allowed_plugins = request.preferences.plugins.get_enabled() | ||||
|     results_on_new_tab = request.preferences.get_value('results_on_new_tab') | ||||
| 
 | ||||
|     # stats for preferences page | ||||
|     stats = {} | ||||
|  | @ -732,7 +729,8 @@ def run(): | |||
|         debug=settings['general']['debug'], | ||||
|         use_debugger=settings['general']['debug'], | ||||
|         port=settings['server']['port'], | ||||
|         host=settings['server']['bind_address'] | ||||
|         host=settings['server']['bind_address'], | ||||
|         threaded=True | ||||
|     ) | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 potato
						potato