From a8ec7fe6a4ad86a8eea4aa6be441984bc5ef7e5a Mon Sep 17 00:00:00 2001 From: pw3t Date: Wed, 15 Jan 2014 22:25:10 +0100 Subject: [PATCH] [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 0000000000000000000000000000000000000000..4130bea1b97673078f1fc9b79fd7c829678b3a19 GIT binary patch literal 1150 zcmb7^O=uHA9K}ac5h{dIp;A9EN&+cHiWIz9pn$P(9u%|L-I>|vo7s)2(Mxvu?c4d!dow$;%L=iKXIq=# zH6aeQ2+<*gNE4P=3F{Qm$G%l7LrmKqS?m#6d?jcSlQG$HtRHCU4Vog>ADH>dA{$`E zPSU3%6m=<*?HaW@z08=bp>?+=ib&#z?DEiRaj8pT-TD;7n6|_R6yp1QbPjpgd)C9I z{Z$MWTqH*vY(M5;$9N^=xPxtntMs~v4@hRiG1`YDu0K?`@mOK*ou>Mjd&~AC4?ija z8jlAhh4w)&$}4n?NX)#_n0g}d;=Q7JREepX|L4tkYY(^(qvjbj)=+bIByK*HnE$A# z9@Vs&cmAFK!xxRtgZ2FSqY~?mcsO&{$HJn*?O7l5pCoS0didFp&);*=d)~2ryMFHf z#?u;!Qxb`j9=7DF7@zjA@L6H{IrG)}{3Wg_apD(!uJzmfXFfGS@*2r=lK4pGT=W#H z$V^o5jO%$_*0}#tvgX)6<4NVY_xAk*T^EB0jjp0Xx+sw@_()%HBdVbmJlkhHCR592 zE(4ay02zzM=1Ypm1{C{s7Z+ oIK)0n6KXQULNNCiZ?q7ji~Ki?k<}z-{}c7ga^7wr?C&Z426T_eApigX literal 0 HcmV?d00001 diff --git a/searx/static/img/icon_twitter.png b/searx/static/img/icon_twitter.png new file mode 100644 index 0000000000000000000000000000000000000000..b4a71699a727c7642612dfa116c748df3c530fe1 GIT binary patch literal 1150 zcmd5)O-lk%6un{KMi>_n?QH2z|AEpUs8vFnq*c3Gwi4VWK~P9g#F)@V5VDO#m`Wj1 zi6iuZF_nfwAvhW{l=i{vUUYJrrd$QR;mo~r?>*-o-Wz}ce5_W$_bAK`0t^Fy9f2jR zbm|xYu%};)G5ANYpck74Bbb{J{XCj*#{Sw6yiXUtu!>fR54lA4 zHxysAN(TX8VhETN?Lj%6j=#4XuHQ7e+FZMypOP~Zhgv@6j|r#P)iCrxe7TzR)b|{s zo~wS72F}r$7-?9PGhaxGak4sZ6qRee>dpf4>0kNuQHi@wj#q#YkM5It&HKEw zvi;RVDGcl(%E?Mi7}N4|k@4L-f%j@_lpk$43b`P#!WuBr&uqC<$yHmqQs8H_v+ADO z8s${K$u7?qQ$D|{Pqm-s_58p820X(Kni$hAfR+uQ$pMtj9i+Q4YXT@CSgFVP0GFBa AX8-^I literal 0 HcmV?d00001 diff --git a/searx/static/img/icon_vimeo.png b/searx/static/img/icon_vimeo.png new file mode 100644 index 0000000000000000000000000000000000000000..4fe4336daf5ccc254f20c869e8ed95a6691027c6 GIT binary patch literal 6518 zcmeHL%We}f6djP*vtUiKp)HNrv17v)1Z)u>fcOC51KocJo6?a?Z%cjLfJQ4UwBJNsPR^)u&3Q>(#@xFZavYFi*W&T7vCLwe)EiJFWXW zakYKXxbf&j_OqR4Xzj+6Y<1??P`Pa{O1(G2WrGF?T-K!vHes>IE&wy529X z2Y=Ajn6SRJcq8{q|KJVSbfa%A!#HLSUDOHc1&z5w4h-ZFJ#aDZFg^0@*8h|91Kaw& z(y8C^LEG;8;D4Lro-CW^qyxMH$PV^+24E+1F;YjSeEaM zj2YSb-;5dajhHsJ!4g~l7c$3r`Y&R|V$`OOZWDVqT}W8rDdWgb))50 z&-oKMbX>eV4rLObdhm%cF%TEmF=t%Lq!<5MU;Ckr&mqLEeOL@RPVt*AT($Qo{_J$p zZ1e3z_W8l_oHrXw;pRNYWBrjol{;+ABYJ+_+B*!5xeIx0J+SY?*|Wk|;K%#Z`I1w{ zBPTK!Ok5)#^qtlR9X1&6beh@v{3V0m+k1aLACE(@>Daw7JwNNuF9q?6CaaGP4~{SR z3mzvYhF~q=&BtZ_Tkmcag$(4ViPhONIS*p5YSm)!9MON+>spYy>oooEmmpwdf_hk) zIc|9nPKAFNYu-ISdfzxE_WHwzG_aPr1k{g?Aq7n>Mt=`H!`Y1#n>UH!iNDS_*7{6Z^CoM$!(nz1F?lYV)7gKBhaZb6MJ&XO{V!low#UF81OE>LzW~o~MkW9N literal 0 HcmV?d00001 diff --git a/searx/static/img/icon_youtube.png b/searx/static/img/icon_youtube.png new file mode 100644 index 0000000000000000000000000000000000000000..977887dbbb8407afcc5c1a9c42109560826fd1a7 GIT binary patch literal 1150 zcmd7Rze@sP7zglI=*Qhzc5100Qe%q{^bhneL~GE{($>;H5CqpyK|^7Q4Vps{I7vg0 z1`S5HR0u&hpSXxFaUgvAo_FY-5|NYd@p<3(p6B}vH=GbYKB_9XFNvKAAtFMEWnzgH zyUs(bu^0B+toLzP((I{BS<)Tg`I}Ey?tu3xDR8C{Mx@Ds3!UI~j!9_~(#-xqeK2Ru zUNwlhzHl^yO63*n8;6)y_Sj2%`mSt4p1bZ4+!o?FRIAmlqvJcM^Sk`MlqcilIeW{x zS0sLeTCLVoD(OhBoDAixIYliDi6#m#45O!BuOoH&F_g1siycKRvey?&6wzw6y4vkF z(wQ%WV)vemlkX_OhX%ndw)hCsG|_B+V{7}(({tzS*|M$#%gpqt(I@2c29m2Up1M2Z m+;xBOStE={^M@)jg?6m~ literal 0 HcmV?d00001 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)