From 5b04700387c966c57c91a43f219a147cbaa11969 Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Mon, 28 Mar 2022 12:38:19 +0530 Subject: [PATCH 1/5] enable currency converter --- searx/engines/currency_convert.py | 4 ++-- searx/settings.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/searx/engines/currency_convert.py b/searx/engines/currency_convert.py index d4c3b5f81..3babea1da 100644 --- a/searx/engines/currency_convert.py +++ b/searx/engines/currency_convert.py @@ -39,9 +39,9 @@ def response(resp): answer = '{0} {1} = {2} {3}, 1 {1} ({5}) = {4} {3} ({6})'.format( resp.search_params['amount'], resp.search_params['from'], - resp.search_params['amount'] * conversion_rate, + round(resp.search_params['amount'] * conversion_rate, 2), resp.search_params['to'], - conversion_rate, + round(conversion_rate, 2), resp.search_params['from_name'], resp.search_params['to_name'], ) diff --git a/searx/settings.yml b/searx/settings.yml index db3bedd4e..5899652e6 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -341,7 +341,7 @@ engines: engine : currency_convert categories : general shortcut : cc - disabled: True + disabled: False - name : deezer engine : deezer -- GitLab From 4f25da619014236ecae0d86a60da6055e3f107f2 Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Thu, 7 Apr 2022 13:59:48 +0530 Subject: [PATCH 2/5] new result page for displaying currency --- searx/engines/currency_convert.py | 18 +++++++----------- searx/static/themes/etheme/css/etheme.css | 10 +++++++++- searx/static/themes/etheme/css/etheme.min.css | Bin 23792 -> 23883 bytes .../themes/etheme/less/etheme/defs.less | 1 + .../themes/etheme/less/etheme/results.less | 8 ++++++++ .../etheme/result_templates/currency.html | 7 +++++++ 6 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 searx/templates/etheme/result_templates/currency.html diff --git a/searx/engines/currency_convert.py b/searx/engines/currency_convert.py index 3babea1da..b33a07331 100644 --- a/searx/engines/currency_convert.py +++ b/searx/engines/currency_convert.py @@ -36,19 +36,15 @@ def response(resp): conversion_rate = float(json.loads(json_resp)['conversion']['converted-amount']) except: return results - answer = '{0} {1} = {2} {3}, 1 {1} ({5}) = {4} {3} ({6})'.format( - resp.search_params['amount'], - resp.search_params['from'], - round(resp.search_params['amount'] * conversion_rate, 2), - resp.search_params['to'], - round(conversion_rate, 2), - resp.search_params['from_name'], - resp.search_params['to_name'], - ) url = 'https://duckduckgo.com/js/spice/currency/1/{0}/{1}'.format( resp.search_params['from'].upper(), resp.search_params['to']) - results.append({'answer': answer, 'url': url}) - + results.append({'template': 'currency.html', + 'amount': resp.search_params['amount'], + 'from': resp.search_params['from'], + 'to': resp.search_params['to'], + 'value': round(resp.search_params['amount'] * conversion_rate, 2), + 'conversion_rate': round(conversion_rate, 2), + 'url': url}) return results diff --git a/searx/static/themes/etheme/css/etheme.css b/searx/static/themes/etheme/css/etheme.css index 378f41ab1..6aa7d218f 100644 --- a/searx/static/themes/etheme/css/etheme.css +++ b/searx/static/themes/etheme/css/etheme.css @@ -35,6 +35,8 @@ --color-main-text: #60686f; --color-primary: #1f6ed7; --color-delete: #e06572; + --color-currency-value: #777777; + } .container-padding, nav { @@ -731,7 +733,7 @@ input:checked + .slider:before { justify-content: space-between; font-size: 14px; padding-bottom: 16px; - padding-top: 16px; + padding-top: 24px; padding-left: 24px; padding-right: 24px; } @@ -996,6 +998,12 @@ input:checked + .slider:before { .result.result-torrent { margin-bottom: 32px; } +.result .currency { + font-family: 'Noto Sans'; + font-style: normal; + font-weight: 700; + font-size: 30px; +} .result.result-images { display: inline; } diff --git a/searx/static/themes/etheme/css/etheme.min.css b/searx/static/themes/etheme/css/etheme.min.css index be2a65193fea6f9b43266721ee91ba9d50e053e7..8fe6b0862208692ac61f4e9b50c7d2606e8fa2e0 100644 GIT binary patch delta 111 zcmeyclkxN}#to~?nT$*}uQ6XL7NVe+Tv}9=nwMNzotB?hqMMeOo0(H-rS6wslCKb) zm{+WB4Hhphsmw{W%F8dxP0WFal&5B + + {% if result.value %}{{ result.value|safe }} {{ result.to|safe}} {% endif %} + + + -- GitLab From 32c438b58e7a8cba236f5b6e691132ffa69e817b Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Thu, 7 Apr 2022 22:00:41 +0530 Subject: [PATCH 3/5] show source url as xe.com --- searx/engines/currency_convert.py | 5 +++++ searx/static/themes/etheme/css/etheme.css | 16 +++++++++++++--- searx/static/themes/etheme/css/etheme.min.css | Bin 23883 -> 24091 bytes .../themes/etheme/less/etheme/results.less | 16 +++++++++++++++- .../etheme/result_templates/currency.html | 13 +++++++++++-- 5 files changed, 44 insertions(+), 6 deletions(-) diff --git a/searx/engines/currency_convert.py b/searx/engines/currency_convert.py index b33a07331..7279097ad 100644 --- a/searx/engines/currency_convert.py +++ b/searx/engines/currency_convert.py @@ -40,11 +40,16 @@ def response(resp): url = 'https://duckduckgo.com/js/spice/currency/1/{0}/{1}'.format( resp.search_params['from'].upper(), resp.search_params['to']) + source_url = 'https://www.xe.com/currencyconverter/convert/?Amount=1&From={0}&To={1}'.format( + resp.search_params['from'], resp.search_params['to'] + ) + results.append({'template': 'currency.html', 'amount': resp.search_params['amount'], 'from': resp.search_params['from'], 'to': resp.search_params['to'], 'value': round(resp.search_params['amount'] * conversion_rate, 2), 'conversion_rate': round(conversion_rate, 2), + 'source_url' : source_url, 'url': url}) return results diff --git a/searx/static/themes/etheme/css/etheme.css b/searx/static/themes/etheme/css/etheme.css index 6aa7d218f..163527f5b 100644 --- a/searx/static/themes/etheme/css/etheme.css +++ b/searx/static/themes/etheme/css/etheme.css @@ -35,8 +35,6 @@ --color-main-text: #60686f; --color-primary: #1f6ed7; --color-delete: #e06572; - --color-currency-value: #777777; - } .container-padding, nav { @@ -998,12 +996,24 @@ input:checked + .slider:before { .result.result-torrent { margin-bottom: 32px; } -.result .currency { +.result .currency-value { font-family: 'Noto Sans'; + color: var(--color-currency-value); font-style: normal; font-weight: 700; font-size: 30px; } +.result .currency-info { + font-family: 'Noto Sans'; + color: var(--color-currency-value); + font-style: normal; + font-weight: 400; + line-height: 3; + font-size: 18px; +} +.source { + margin-left: 15%; +} .result.result-images { display: inline; } diff --git a/searx/static/themes/etheme/css/etheme.min.css b/searx/static/themes/etheme/css/etheme.min.css index 8fe6b0862208692ac61f4e9b50c7d2606e8fa2e0..ee719951629f0f211b8701aeb4e616c6e4bd10f8 100644 GIT binary patch delta 215 zcmX@Ti*fcI#tqSaY`SHMIi;zSqx~cmlk;=(i>%5Li!^j~!ED{+(xRf&yyQxVBF)Lg zewO?SdT`OqytI6f&U%76t<&=JN_2}$Dsxh;^74yv6LTOU<*AwJ86{RG1_stSnR%(Y z84$iPRDEVus+FNdK}D@zaeir0a%y#MVo`c#o^DQRT8WjRscNlWQEG8%&g3Hj5}ObE Hb?^ZIzsXQQ delta 30 mcmbQehw=0-#tqSalN0?UC(HTEP2S}vHF;{F_~yy}9ee=Ag$yA8 diff --git a/searx/static/themes/etheme/less/etheme/results.less b/searx/static/themes/etheme/less/etheme/results.less index bebdb577c..34a8ef7ac 100644 --- a/searx/static/themes/etheme/less/etheme/results.less +++ b/searx/static/themes/etheme/less/etheme/results.less @@ -137,13 +137,27 @@ margin-bottom: @spacing_xx-large; } -.result .currency { +.result .currency-value { font-family: 'Noto Sans'; color: var(--color-currency-value); font-style: normal; font-weight: 700; font-size: @fontsize_xxx-large; } + +.result .currency-info { + font-family: 'Noto Sans'; + color: var(--color-currency-value); + font-style: normal; + font-weight: 400; + line-height: 3; + font-size: @fontsize_large; +} + +.source { + margin-left: 15%; +} + .result.result-images { display: inline; diff --git a/searx/templates/etheme/result_templates/currency.html b/searx/templates/etheme/result_templates/currency.html index ad2b84eb7..e5607faa2 100644 --- a/searx/templates/etheme/result_templates/currency.html +++ b/searx/templates/etheme/result_templates/currency.html @@ -1,7 +1,16 @@ - -
+
{% if result.value %}{{ result.value|safe }} {{ result.to|safe}} {% endif %}
+
+ {% if result.value %} + + 1 {{ result.from|safe }} = {{ result.conversion_rate|safe }} {{ result.to|safe}} + + + {{ _('Source') }} : XE Currency + + {% endif %} +
-- GitLab From e0e4c0232fd8dbe575b67d2ad61862c5fc8e0ec1 Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Thu, 7 Apr 2022 22:40:35 +0530 Subject: [PATCH 4/5] make css changes to match design --- searx/static/themes/etheme/css/etheme.css | 7 +++++-- searx/static/themes/etheme/css/etheme.min.css | Bin 24091 -> 24131 bytes .../themes/etheme/less/etheme/results.less | 8 +++++--- .../etheme/result_templates/currency.html | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/searx/static/themes/etheme/css/etheme.css b/searx/static/themes/etheme/css/etheme.css index 163527f5b..beffd0098 100644 --- a/searx/static/themes/etheme/css/etheme.css +++ b/searx/static/themes/etheme/css/etheme.css @@ -1002,17 +1002,20 @@ input:checked + .slider:before { font-style: normal; font-weight: 700; font-size: 30px; + padding-bottom: 15px; } .result .currency-info { font-family: 'Noto Sans'; color: var(--color-currency-value); font-style: normal; font-weight: 400; - line-height: 3; font-size: 18px; } +.conversion { + margin-right: 15%; +} .source { - margin-left: 15%; + display: inline-block; } .result.result-images { display: inline; diff --git a/searx/static/themes/etheme/css/etheme.min.css b/searx/static/themes/etheme/css/etheme.min.css index ee719951629f0f211b8701aeb4e616c6e4bd10f8..82def583a288090ae8f74ec40fa4aa9bacd855e1 100644 GIT binary patch delta 97 zcmbQehw<5 AQvd(} delta 79 zcmX@ShjI2E#tmouCO_~iG0DlyOV!Ot%}mcIu`;$!%g-y(EzYb;wKB9QsHoK|&Mz%W jPOZ*OEK1MJ)6GduE3q;(Rh@j$Uu^Q}K+es({X6&oBLW}7 diff --git a/searx/static/themes/etheme/less/etheme/results.less b/searx/static/themes/etheme/less/etheme/results.less index 34a8ef7ac..6b275167b 100644 --- a/searx/static/themes/etheme/less/etheme/results.less +++ b/searx/static/themes/etheme/less/etheme/results.less @@ -143,6 +143,7 @@ font-style: normal; font-weight: 700; font-size: @fontsize_xxx-large; + padding-bottom: 15px; } .result .currency-info { @@ -150,12 +151,13 @@ color: var(--color-currency-value); font-style: normal; font-weight: 400; - line-height: 3; font-size: @fontsize_large; } - +.conversion { + margin-right: 15%; +} .source { - margin-left: 15%; + display: inline-block; } .result.result-images { diff --git a/searx/templates/etheme/result_templates/currency.html b/searx/templates/etheme/result_templates/currency.html index e5607faa2..85ae173d0 100644 --- a/searx/templates/etheme/result_templates/currency.html +++ b/searx/templates/etheme/result_templates/currency.html @@ -6,7 +6,7 @@
{% if result.value %} - + 1 {{ result.from|safe }} = {{ result.conversion_rate|safe }} {{ result.to|safe}} -- GitLab From b132de79e0abc08e7a90e12ae5a26b120a22b655 Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Thu, 7 Apr 2022 22:43:21 +0530 Subject: [PATCH 5/5] fix pep8 --- searx/engines/currency_convert.py | 2 +- searx/templates/etheme/result_templates/currency.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/searx/engines/currency_convert.py b/searx/engines/currency_convert.py index 7279097ad..75ec390b5 100644 --- a/searx/engines/currency_convert.py +++ b/searx/engines/currency_convert.py @@ -50,6 +50,6 @@ def response(resp): 'to': resp.search_params['to'], 'value': round(resp.search_params['amount'] * conversion_rate, 2), 'conversion_rate': round(conversion_rate, 2), - 'source_url' : source_url, + 'source_url': source_url, 'url': url}) return results diff --git a/searx/templates/etheme/result_templates/currency.html b/searx/templates/etheme/result_templates/currency.html index 85ae173d0..5897eec01 100644 --- a/searx/templates/etheme/result_templates/currency.html +++ b/searx/templates/etheme/result_templates/currency.html @@ -10,7 +10,7 @@ 1 {{ result.from|safe }} = {{ result.conversion_rate|safe }} {{ result.to|safe}} - {{ _('Source') }} : XE Currency + {{ _('Source') }}: XE Currency {% endif %}
-- GitLab