From ea475ee709379b2189eb83a32f76c5b5427a2a60 Mon Sep 17 00:00:00 2001 From: asciimoo Date: Fri, 25 Oct 2013 02:14:26 +0200 Subject: [PATCH] [enh] url prettify --- searx/templates/result_templates/default.html | 2 +- searx/webapp.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/searx/templates/result_templates/default.html b/searx/templates/result_templates/default.html index 99789484a..f479ca701 100644 --- a/searx/templates/result_templates/default.html +++ b/searx/templates/result_templates/default.html @@ -1,4 +1,4 @@

{{ result.title|safe }}

-

{{ result.engine }}
{% if result.content %}{{ result.content|safe }}
{% endif %}{{ result.url }}

+

{{ result.engine }}
{% if result.content %}{{ result.content|safe }}
{% endif %}{{ result.pretty_url }}

diff --git a/searx/webapp.py b/searx/webapp.py index 7867d66f6..84835b826 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -79,6 +79,11 @@ def index(): selected_categories.append(ccateg) query = request_data['q'].encode('utf-8') results = search(query, request, selected_categories) + for result in results: + if len(result['url']) > 74: + result['pretty_url'] = result['url'][:35] + '[..]' + result['url'][-35:] + else: + result['pretty_url'] = result['url'] if request_data.get('format') == 'json': return Response(json.dumps({'query': query, 'results': results}), mimetype='application/json') template = render('results.html'