From cf8f444e8597bf527ef4bfc691b6d45d5704f77f Mon Sep 17 00:00:00 2001 From: pw3t Date: Sun, 12 Jan 2014 18:31:57 +0100 Subject: [ehn] Add a 'featured result feature'm putting on top of the reasults ddg definitions and wikipedia (ugly html / css) [ehn] Add a templates for videos, so the thumbnails all have the same side --- searx/engines/vimeo.py | 10 +++++++--- searx/engines/youtube.py | 11 +++++++++-- searx/static/css/style.css | 8 ++++++++ searx/templates/result_templates/videos.html | 7 +++++++ searx/templates/results.html | 15 +++++++++++++++ searx/webapp.py | 8 +++++++- 6 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 searx/templates/result_templates/videos.html diff --git a/searx/engines/vimeo.py b/searx/engines/vimeo.py index 52c89ffdd..35bc3d50a 100644 --- a/searx/engines/vimeo.py +++ b/searx/engines/vimeo.py @@ -35,7 +35,11 @@ def response(resp): for result in dom.xpath(results_xpath): url = base_url + result.xpath(url_xpath)[0] title = p.unescape(extract_text(result.xpath(title_xpath))) - content = ' '.format(url, title, extract_text(result.xpath(content_xpath)[0])) - results.append({'url': url, 'title': title, 'content': content}) - + thumbnail = extract_text(result.xpath(content_xpath)[0]) + content = ' '.format(url, title, thumbnail) + results.append({'url': url + , 'title': title + , 'content': content + , 'template':'videos.html' + , 'thumbnail': thumbnail}) return results diff --git a/searx/engines/youtube.py b/searx/engines/youtube.py index 1331f480e..cefdb6536 100644 --- a/searx/engines/youtube.py +++ b/searx/engines/youtube.py @@ -26,14 +26,21 @@ def response(resp): url = url[:-1] title = result['title']['$t'] content = '' + + thumbnail = '' if len(result['media$group']['media$thumbnail']): - content += ''.format(url, result['media$group']['media$thumbnail'][0]['url']) + thumbnail = result['media$group']['media$thumbnail'][0]['url'] + content += ''.format(url, thumbnail) if len(content): content += '
' + result['content']['$t'] else: content = result['content']['$t'] - results.append({'url': url, 'title': title, 'content': content}) + results.append({'url': url + , 'title': title + , 'content': content + , 'template':'videos.html' + , 'thumbnail':thumbnail}) return results diff --git a/searx/static/css/style.css b/searx/static/css/style.css index 2e6f450e1..90db60d6b 100644 --- a/searx/static/css/style.css +++ b/searx/static/css/style.css @@ -70,6 +70,7 @@ a { text-decoration: none; color: #1a11be; } a:visited { color: #7b11be; } .result { margin: 19px 0 18px 0; padding: 0; max-width: 55em; clear: both; } +.result:hover { background: #e8e7e6; } .result_title { margin-bottom: 0; } .result h3 { font-size: 1em; word-wrap:break-word; margin: 5px 0 1px 0; padding: 0 } .result .content { font-size: 0.8em; margin: 0; padding: 0; max-width: 54em; word-wrap:break-word; line-height: 1.24; } @@ -143,6 +144,13 @@ tr:hover td { background: #DDDDDD; } #result_count { font-size: 0.8em; margin: 2px 0 2px 0; padding: 0 } +#fr { padding: 2px 6px; +display: inline-block; +background: #ECF0F1; +border-radius: 4px; +border: 1px solid #3498DB;; +width:55em;} + #suggestions { position: absolute; left: 54em; width: 12em; margin: 0 2px 5px 5px; padding: 0 2px 2px 2px; } #suggestions span { display: block; font-size: 0.8em; margin: 0 2px 10px 2px; padding: 0; } #suggestions form { display: block; } diff --git a/searx/templates/result_templates/videos.html b/searx/templates/result_templates/videos.html new file mode 100644 index 000000000..97c966e43 --- /dev/null +++ b/searx/templates/result_templates/videos.html @@ -0,0 +1,7 @@ +
+

