From 5ec9eb8030b0522c4dd35db41466169bc46f11d8 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 29 Dec 2021 14:49:06 +0100 Subject: [PATCH 1/2] [mod] switch default theme from oscar to simple Signed-off-by: Markus Heiser --- searx/settings.yml | 2 +- searx/settings_defaults.py | 2 +- searxng_extra/standalone_searx.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/searx/settings.yml b/searx/settings.yml index cec9889b2..69dc69572 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -76,7 +76,7 @@ ui: # it decreases the privacy, since the browser can records the page titles. query_in_title: false # ui theme - default_theme: oscar + default_theme: simple # Default interface locale - leave blank to detect from browser information or # use codes from the 'locales' config section default_locale: "" diff --git a/searx/settings_defaults.py b/searx/settings_defaults.py index 15b4524c6..6808b0957 100644 --- a/searx/settings_defaults.py +++ b/searx/settings_defaults.py @@ -177,7 +177,7 @@ SCHEMA = { 'ui': { 'static_path': SettingsDirectoryValue(str, os.path.join(searx_dir, 'static')), 'templates_path': SettingsDirectoryValue(str, os.path.join(searx_dir, 'templates')), - 'default_theme': SettingsValue(str, 'oscar'), + 'default_theme': SettingsValue(str, 'simple'), 'default_locale': SettingsValue(str, ''), 'theme_args': { 'oscar_style': SettingsValue(OSCAR_STYLE, 'logicodev'), diff --git a/searxng_extra/standalone_searx.py b/searxng_extra/standalone_searx.py index baf8db0b4..0a1e18846 100755 --- a/searxng_extra/standalone_searx.py +++ b/searxng_extra/standalone_searx.py @@ -105,7 +105,7 @@ def get_search_query( "language": args.lang, "time_range": args.timerange, } - preferences = searx.preferences.Preferences(['oscar'], engine_categories, searx.engines.engines, []) + preferences = searx.preferences.Preferences(['simple'], engine_categories, searx.engines.engines, []) preferences.key_value_settings['safesearch'].parse(args.safesearch) search_query = searx.webadapter.get_search_query_from_webapp(preferences, form)[0] From fdeece0aae9ef64c8e73773914b15fd23e2e5fce Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 29 Dec 2021 16:31:05 +0100 Subject: [PATCH 2/2] [fix] changeover of the unit tests to the simple theme Signed-off-by: Markus Heiser --- tests/unit/settings/user_settings.yml | 4 ++-- tests/unit/test_preferences.py | 2 +- tests/unit/test_webadapter.py | 6 +++--- tests/unit/test_webapp.py | 23 +++++++++++------------ 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/tests/unit/settings/user_settings.yml b/tests/unit/settings/user_settings.yml index cd5a2cded..fba8e6133 100644 --- a/tests/unit/settings/user_settings.yml +++ b/tests/unit/settings/user_settings.yml @@ -27,10 +27,10 @@ server: ui: static_path: "" templates_path: "" - default_theme: oscar + default_theme: simple default_locale: "" theme_args: - oscar_style: logicodev + simple_style: auto engines: - name: wikidata diff --git a/tests/unit/test_preferences.py b/tests/unit/test_preferences.py index a69c45178..40cfd006b 100644 --- a/tests/unit/test_preferences.py +++ b/tests/unit/test_preferences.py @@ -119,7 +119,7 @@ class TestPreferences(SearxTestCase): def test_encode(self): from searx.preferences import Preferences - pref = Preferences(['oscar'], ['general'], {}, []) + pref = Preferences(['oscar', 'simple'], ['general'], {}, []) url_params = ( 'eJx1VMmO2zAM_Zr6YrTocujJh6JF0QEKzKAz7VVgJNohLIseUU7ivy-VcWy5yyGOTVGP73GLKJNPYjiYgGeT4NB8BS9YOSY' 'TUdifMDYM-vmGY1d5CN0EHTYOK88W_PXNkcDBozOjnzoK0vyi4bWnHs2RU4-zvHr_-RF9a-5Cy3GARByy7X7EkKMoBeMp9CuPQ-SzYMx' diff --git a/tests/unit/test_webadapter.py b/tests/unit/test_webadapter.py index 975d846cc..2aa5cba8b 100644 --- a/tests/unit/test_webadapter.py +++ b/tests/unit/test_webadapter.py @@ -30,14 +30,14 @@ class ValidateQueryCase(SearxTestCase): searx.search.initialize(TEST_ENGINES) def test_query_private_engine_without_token(self): - preferences = Preferences(['oscar'], ['general'], engines, []) + preferences = Preferences(['simple'], ['general'], engines, []) valid, unknown, invalid_token = validate_engineref_list(SEARCHQUERY, preferences) self.assertEqual(len(valid), 0) self.assertEqual(len(unknown), 0) self.assertEqual(len(invalid_token), 1) def test_query_private_engine_with_incorrect_token(self): - preferences_with_tokens = Preferences(['oscar'], ['general'], engines, []) + preferences_with_tokens = Preferences(['simple'], ['general'], engines, []) preferences_with_tokens.parse_dict({'tokens': 'bad-token'}) valid, unknown, invalid_token = validate_engineref_list(SEARCHQUERY, preferences_with_tokens) self.assertEqual(len(valid), 0) @@ -45,7 +45,7 @@ class ValidateQueryCase(SearxTestCase): self.assertEqual(len(invalid_token), 1) def test_query_private_engine_with_correct_token(self): - preferences_with_tokens = Preferences(['oscar'], ['general'], engines, []) + preferences_with_tokens = Preferences(['simple'], ['general'], engines, []) preferences_with_tokens.parse_dict({'tokens': 'my-token'}) valid, unknown, invalid_token = validate_engineref_list(SEARCHQUERY, preferences_with_tokens) self.assertEqual(len(valid), 1) diff --git a/tests/unit/test_webapp.py b/tests/unit/test_webapp.py index 70ebd447b..a50bd5c78 100644 --- a/tests/unit/test_webapp.py +++ b/tests/unit/test_webapp.py @@ -73,7 +73,7 @@ class ViewsTestCase(SearxTestCase): def get_current_theme_name_mock(override=None): if override: return override - return 'oscar' + return 'simple' self.setattr4test(webapp, 'get_current_theme_name', get_current_theme_name_mock) @@ -83,9 +83,7 @@ class ViewsTestCase(SearxTestCase): result = self.app.post('/') self.assertEqual(result.status_code, 200) self.assertIn( - b'', + b'

