Przeglądaj źródła

[ehn] add favicons for vimeo, soundcloud, twitter and youtube

pw3t 11 lat temu
rodzic
commit
a8ec7fe6a4

+ 8
- 0
searx/engines/mediawiki.py Wyświetl plik

@@ -14,5 +14,13 @@ def request(query, params):
14 14
 def response(resp):
15 15
     search_results = loads(resp.text)
16 16
     res = search_results.get('query', {}).get('search', [])
17
+
17 18
     return [{'url': url + 'wiki/' + quote(result['title'].replace(' ', '_').encode('utf-8')),
18 19
         'title': result['title']} for result in res[:int(number_of_results)]]
20
+
21
+    if not len(res):
22
+        return results
23
+    for result in res[:int(number_of_results)]:
24
+        results.append({'url': url + 'wiki/' + quote(result['title'].replace(' ', '_').encode('utf-8')), 'title': result['title'], 'favicon':'wikipedia'})
25
+    return results
26
+

BIN
searx/static/img/icon_soundcloud.png Wyświetl plik


BIN
searx/static/img/icon_twitter.png Wyświetl plik


BIN
searx/static/img/icon_vimeo.png Wyświetl plik


BIN
searx/static/img/icon_youtube.png Wyświetl plik


+ 1
- 1
searx/templates/result_templates/default.html Wyświetl plik

@@ -2,7 +2,7 @@
2 2
 
3 3
   {% if result['favicon'] %}
4 4
   <div style="float:left; margin:2px;">
5
-    <img width="24" height="24" src="static/img/icon_{{result['favicon']}}.png" alt="{{result['favicon']}}.png" title="{{result['favicon']}}.png" />
5
+    <img width="18" height="18" src="static/img/icon_{{result['favicon']}}.png" alt="{{result['favicon']}}.png" title="{{result['favicon']}}.png" />
6 6
   </div>
7 7
   {% endif %}
8 8
 

+ 8
- 0
searx/templates/result_templates/videos.html Wyświetl plik

@@ -1,4 +1,12 @@
1 1
 <div class="result">
2
+  
3
+  {% if result['favicon'] %}
4
+  <div style="float:left; margin:2px;">
5
+    <img width="18" height="18" src="static/img/icon_{{result['favicon']}}.png" alt="{{result['favicon']}}.png" title="{{result['favicon']}}.png" />
6
+  </div>
7
+  {% endif %}
8
+
9
+
2 10
     <p>
3 11
       <h3 class="result_title"><a href="{{ result.url }}">{{ result.title|safe }}</a></h3>
4 12
       <a href="{{ result.url }}"><img width="300" height="170"  src="{{ result.thumbnail }}" title={{ result.title }} alt=" {{ result.title }}"/></a>

+ 3
- 5
searx/webapp.py Wyświetl plik

@@ -141,11 +141,9 @@ def index():
141 141
             result['pretty_url'] = result['url']
142 142
 
143 143
         for engine in result['engines']:
144
-            if engine in ['wikipedia']:
145
-                result['favicon'] = engine 
146
-                featured_results.append(result)
147
-                results.remove(result)
148
-            elif engine in ['ddg definitions']:
144
+            if engine in ['wikipedia', 'youtube', 'vimeo', 'soundcloud', 'twitter']:
145
+                result['favicon'] = engine
146
+            if engine in ['wikipedia', 'ddg definitions']:
149 147
                 featured_results.append(result)
150 148
                 results.remove(result)
151 149