+

{{ result.title|safe }}

+  {{ result.title }} +

{{ result.url }}

+

+
diff --git a/searx/templates/results.html b/searx/templates/results.html index 4ca36c656..411f84c64 100644 --- a/searx/templates/results.html +++ b/searx/templates/results.html @@ -9,9 +9,24 @@ {% if suggestions %}
Suggestions: {% for suggestion in suggestions %}
{% endfor %}
{% endif %} + +
Number of results: {{ number_of_results }}
+ {% if featured_results %} +
+ + {% for result in featured_results %} + {% if result['template'] %} + {% include 'result_templates/'+result['template'] %} + {% else %} + {% include 'result_templates/default.html' %} + {% endif %} + {% endfor %} +
+ {% endif %} + {% for result in results %} {% if result['template'] %} {% include 'result_templates/'+result['template'] %} diff --git a/searx/webapp.py b/searx/webapp.py index 48448eb25..72395709c 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -125,6 +125,7 @@ def index(): results, suggestions = search(query, request, selected_engines) + featured_results = [] for result in results: if request_data.get('format', 'html') == 'html': if 'content' in result: @@ -139,6 +140,10 @@ def index(): else: result['pretty_url'] = result['url'] + if 'wikipedia' in result['engines'] or 'ddg definitions' in result['engines']: + featured_results.append(result) + results.remove(result) + if request_data.get('format') == 'json': return Response(json.dumps({'query': query, 'results': results}), mimetype='application/json') elif request_data.get('format') == 'csv': @@ -167,7 +172,8 @@ def index(): ,results=results ,q=request_data['q'] ,selected_categories=selected_categories - ,number_of_results=len(results) + ,number_of_results=len(results)+len(featured_results) + ,featured_results=featured_results ,suggestions=suggestions ) -- cgit v1.2.3 From fdb6fac214c2fb5bdc6c27492bc45c6694483fb4 Mon Sep 17 00:00:00 2001 From: pw3t Date: Mon, 13 Jan 2014 22:24:05 +0100 Subject: [ehn] Add possibility to add icon in results (more ugly html / css, need fix) --- searx/static/img/icon_wikipedia.png | Bin 0 -> 14858 bytes searx/templates/result_templates/default.html | 11 ++++++++++- searx/templates/result_templates/featured_results.html | 10 ++++++++++ searx/templates/results.html | 11 +---------- searx/webapp.py | 11 ++++++++--- 5 files changed, 29 insertions(+), 14 deletions(-) create mode 100644 searx/static/img/icon_wikipedia.png create mode 100644 searx/templates/result_templates/featured_results.html diff --git a/searx/static/img/icon_wikipedia.png b/searx/static/img/icon_wikipedia.png new file mode 100644 index 000000000..911fa76f6 Binary files /dev/null and b/searx/static/img/icon_wikipedia.png differ diff --git a/searx/templates/result_templates/default.html b/searx/templates/result_templates/default.html index 48c0775ae..3f2d0f360 100644 --- a/searx/templates/result_templates/default.html +++ b/searx/templates/result_templates/default.html @@ -1,5 +1,14 @@
-

{{ result.title|safe }}

+ + {% if result['favicon'] %} +
+ {{result['favicon']}}.png +
+ {% endif %} + +
+

{{ result.title|safe }}


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

{{ result.pretty_url }}

