1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-19 19:00:10 +01:00
This commit is contained in:
potato 2016-09-06 11:47:34 +02:00
commit 9d08c81f47
9 changed files with 63 additions and 22 deletions

View File

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

View File

@ -19,6 +19,7 @@ import gc
import threading import threading
from thread import start_new_thread from thread import start_new_thread
from time import time from time import time
from uuid import uuid4
import searx.poolrequests as requests_lib import searx.poolrequests as requests_lib
from searx.engines import ( from searx.engines import (
categories, engines categories, engines
@ -56,19 +57,20 @@ def search_request_wrapper(fn, url, engine_name, **kwargs):
def threaded_requests(requests): def threaded_requests(requests):
timeout_limit = max(r[2]['timeout'] for r in requests) timeout_limit = max(r[2]['timeout'] for r in requests)
search_start = time() search_start = time()
search_id = uuid4().__str__()
for fn, url, request_args, engine_name in requests: for fn, url, request_args, engine_name in requests:
request_args['timeout'] = timeout_limit request_args['timeout'] = timeout_limit
th = threading.Thread( th = threading.Thread(
target=search_request_wrapper, target=search_request_wrapper,
args=(fn, url, engine_name), args=(fn, url, engine_name),
kwargs=request_args, kwargs=request_args,
name='search_request', name=search_id,
) )
th._engine_name = engine_name th._engine_name = engine_name
th.start() th.start()
for th in threading.enumerate(): 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)) remaining_time = max(0.0, timeout_limit - (time() - search_start))
th.join(remaining_time) th.join(remaining_time)
if th.isAlive(): if th.isAlive():

View File

@ -25,7 +25,7 @@ outgoing: # communication with search engines
pool_maxsize : 10 # Number of simultaneous requests by host pool_maxsize : 10 # Number of simultaneous requests by host
# uncomment below section if you want to use a proxy # uncomment below section if you want to use a proxy
# see http://docs.python-requests.org/en/latest/user/advanced/#proxies # 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 : # proxies :
# http : http://127.0.0.1:8080 # http : http://127.0.0.1:8080
# https: 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

View File

@ -6,7 +6,7 @@
.favicon { .favicon {
margin-bottom:-3px; margin-bottom:-3px;
} }
a { a {
color: @black; color: @black;
text-decoration: none; text-decoration: none;
@ -18,7 +18,7 @@
&:visited{ &:visited{
color: @violet; color: @violet;
} }
.highlight { .highlight {
background-color: @dim-gray; background-color: @dim-gray;
// Chrome hack: bold is different size than normal // Chrome hack: bold is different size than normal
@ -64,10 +64,9 @@
float: left !important; float: left !important;
width: 24%; width: 24%;
margin: .5%; margin: .5%;
a{ a {
display: block; display: block;
width: 100%; width: 100%;
height: 170px;
background-size: cover; background-size: cover;
} }
} }
@ -148,3 +147,21 @@
color: @gray; color: @gray;
background: transparent; 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;
}

View File

@ -6,10 +6,10 @@
.favicon { .favicon {
margin-bottom:-3px; margin-bottom:-3px;
} }
a { a {
vertical-align: bottom; vertical-align: bottom;
.highlight { .highlight {
font-weight:bold; font-weight:bold;
} }
@ -81,3 +81,21 @@
color: #AAA; color: #AAA;
background: #FFF; 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;
}

View File

@ -6,7 +6,7 @@
<div class="modal fade" id="modal-{{ index }}" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal fade" id="modal-{{ index }}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-wrapper">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button> <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</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> <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> <span class="label label-default pull-right">{{ result.engine }}</span>
<p class="text-muted pull-left">{{ result.pretty_url }}</p> <p class="text-muted pull-left">{{ result.pretty_url }}</p>
<div class="clearfix"></div> <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> <div class="row">
<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="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> </div>
</div> </div>

View File

@ -395,11 +395,9 @@ def index():
search.paging = True search.paging = True
if search.request_data.get('format', 'html') == 'html': if search.request_data.get('format', 'html') == 'html':
if 'content' in result: if 'content' in result and result['content']:
result['content'] = highlight_content(result['content'], result['content'] = highlight_content(result['content'][:1024], search.query.encode('utf-8'))
search.query.encode('utf-8')) # noqa result['title'] = highlight_content(result['title'], search.query.encode('utf-8'))
result['title'] = highlight_content(result['title'],
search.query.encode('utf-8'))
else: else:
if result.get('content'): if result.get('content'):
result['content'] = html_to_text(result['content']).strip() result['content'] = html_to_text(result['content']).strip()
@ -559,7 +557,6 @@ def preferences():
lang = request.preferences.get_value('language') lang = request.preferences.get_value('language')
disabled_engines = request.preferences.engines.get_disabled() disabled_engines = request.preferences.engines.get_disabled()
allowed_plugins = request.preferences.plugins.get_enabled() allowed_plugins = request.preferences.plugins.get_enabled()
results_on_new_tab = request.preferences.get_value('results_on_new_tab')
# stats for preferences page # stats for preferences page
stats = {} stats = {}
@ -732,7 +729,8 @@ def run():
debug=settings['general']['debug'], debug=settings['general']['debug'],
use_debugger=settings['general']['debug'], use_debugger=settings['general']['debug'],
port=settings['server']['port'], port=settings['server']['port'],
host=settings['server']['bind_address'] host=settings['server']['bind_address'],
threaded=True
) )