From 4ca0d8cb0fd6c0e6b1301a6e8577aea6d928e9dc Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Mon, 15 Jun 2020 18:25:05 +0200 Subject: [PATCH 1/3] [enh] add translatable strings to javascript - closes #461 --- searx/static/themes/oscar/js/searx.js | 2 +- searx/static/themes/oscar/js/searx.min.js | Bin 5217 -> 5215 bytes .../themes/oscar/js/searx_src/leaflet_map.js | 2 +- .../static/themes/simple/js/searx.head.min.js | Bin 775 -> 742 bytes searx/static/themes/simple/js/searx.js | 2 +- searx/static/themes/simple/js/searx.min.js | Bin 23952 -> 23911 bytes .../static/themes/simple/js/searx.min.js.map | Bin 30399 -> 30418 bytes .../simple/js/searx_src/searx_mapresult.js | 2 +- searx/templates/oscar/base.html | 2 +- searx/templates/simple/base.html | 1 + searx/webapp.py | 8 ++++++++ 11 files changed, 14 insertions(+), 5 deletions(-) diff --git a/searx/static/themes/oscar/js/searx.js b/searx/static/themes/oscar/js/searx.js index c93f597fe..2cd9ca26a 100644 --- a/searx/static/themes/oscar/js/searx.js +++ b/searx/static/themes/oscar/js/searx.js @@ -291,7 +291,7 @@ $(document).ready(function(){ } }) .fail(function() { - $(result_table_loadicon).html($(result_table_loadicon).html() + "

could not load data!

"); + $(result_table_loadicon).html($(result_table_loadicon).html() + "

"+could_not_load+"

"); }); } } diff --git a/searx/static/themes/oscar/js/searx.min.js b/searx/static/themes/oscar/js/searx.min.js index 08aba2b4be8b580419795dfec39f60f0dd9f736e..52a58800bac2cb584261db6484ed3175d9ab381b 100644 GIT binary patch delta 42 ycmaE;abIJCB$J`(M(HDb;_BMT`K382@p<_r@j3a4DcVXl`UQ4Mn}6_SvH}1>Fbcould not load data!

"); + $(result_table_loadicon).html($(result_table_loadicon).html() + "

"+could_not_load+"