+
diff --git a/searx/templates/result_templates/featured_results.html b/searx/templates/result_templates/featured_results.html new file mode 100644 index 000000000..4aeddfe24 --- /dev/null +++ b/searx/templates/result_templates/featured_results.html @@ -0,0 +1,10 @@ +
+ {% for result in featured_results %} + + {% if result['template'] %} + {% include 'result_templates/'+result['template'] %} + {% else %} + {% include 'result_templates/default.html' %} + {% endif %} + {% endfor %} +
diff --git a/searx/templates/results.html b/searx/templates/results.html index 411f84c64..b35416ffa 100644 --- a/searx/templates/results.html +++ b/searx/templates/results.html @@ -15,16 +15,7 @@ Number of results: {{ number_of_results }} {% if featured_results %} -
- - {% for result in featured_results %} - {% if result['template'] %} - {% include 'result_templates/'+result['template'] %} - {% else %} - {% include 'result_templates/default.html' %} - {% endif %} - {% endfor %} -
+ {% include 'result_templates/featured_results.html' %} {% endif %} {% for result in results %} diff --git a/searx/webapp.py b/searx/webapp.py index 72395709c..5fc981a89 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -140,9 +140,14 @@ def index(): else: result['pretty_url'] = result['url'] - if 'wikipedia' in result['engines'] or 'ddg definitions' in result['engines']: - featured_results.append(result) - results.remove(result) + for engine in result['engines']: + if engine in ['wikipedia']: + result['favicon'] = engine + featured_results.append(result) + results.remove(result) + elif engine in ['ddg definitions']: + featured_results.append(result) + results.remove(result) if request_data.get('format') == 'json': return Response(json.dumps({'query': query, 'results': results}), mimetype='application/json') -- cgit v1.2.3 From a8ec7fe6a4ad86a8eea4aa6be441984bc5ef7e5a Mon Sep 17 00:00:00 2001 From: pw3t Date: Wed, 15 Jan 2014 22:25:10 +0100 Subject: [ehn] add favicons for vimeo, soundcloud, twitter and youtube --- searx/engines/mediawiki.py | 8 ++++++++ searx/static/img/icon_soundcloud.png | Bin 0 -> 1150 bytes searx/static/img/icon_twitter.png | Bin 0 -> 1150 bytes searx/static/img/icon_vimeo.png | Bin 0 -> 6518 bytes searx/static/img/icon_youtube.png | Bin 0 -> 1150 bytes searx/templates/result_templates/default.html | 2 +- searx/templates/result_templates/videos.html | 8 ++++++++ searx/webapp.py | 8 +++----- 8 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 searx/static/img/icon_soundcloud.png create mode 100644 searx/static/img/icon_twitter.png create mode 100644 searx/static/img/icon_vimeo.png create mode 100644 searx/static/img/icon_youtube.png diff --git a/searx/engines/mediawiki.py b/searx/engines/mediawiki.py index d4b3fd843..19b4406b5 100644 --- a/searx/engines/mediawiki.py +++ b/searx/engines/mediawiki.py @@ -14,5 +14,13 @@ def request(query, params): def response(resp): search_results = loads(resp.text) res = search_results.get('query', {}).get('search', []) + return [{'url': url + 'wiki/' + quote(result['title'].replace(' ', '_').encode('utf-8')), 'title': result['title']} for result in res[:int(number_of_results)]] + + if not len(res): + return results + for result in res[:int(number_of_results)]: + results.append({'url': url + 'wiki/' + quote(result['title'].replace(' ', '_').encode('utf-8')), 'title': result['title'], 'favicon':'wikipedia'}) + return results + diff --git a/searx/static/img/icon_soundcloud.png b/searx/static/img/icon_soundcloud.png new file mode 100644 index 000000000..4130bea1b Binary files /dev/null and b/searx/static/img/icon_soundcloud.png differ diff --git a/searx/static/img/icon_twitter.png b/searx/static/img/icon_twitter.png new file mode 100644 index 000000000..b4a71699a Binary files /dev/null and b/searx/static/img/icon_twitter.png differ diff --git a/searx/static/img/icon_vimeo.png b/searx/static/img/icon_vimeo.png new file mode 100644 index 000000000..4fe4336da Binary files /dev/null and b/searx/static/img/icon_vimeo.png differ diff --git a/searx/static/img/icon_youtube.png b/searx/static/img/icon_youtube.png new file mode 100644 index 000000000..977887dbb Binary files /dev/null and b/searx/static/img/icon_youtube.png differ diff --git a/searx/templates/result_templates/default.html b/searx/templates/result_templates/default.html index 3f2d0f360..14f527361 100644 --- a/searx/templates/result_templates/default.html +++ b/searx/templates/result_templates/default.html @@ -2,7 +2,7 @@ {% if result['favicon'] %}
- {{result['favicon']}}.png + {{result['favicon']}}.png
{% endif %} diff --git a/searx/templates/result_templates/videos.html b/searx/templates/result_templates/videos.html index 97c966e43..524c99116 100644 --- a/searx/templates/result_templates/videos.html +++ b/searx/templates/result_templates/videos.html @@ -1,4 +1,12 @@
+ + {% if result['favicon'] %} +
+ {{result['favicon']}}.png +
+ {% endif %} + +

