diff options
-rw-r--r-- | searx/engines/bing_images.py | 2 | ||||
-rw-r--r-- | searx/engines/currency_convert.py | 6 | ||||
-rw-r--r-- | searx/engines/www1x.py | 4 | ||||
-rw-r--r-- | searx/templates/courgette/preferences.html | 2 | ||||
-rw-r--r-- | searx/templates/default/preferences.html | 2 | ||||
-rw-r--r-- | searx/templates/oscar/messages/no_cookies.html | 5 | ||||
-rw-r--r-- | searx/templates/oscar/preferences.html | 30 | ||||
-rw-r--r-- | searx/tests/engines/test_bing_images.py | 2 | ||||
-rw-r--r-- | searx/tests/engines/test_www1x.py | 4 | ||||
-rw-r--r-- | searx/webapp.py | 8 |
10 files changed, 40 insertions, 25 deletions
diff --git a/searx/engines/bing_images.py b/searx/engines/bing_images.py index b06a57edc..839b8e5be 100644 --- a/searx/engines/bing_images.py +++ b/searx/engines/bing_images.py @@ -28,7 +28,7 @@ safesearch = True # search-url base_url = 'https://www.bing.com/' search_string = 'images/search?{query}&count=10&first={offset}' -thumb_url = "http://ts1.mm.bing.net/th?id={ihk}" # no https, bad certificate +thumb_url = "https://www.bing.com/th?id={ihk}" # safesearch definitions safesearch_types = {2: 'STRICT', diff --git a/searx/engines/currency_convert.py b/searx/engines/currency_convert.py index 1ba4575c5..26830a167 100644 --- a/searx/engines/currency_convert.py +++ b/searx/engines/currency_convert.py @@ -9,7 +9,7 @@ categories = [] url = 'https://download.finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s={query}=X' weight = 100 -parser_re = re.compile(r'^\W*(\d+(?:\.\d+)?)\W*([^.0-9].+)\W*in?\W*([^\.]+)\W*$', re.I) # noqa +parser_re = re.compile(u'^\W*(\d+(?:\.\d+)?)\W*([^.0-9].+)\W+in?\W+([^\.]+)\W*$', re.I) # noqa db = 1 @@ -17,7 +17,7 @@ db = 1 def normalize_name(name): name = name.lower().replace('-', ' ') name = re.sub(' +', ' ', name) - return unicodedata.normalize('NFKD', u"" + name).lower() + return unicodedata.normalize('NFKD', name).lower() def name_to_iso4217(name): @@ -35,7 +35,7 @@ def iso4217_to_name(iso4217, language): def request(query, params): - m = parser_re.match(query) + m = parser_re.match(unicode(query, 'utf8')) if not m: # wrong query return params diff --git a/searx/engines/www1x.py b/searx/engines/www1x.py index 12868ad22..ddb79bfea 100644 --- a/searx/engines/www1x.py +++ b/searx/engines/www1x.py @@ -20,8 +20,8 @@ import re categories = ['images'] paging = False -# search-url, no HTTPS (there is a valid certificate for https://api2.1x.com/ ) -base_url = 'http://1x.com' +# search-url +base_url = 'https://1x.com' search_url = base_url+'/backend/search.php?{query}' diff --git a/searx/templates/courgette/preferences.html b/searx/templates/courgette/preferences.html index 2afb74d11..f89915d8d 100644 --- a/searx/templates/courgette/preferences.html +++ b/searx/templates/courgette/preferences.html @@ -101,7 +101,7 @@ <th>{{ _('Category') }}</th> <th>{{ _('Allow') }} / {{ _('Block') }}</th> </tr> - {% for categ in categories %} + {% for categ in all_categories %} {% for search_engine in engines_by_category[categ] %} {% if not search_engine.private %} diff --git a/searx/templates/default/preferences.html b/searx/templates/default/preferences.html index 0afe9f7d0..90006c029 100644 --- a/searx/templates/default/preferences.html +++ b/searx/templates/default/preferences.html @@ -89,7 +89,7 @@ <th>{{ _('Category') }}</th> <th>{{ _('Allow') }} / {{ _('Block') }}</th> </tr> - {% for categ in categories %} + {% for categ in all_categories %} {% for search_engine in engines_by_category[categ] %} {% if not search_engine.private %} diff --git a/searx/templates/oscar/messages/no_cookies.html b/searx/templates/oscar/messages/no_cookies.html new file mode 100644 index 000000000..9bebc8ad1 --- /dev/null +++ b/searx/templates/oscar/messages/no_cookies.html @@ -0,0 +1,5 @@ +{% from 'oscar/macros.html' import icon %} +<div class="alert alert-info fade in" role="alert"> + <strong class="lead">{{ icon('info-sign') }} {{ _('Information!') }}</strong> + {{ _('currently, there are no cookies defined.') }} +</div> diff --git a/searx/templates/oscar/preferences.html b/searx/templates/oscar/preferences.html index ee4e6ab57..ea36a14b9 100644 --- a/searx/templates/oscar/preferences.html +++ b/searx/templates/oscar/preferences.html @@ -117,7 +117,7 @@ <!-- Nav tabs --> <ul class="nav nav-tabs nav-justified hide_if_nojs" role="tablist" style="margin-bottom:20px;"> - {% for categ in categories %} + {% for categ in all_categories %} <li{% if loop.first %} class="active"{% endif %}><a href="#tab_engine_{{ categ|replace(' ', '_') }}" role="tab" data-toggle="tab">{{ _(categ) }}</a></li> {% endfor %} </ul> @@ -128,7 +128,7 @@ <!-- Tab panes --> <div class="tab-content"> - {% for categ in categories %} + {% for categ in all_categories %} <noscript><label>{{ _(categ) }}</label> </noscript> <div class="tab-pane{% if loop.first %} active{% endif %} active_if_nojs" id="tab_engine_{{ categ|replace(' ', '_') }}"> @@ -213,21 +213,23 @@ {{ _('This is the list of cookies and their values searx is storing on your computer.') }}<br /> {{ _('With that list, you can assess searx transparency.') }}<br /> </p> - <div class="container-fluid"> - <fieldset> - <div class="row"> - <div class="col-xs-6 col-sm-4 col-md-4 text-muted"><label>{{ _('Cookie name') }}</label></div> - <div class="col-xs-6 col-sm-4 col-md-4 text-muted"><label>{{ _('Value') }}</label></div> - </div> + {% if cookies %} + <table class="table table-striped"> + <tr> + <th class="text-muted" style="padding-right:40px;">{{ _('Cookie name') }}</th> + <th class="text-muted">{{ _('Value') }}</th> + </tr> {% for cookie in cookies %} - <div class="row"> - <div class="col-xs-6 col-sm-4 col-md-4 text-muted">{{ cookie }}</div> - <div class="col-xs-6 col-sm-4 col-md-4 text-muted">{{ cookies[cookie] }}</div> - </div> + <tr> + <td class="text-muted" style="padding-right:40px;">{{ cookie }}</td> + <td class="text-muted">{{ cookies[cookie] }}</td> + </tr> {% endfor %} - </fieldset> - </div> + </table> + {% else %} + {% include 'oscar/messages/no_cookies.html' %} + {% endif %} </div> </div> <p class="text-muted" style="margin:20px 0;">{{ _('These settings are stored in your cookies, this allows us not to store this data about you.') }} diff --git a/searx/tests/engines/test_bing_images.py b/searx/tests/engines/test_bing_images.py index a1d96b06e..f869da79d 100644 --- a/searx/tests/engines/test_bing_images.py +++ b/searx/tests/engines/test_bing_images.py @@ -59,7 +59,7 @@ oh:"238",tft:"0",oi:"http://www.image.url/Images/Test%2 self.assertEqual(results[0]['title'], 'Test Query') self.assertEqual(results[0]['url'], 'http://www.page.url/') self.assertEqual(results[0]['content'], '') - self.assertEqual(results[0]['thumbnail_src'], 'http://ts1.mm.bing.net/th?id=HN.608003696942779811') + self.assertEqual(results[0]['thumbnail_src'], 'https://www.bing.com/th?id=HN.608003696942779811') self.assertEqual(results[0]['img_src'], 'http://test.url/Test%20Query.jpg') html = """ diff --git a/searx/tests/engines/test_www1x.py b/searx/tests/engines/test_www1x.py index ab4f282c1..9df8de6bf 100644 --- a/searx/tests/engines/test_www1x.py +++ b/searx/tests/engines/test_www1x.py @@ -51,7 +51,7 @@ class TestWww1xEngine(SearxTestCase): results = www1x.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 1) - self.assertEqual(results[0]['url'], 'http://1x.com/photo/123456') - self.assertEqual(results[0]['thumbnail_src'], 'http://1x.com/images/user/testimage-123456.jpg') + self.assertEqual(results[0]['url'], 'https://1x.com/photo/123456') + self.assertEqual(results[0]['thumbnail_src'], 'https://1x.com/images/user/testimage-123456.jpg') self.assertEqual(results[0]['content'], '') self.assertEqual(results[0]['template'], 'images.html') diff --git a/searx/webapp.py b/searx/webapp.py index 8587d546a..dbcbb4c0d 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -279,6 +279,12 @@ def render(template_name, override_theme=None, **kwargs): if x != 'general' and x in nonblocked_categories) + if 'all_categories' not in kwargs: + kwargs['all_categories'] = ['general'] + kwargs['all_categories'].extend(x for x in + sorted(categories.keys()) + if x != 'general') + if 'selected_categories' not in kwargs: kwargs['selected_categories'] = [] for arg in request.args: @@ -286,11 +292,13 @@ def render(template_name, override_theme=None, **kwargs): c = arg.split('_', 1)[1] if c in categories: kwargs['selected_categories'].append(c) + if not kwargs['selected_categories']: cookie_categories = request.cookies.get('categories', '').split(',') for ccateg in cookie_categories: if ccateg in categories: kwargs['selected_categories'].append(ccateg) + if not kwargs['selected_categories']: kwargs['selected_categories'] = ['general'] |