"); }); } } diff --git a/searx/static/themes/simple/js/searx.head.min.js b/searx/static/themes/simple/js/searx.head.min.js index 00c711c793e6b8f82330c89bbd61c39c7610ad77..8cd0df3d6c23c6b44c605586daecf189227202b6 100644 GIT binary patch delta 24 fcmZo?d&W9Jir3Io*T78I$iT=zp+;e&$9^UNQ3(c+ delta 57 zcmaFH+RipXO3%Pd*T6#8$iUE2p++I2q@iu-~#|^ CX%D#o delta 87 zcmaF9i*dqk#tBk-24=bj7P>|ThL#F73K=CO1;tkS`stY^8Kp^j$@#hZiN(p8nYsD- r`o*bH~EPvCFhssq$uR&mnh`qC#EQ*B$gy9Ds6u5*T4q=Bx4@Z diff --git a/searx/static/themes/simple/js/searx.min.js.map b/searx/static/themes/simple/js/searx.min.js.map index d7a1eeac82a871923e974a6c7a544b8df82d325b..81e7ddffa3758da64d411856870d18b660b90655 100644 GIT binary patch delta 1334 zcmZuxO>ZMb5S4E+2sW2RyG!_x5E9^C{E^8zDkG^UN~^(%mslsk>eh?AgXG@Zi2Xs+*Q@D>b-jHr92Ub~a>mPk17hnA4f1i7$>M%NfR6Dr1ID=d+)XyfvTl0ZfNPy2I zlSs55+<)mRwvdVbHrUQD+e9srJNlR4ZvM=r(*no%J9wB6_%xEK{v`Bw7hTE)QVEB3 zQJ@Y&i((GYw?1pLa7(V6OH$}nMM#Q+@N<2JGF`|almN8l_ID}zY783bN%<~+)CRMfOqHD{kv zL+gPQK5C=ioPKQ>b(-A8CTc)f2Wg*cDu>j!@o%~XsoIfPu&eB<{&V_K?ty+Ue*eR; zi=(QQCYlI6hH4R9HPfF>)R^gYyp@aeH*o>C^i%xC#;8NhT8X}l@7<0c(ZL~+ z!8z@-BMW+K_QC7t1GEdYB2x?jhHQ{=W{|n=&+e?lCJ(#XqcVoHsrgg|*&*!;mrYED zMvc?~r5|S+*;m=1#*I?_ zy@5l6M78$VWX|{oM2Rn>LJru8x$@{*BT!6&;EytAw5kKjSR;#h8>F>Wrl$ifCKk)- z0AqPt4LN41pUfYAQKqhpiESPFwo(G{1=v2a0>CiONK_J=I^Og?|7?TaJSO delta 1353 zcmZ`(O=}xh6h%7;QsQFLriDTwWYOpa*<(#?k=1=~MiW^Uqlq+@#!!kh5t6L=(8x1` zYzqDbDJAbGWYJY=!F1hKvrji&WR*>JA)7!ph4$VzNr-8>5%ccnx#ym%KVO!9e_8tV z#m2>(jUNUTw#A{d7WqB-oUtI3#U8~}UJFe~|eczg4$E#s?w9Ms(9 zvz~j>zJwOfPcL z10(8|3#<&S*rkCyqSFEOIqMSzqiO%W!zNsTS(I1}ixO8b!%h@RFOr`vf2(V4Qi6-6 z#8^#|jubSltCsc7-Gf}{90T@*rOSVocT077H~FR=3=xo6a|H`1(+P)cfuy635WsFh zz0y%LHnWt4FIZuf_N2+a|KXt{o}u?8(~d zR((BYJ&cMCHUXF@866k&B_8F(oD`83*wl9IKt5buKVJ;UZKXrz;^;*R@*@ri@lip~ zJ8#%hjj>Yun8#hDSAgQwT94Qq=bY0a;PSB54xcLW?7&eI5;fz6qwohVomE#urq97_ z7I0>lN}Q@>74qczzI2Xepa;H@<}X{nJlOEiberq$ {% block meta %}{% endblock %} - + {% block title %}{% endblock %}{{ instance_name }} {% if preferences.get_value('oscar-style') -%} diff --git a/searx/templates/simple/base.html b/searx/templates/simple/base.html index 650ef771c..5cb1e1757 100644 --- a/searx/templates/simple/base.html +++ b/searx/templates/simple/base.html @@ -12,6 +12,7 @@ {% block title %}{% endblock %}{{ instance_name }} {% block meta %}{% endblock %} + {% if rtl %} {% else %} diff --git a/searx/webapp.py b/searx/webapp.py index 2ba8ccfb8..68be25584 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -1021,6 +1021,14 @@ def config(): }) +@app.route('/translations.js') +def js_translations(): + return render( + 'translations.js.tpl', + override_theme='__common__', + ), {'Content-Type': 'text/javascript; charset=UTF-8'} + + @app.errorhandler(404) def page_not_found(e): return render('404.html'), 404 From 32f7877235f87f1dcfabc271e5c92539bbcdac9a Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Mon, 15 Jun 2020 19:15:24 +0200 Subject: [PATCH 2/3] [fix] resolve flickr_noapi encoding issues --- searx/engines/flickr_noapi.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/searx/engines/flickr_noapi.py b/searx/engines/flickr_noapi.py index c8ee34f7a..1cbb3e0a9 100644 --- a/searx/engines/flickr_noapi.py +++ b/searx/engines/flickr_noapi.py @@ -117,14 +117,10 @@ def response(resp): 'img_format': img_format, 'template': 'images.html' } - try: - result['author'] = author - result['title'] = title - result['content'] = content - except: - result['author'] = '' - result['title'] = '' - result['content'] = '' + result['author'] = author.encode('utf-8', 'ignore').decode('utf-8') + result['source'] = source.encode('utf-8', 'ignore').decode('utf-8') + result['title'] = title.encode('utf-8', 'ignore').decode('utf-8') + result['content'] = content.encode('utf-8', 'ignore').decode('utf-8') results.append(result) return results From 0dc5bdb6ef602d00456eb1db96d45e2f42b2b7a4 Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Mon, 15 Jun 2020 20:11:12 +0200 Subject: [PATCH 3/3] [fix] add missing template file --- searx/templates/__common__/translations.js.tpl | 1 + 1 file changed, 1 insertion(+) create mode 100644 searx/templates/__common__/translations.js.tpl diff --git a/searx/templates/__common__/translations.js.tpl b/searx/templates/__common__/translations.js.tpl new file mode 100644 index 000000000..8453aba69 --- /dev/null +++ b/searx/templates/__common__/translations.js.tpl @@ -0,0 +1 @@ +var could_not_load = '{{ _('could not load data') }}!';