{{ result.title|safe }}

 {{ result.title }} diff --git a/searx/webapp.py b/searx/webapp.py index 5fc981a89..b26e868f5 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -141,11 +141,9 @@ def index(): result['pretty_url'] = result['url'] for engine in result['engines']: - if engine in ['wikipedia']: - result['favicon'] = engine - featured_results.append(result) - results.remove(result) - elif engine in ['ddg definitions']: + if engine in ['wikipedia', 'youtube', 'vimeo', 'soundcloud', 'twitter']: + result['favicon'] = engine + if engine in ['wikipedia', 'ddg definitions']: featured_results.append(result) results.remove(result) -- cgit v1.2.3 From d43bd05582c189d8696d58e22c160399ed0b811d Mon Sep 17 00:00:00 2001 From: pw3t Date: Sun, 12 Jan 2014 18:31:57 +0100 Subject: [ehn] Add a 'featured result feature'm putting on top of the reasults ddg definitions and wikipedia (ugly html / css) [ehn] Add a templates for videos, so the thumbnails all have the same side --- searx/templates/result_templates/videos.html | 4 +--- searx/webapp.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/searx/templates/result_templates/videos.html b/searx/templates/result_templates/videos.html index 524c99116..ae6d8f16c 100644 --- a/searx/templates/result_templates/videos.html +++ b/searx/templates/result_templates/videos.html @@ -1,12 +1,10 @@
- {% if result['favicon'] %}
- {{result['favicon']}}.png + {{result['favicon']}}.ico
{% endif %} -

{{ result.title|safe }}

 {{ result.title }} diff --git a/searx/webapp.py b/searx/webapp.py index b26e868f5..43bef7db9 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -141,7 +141,7 @@ def index(): result['pretty_url'] = result['url'] for engine in result['engines']: - if engine in ['wikipedia', 'youtube', 'vimeo', 'soundcloud', 'twitter']: + if engine in ['wikipedia', 'youtube', 'vimeo', 'soundcloud', 'twitter', 'stackoverflow']: result['favicon'] = engine if engine in ['wikipedia', 'ddg definitions']: featured_results.append(result) -- cgit v1.2.3 From 91057682b5f813200ffd887fcb0747aa344dfa0e Mon Sep 17 00:00:00 2001 From: pw3t Date: Mon, 13 Jan 2014 22:24:05 +0100 Subject: [ehn] Add possibility to add icon in results (more ugly html / css, need fix) --- searx/templates/result_templates/default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searx/templates/result_templates/default.html b/searx/templates/result_templates/default.html index 14f527361..ab6d469b4 100644 --- a/searx/templates/result_templates/default.html +++ b/searx/templates/result_templates/default.html @@ -2,7 +2,7 @@ {% if result['favicon'] %}
