summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--searx/engines/mediawiki.py8
-rw-r--r--searx/engines/vimeo.py10
-rw-r--r--searx/engines/youtube.py11
-rw-r--r--searx/static/css/style.css8
-rw-r--r--searx/static/img/icon_github.icobin0 -> 6518 bytes
-rw-r--r--searx/static/img/icon_soundcloud.icobin0 -> 1150 bytes
-rw-r--r--searx/static/img/icon_stackoverflow.icobin0 -> 1150 bytes
-rw-r--r--searx/static/img/icon_twitter.icobin0 -> 1150 bytes
-rw-r--r--searx/static/img/icon_vimeo.icobin0 -> 6518 bytes
-rw-r--r--searx/static/img/icon_wikipedia.icobin0 -> 14858 bytes
-rw-r--r--searx/static/img/icon_youtube.icobin0 -> 1150 bytes
-rw-r--r--searx/templates/result_templates/default.html11
-rw-r--r--searx/templates/result_templates/featured_results.html10
-rw-r--r--searx/templates/result_templates/videos.html13
-rw-r--r--searx/templates/results.html6
-rw-r--r--searx/webapp.py11
16 files changed, 81 insertions, 7 deletions
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/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 = '<a href="{0}"> <img src="{2}"/> </a>'.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 = '<a href="{0}"> <img src="{2}"/> </a>'.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 += '<a href="{0}" title="{0}" ><img src="{1}" /></a>'.format(url, result['media$group']['media$thumbnail'][0]['url'])
+ thumbnail = result['media$group']['media$thumbnail'][0]['url']
+ content += '<a href="{0}" title="{0}" ><img src="{1}" /></a>'.format(url, thumbnail)
if len(content):
content += '<br />' + 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 6abe6b4bb..868f2f813 100644
--- a/searx/static/css/style.css
+++ b/searx/static/css/style.css
@@ -79,6 +79,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; }
@@ -150,6 +151,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/static/img/icon_github.ico b/searx/static/img/icon_github.ico
new file mode 100644
index 000000000..133f0ca35
--- /dev/null
+++ b/searx/static/img/icon_github.ico
Binary files differ
diff --git a/searx/static/img/icon_soundcloud.ico b/searx/static/img/icon_soundcloud.ico
new file mode 100644
index 000000000..4130bea1b
--- /dev/null
+++ b/searx/static/img/icon_soundcloud.ico
Binary files differ
diff --git a/searx/static/img/icon_stackoverflow.ico b/searx/static/img/icon_stackoverflow.ico
new file mode 100644
index 000000000..b2242bc6c
--- /dev/null
+++ b/searx/static/img/icon_stackoverflow.ico
Binary files differ
diff --git a/searx/static/img/icon_twitter.ico b/searx/static/img/icon_twitter.ico
new file mode 100644
index 000000000..b4a71699a
--- /dev/null
+++ b/searx/static/img/icon_twitter.ico
Binary files differ
diff --git a/searx/static/img/icon_vimeo.ico b/searx/static/img/icon_vimeo.ico
new file mode 100644
index 000000000..4fe4336da
--- /dev/null
+++ b/searx/static/img/icon_vimeo.ico
Binary files differ
diff --git a/searx/static/img/icon_wikipedia.ico b/searx/static/img/icon_wikipedia.ico
new file mode 100644
index 000000000..911fa76f6
--- /dev/null
+++ b/searx/static/img/icon_wikipedia.ico
Binary files differ
diff --git a/searx/static/img/icon_youtube.ico b/searx/static/img/icon_youtube.ico
new file mode 100644
index 000000000..977887dbb
--- /dev/null
+++ b/searx/static/img/icon_youtube.ico
Binary files differ
diff --git a/searx/templates/result_templates/default.html b/searx/templates/result_templates/default.html
index 48c0775ae..ab6d469b4 100644
--- a/searx/templates/result_templates/default.html
+++ b/searx/templates/result_templates/default.html
@@ -1,5 +1,14 @@
<div class="result {{ result.class }}">
- <h3 class="result_title"><a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
+
+ {% if result['favicon'] %}
+ <div style="float:left; margin:2px;">
+ <img width="18" height="18" src="static/img/icon_{{result['favicon']}}.ico" alt="{{result['favicon']}}.ico" title="{{result['favicon']}}.ico" />
+ </div>
+ {% endif %}
+
+ <div>
+ <h3 class="result_title"><a href="{{ result.url }}">{{ result.title|safe }}</a></h3></br>
<p class="content">{% if result.content %}{{ result.content|safe }}<br />{% endif %}</p>
<p class="url">{{ result.pretty_url }}</p>
+ </div>
</div>
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 @@
+<div id="fr">
+ {% for result in featured_results %}
+
+ {% if result['template'] %}
+ {% include 'result_templates/'+result['template'] %}
+ {% else %}
+ {% include 'result_templates/default.html' %}
+ {% endif %}
+ {% endfor %}
+</div>
diff --git a/searx/templates/result_templates/videos.html b/searx/templates/result_templates/videos.html
new file mode 100644
index 000000000..ae6d8f16c
--- /dev/null
+++ b/searx/templates/result_templates/videos.html
@@ -0,0 +1,13 @@
+<div class="result">
+ {% if result['favicon'] %}
+ <div style="float:left; margin:2px;">
+ <img width="18" height="18" src="static/img/icon_{{result['favicon']}}.ico" alt="{{result['favicon']}}.ico" title="{{result['favicon']}}.ico" />
+ </div>
+ {% endif %}
+
+ <p>
+ <h3 class="result_title"><a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
+ <a href="{{ result.url }}"><img width="300" height="170" src="{{ result.thumbnail }}" title={{ result.title }} alt=" {{ result.title }}"/></a>
+ <p class="url">{{ result.url }}</p>
+ </p>
+</div>
diff --git a/searx/templates/results.html b/searx/templates/results.html
index 4ca36c656..b35416ffa 100644
--- a/searx/templates/results.html
+++ b/searx/templates/results.html
@@ -9,9 +9,15 @@
{% if suggestions %}
<div id="suggestions"><span>Suggestions: </span>{% for suggestion in suggestions %}<form method="post" action="/"><input type="hidden" name="q" value="{{suggestion}}"><input type="submit" value="{{ suggestion }}" /></form>{% endfor %}</div>
{% endif %}
+
+
<div id ="result_count">
Number of results: {{ number_of_results }}
</div>
+ {% if featured_results %}
+ {% include 'result_templates/featured_results.html' %}
+ {% endif %}
+
{% for result in results %}
{% if result['template'] %}
{% include 'result_templates/'+result['template'] %}
diff --git a/searx/webapp.py b/searx/webapp.py
index ec02e8f5c..5732ba44b 100644
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -120,6 +120,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:
@@ -134,6 +135,13 @@ def index():
else:
result['pretty_url'] = result['url']
+ 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')
elif request_data.get('format') == 'csv':
@@ -162,7 +170,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
)