SearXNG

', result.data, ) @@ -102,7 +100,7 @@ class ViewsTestCase(SearxTestCase): def test_search_empty_html(self): result = self.app.post('/search', data={'q': ''}) self.assertEqual(result.status_code, 200) - self.assertIn(b'SearXNG', result.data) + self.assertIn(b'

SearXNG

', result.data) def test_search_empty_json(self): result = self.app.post('/search', data={'q': '', 'format': 'json'}) @@ -120,13 +118,12 @@ class ViewsTestCase(SearxTestCase): result = self.app.post('/search', data={'q': 'test'}) self.assertIn( - b'

youtubeSecond Test

', # noqa + b'http://second.test.xyz', result.data, ) self.assertIn( - b'

second test content

', result.data # noqa + b'

\n second test ', + result.data, ) def test_index_json(self): @@ -186,9 +183,11 @@ class ViewsTestCase(SearxTestCase): def test_preferences(self): result = self.app.get('/preferences') self.assertEqual(result.status_code, 200) - self.assertIn(b'

', result.data) - self.assertIn(b'', result.data) - self.assertIn(b'', result.data) + self.assertIn(b'', result.data + ) + self.assertIn(b'Interface language', result.data) def test_browser_locale(self): result = self.app.get('/preferences', headers={'Accept-Language': 'zh-tw;q=0.8'})