- {{result['favicon']}}.png + {{result['favicon']}}.ico
{% endif %} -- cgit v1.2.3 From dd1baa6d5894c814625cdf19e71b797ab6354d9c Mon Sep 17 00:00:00 2001 From: pw3t Date: Thu, 16 Jan 2014 21:58:18 +0100 Subject: [fix] replace the png icons by ico's, minor chnage in the html --- searx/static/img/icon_github.ico | Bin 0 -> 6518 bytes searx/static/img/icon_soundcloud.ico | Bin 0 -> 1150 bytes searx/static/img/icon_soundcloud.png | Bin 1150 -> 0 bytes searx/static/img/icon_stackoverflow.ico | Bin 0 -> 1150 bytes searx/static/img/icon_twitter.ico | Bin 0 -> 1150 bytes searx/static/img/icon_twitter.png | Bin 1150 -> 0 bytes searx/static/img/icon_vimeo.ico | Bin 0 -> 6518 bytes searx/static/img/icon_vimeo.png | Bin 6518 -> 0 bytes searx/static/img/icon_wikipedia.ico | Bin 0 -> 14858 bytes searx/static/img/icon_wikipedia.png | Bin 14858 -> 0 bytes searx/static/img/icon_youtube.ico | Bin 0 -> 1150 bytes searx/static/img/icon_youtube.png | Bin 1150 -> 0 bytes searx/webapp.py | 2 +- 13 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 searx/static/img/icon_github.ico create mode 100644 searx/static/img/icon_soundcloud.ico delete mode 100644 searx/static/img/icon_soundcloud.png create mode 100644 searx/static/img/icon_stackoverflow.ico create mode 100644 searx/static/img/icon_twitter.ico delete mode 100644 searx/static/img/icon_twitter.png create mode 100644 searx/static/img/icon_vimeo.ico delete mode 100644 searx/static/img/icon_vimeo.png create mode 100644 searx/static/img/icon_wikipedia.ico delete mode 100644 searx/static/img/icon_wikipedia.png create mode 100644 searx/static/img/icon_youtube.ico delete mode 100644 searx/static/img/icon_youtube.png diff --git a/searx/static/img/icon_github.ico b/searx/static/img/icon_github.ico new file mode 100644 index 000000000..133f0ca35 Binary files /dev/null and b/searx/static/img/icon_github.ico differ diff --git a/searx/static/img/icon_soundcloud.ico b/searx/static/img/icon_soundcloud.ico new file mode 100644 index 000000000..4130bea1b Binary files /dev/null and b/searx/static/img/icon_soundcloud.ico differ diff --git a/searx/static/img/icon_soundcloud.png b/searx/static/img/icon_soundcloud.png deleted file mode 100644 index 4130bea1b..000000000 Binary files a/searx/static/img/icon_soundcloud.png and /dev/null differ diff --git a/searx/static/img/icon_stackoverflow.ico b/searx/static/img/icon_stackoverflow.ico new file mode 100644 index 000000000..b2242bc6c Binary files /dev/null and b/searx/static/img/icon_stackoverflow.ico differ diff --git a/searx/static/img/icon_twitter.ico b/searx/static/img/icon_twitter.ico new file mode 100644 index 000000000..b4a71699a Binary files /dev/null and b/searx/static/img/icon_twitter.ico differ diff --git a/searx/static/img/icon_twitter.png b/searx/static/img/icon_twitter.png deleted file mode 100644 index b4a71699a..000000000 Binary files a/searx/static/img/icon_twitter.png and /dev/null differ diff --git a/searx/static/img/icon_vimeo.ico b/searx/static/img/icon_vimeo.ico new file mode 100644 index 000000000..4fe4336da Binary files /dev/null and b/searx/static/img/icon_vimeo.ico differ diff --git a/searx/static/img/icon_vimeo.png b/searx/static/img/icon_vimeo.png deleted file mode 100644 index 4fe4336da..000000000 Binary files a/searx/static/img/icon_vimeo.png and /dev/null differ diff --git a/searx/static/img/icon_wikipedia.ico b/searx/static/img/icon_wikipedia.ico new file mode 100644 index 000000000..911fa76f6 Binary files /dev/null and b/searx/static/img/icon_wikipedia.ico differ diff --git a/searx/static/img/icon_wikipedia.png b/searx/static/img/icon_wikipedia.png deleted file mode 100644 index 911fa76f6..000000000 Binary files a/searx/static/img/icon_wikipedia.png and /dev/null differ diff --git a/searx/static/img/icon_youtube.ico b/searx/static/img/icon_youtube.ico new file mode 100644 index 000000000..977887dbb Binary files /dev/null and b/searx/static/img/icon_youtube.ico differ diff --git a/searx/static/img/icon_youtube.png b/searx/static/img/icon_youtube.png deleted file mode 100644 index 977887dbb..000000000 Binary files a/searx/static/img/icon_youtube.png and /dev/null differ diff --git a/searx/webapp.py b/searx/webapp.py index 43bef7db9..6bd4e6097 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -141,7 +141,7 @@ def index(): result['pretty_url'] = result['url'] for engine in result['engines']: - if engine in ['wikipedia', 'youtube', 'vimeo', 'soundcloud', 'twitter', 'stackoverflow']: + if engine in ['wikipedia', 'youtube', 'vimeo', 'soundcloud', 'twitter', 'stackoverflow', 'github']: result['favicon'] = engine if engine in ['wikipedia', 'ddg definitions']: featured_results.append(result) -- cgit v1.2.3 From 380b440a55ba3b8ec1430843226fa6b4b0dfe289 Mon Sep 17 00:00:00 2001 From: pw3t Date: Thu, 16 Jan 2014 21:58:18 +0100 Subject: [fix] replace the png icons by ico's, minor chnage in the html --- searx/engines/mediawiki.py | 6 ------ searx/static/css/style.css | 7 ------- searx/templates/result_templates/featured_results.html | 10 ---------- searx/templates/results.html | 3 --- searx/webapp.py | 3 --- 5 files changed, 29 deletions(-) delete mode 100644 searx/templates/result_templates/featured_results.html diff --git a/searx/engines/mediawiki.py b/searx/engines/mediawiki.py index 19b4406b5..00ad0f106 100644 --- a/searx/engines/mediawiki.py +++ b/searx/engines/mediawiki.py @@ -18,9 +18,3 @@ def response(resp): return [{'url': url + 'wiki/' + quote(result['title'].replace(' ', '_').encode('utf-8')), 'title': result['title']} for result in res[:int(number_of_results)]] - if not len(res): - return results - for result in res[:int(number_of_results)]: - results.append({'url': url + 'wiki/' + quote(result['title'].replace(' ', '_').encode('utf-8')), 'title': result['title'], 'favicon':'wikipedia'}) - return results - diff --git a/searx/static/css/style.css b/searx/static/css/style.css index 868f2f813..83d281806 100644 --- a/searx/static/css/style.css +++ b/searx/static/css/style.css @@ -151,13 +151,6 @@ tr:hover td { background: #DDDDDD; } #result_count { font-size: 0.8em; margin: 2px 0 2px 0; padding: 0 } -#fr { padding: 2px 6px; -display: inline-block; -background: #ECF0F1; -border-radius: 4px; -border: 1px solid #3498DB;; -width:55em;} - #suggestions { position: absolute; left: 54em; width: 12em; margin: 0 2px 5px 5px; padding: 0 2px 2px 2px; } #suggestions span { display: block; font-size: 0.8em; margin: 0 2px 10px 2px; padding: 0; } #suggestions form { display: block; } diff --git a/searx/templates/result_templates/featured_results.html b/searx/templates/result_templates/featured_results.html deleted file mode 100644 index 4aeddfe24..000000000 --- a/searx/templates/result_templates/featured_results.html +++ /dev/null @@ -1,10 +0,0 @@ -
- {% for result in featured_results %} - - {% if result['template'] %} - {% include 'result_templates/'+result['template'] %} - {% else %} - {% include 'result_templates/default.html' %} - {% endif %} - {% endfor %} -
diff --git a/searx/templates/results.html b/searx/templates/results.html index b35416ffa..be40900c3 100644 --- a/searx/templates/results.html +++ b/searx/templates/results.html @@ -14,9 +14,6 @@
Number of results: {{ number_of_results }}
- {% if featured_results %} - {% include 'result_templates/featured_results.html' %} - {% endif %} {% for result in results %} {% if result['template'] %} diff --git a/searx/webapp.py b/searx/webapp.py index bc534d36b..07db95452 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -144,9 +144,6 @@ def index(): for engine in result['engines']: if engine in ['wikipedia', 'youtube', 'vimeo', 'soundcloud', 'twitter', 'stackoverflow', 'github']: result['favicon'] = engine - if engine in ['wikipedia', 'ddg definitions']: - featured_results.append(result) - results.remove(result) if request_data.get('format') == 'json': return Response(json.dumps({'query': query, 'results': results}), mimetype='application/json') -- cgit v1.2.3