From df06dddc044161c6d5caacab1b2a5b9faa109f01 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Thu, 30 Sep 2021 17:55:22 +0200 Subject: [PATCH] SearXNG: oscar theme --- searx/static/themes/oscar/gruntfile.js | 12 ++++++---- searx/static/themes/oscar/src/js/01_init.js | 23 +++++++------------ .../themes/oscar/src/js/autocompleter.js | 19 ++++----------- .../themes/oscar/src/js/element_modifiers.js | 21 +++++------------ searx/static/themes/oscar/src/js/infobox.js | 7 ++++++ .../static/themes/oscar/src/js/leaflet_map.js | 19 ++++----------- .../static/themes/oscar/src/js/preferences.js | 9 +++++++- searx/static/themes/oscar/src/js/toggleall.js | 7 ++++++ .../oscar/src/less/logicodev-dark/oscar.less | 2 +- .../oscar/src/less/logicodev/navbar.less | 2 +- .../themes/oscar/src/less/pointhi/navbar.less | 2 +- searx/templates/oscar/base.html | 8 +++---- searx/templates/oscar/index.html | 4 ++-- .../templates/oscar/messages/first_time.html | 2 +- .../templates/oscar/messages/no_results.html | 2 +- searx/templates/oscar/navbar.html | 2 +- searx/templates/oscar/preferences.html | 10 ++++---- .../templates/oscar/result_templates/map.html | 2 +- tests/unit/test_webapp.py | 2 +- 19 files changed, 73 insertions(+), 82 deletions(-) diff --git a/searx/static/themes/oscar/gruntfile.js b/searx/static/themes/oscar/gruntfile.js index d33c1b183..8e118afd6 100644 --- a/searx/static/themes/oscar/gruntfile.js +++ b/searx/static/themes/oscar/gruntfile.js @@ -61,29 +61,33 @@ module.exports = function(grunt) { }, dist: { src: ['src/js/*.js', '../__common__/js/image_layout.js'], - dest: 'js/searx.js' + dest: 'js/searxng.js' } }, uglify: { options: { + output: { + comments: 'some' + }, sourceMap: true, }, dist: { files: { - 'js/searx.min.js': ['<%= concat.dist.dest %>'] + 'js/searxng.min.js': ['<%= concat.dist.dest %>'] } } }, jshint: { - files: ['gruntfile.js', 'js/searx_src/*.js', '../__common__/js/image_layout.js'], + files: ['gruntfile.js', 'src/js/*.js', '../__common__/js/image_layout.js'], options: { reporterOutput: "", + esversion: 6, // options here to override JSHint defaults globals: { jQuery: true, console: true, module: true, - document: true + document: true, } } }, diff --git a/searx/static/themes/oscar/src/js/01_init.js b/searx/static/themes/oscar/src/js/01_init.js index e361d87ca..3066caad0 100644 --- a/searx/static/themes/oscar/src/js/01_init.js +++ b/searx/static/themes/oscar/src/js/01_init.js @@ -1,20 +1,11 @@ /** - * searx is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * searx is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with searx. If not, see < http://www.gnu.org/licenses/ >. - * - * (C) 2019 by Alexandre Flament + * @license + * (C) Copyright Contributors to the SearXNG project. + * (C) Copyright Contributors to the searx project (2014 - 2021). + * SPDX-License-Identifier: AGPL-3.0-or-later */ -window.searx = (function(d) { + +window.searxng = (function(d) { 'use strict'; // @@ -32,3 +23,5 @@ window.searx = (function(d) { translations: JSON.parse(script.getAttribute('data-translations')) }; })(document); + +window.searx = {}; diff --git a/searx/static/themes/oscar/src/js/autocompleter.js b/searx/static/themes/oscar/src/js/autocompleter.js index 56293f4f3..97c6d3c4e 100644 --- a/searx/static/themes/oscar/src/js/autocompleter.js +++ b/searx/static/themes/oscar/src/js/autocompleter.js @@ -1,23 +1,14 @@ /** - * searx is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * searx is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with searx. If not, see < http://www.gnu.org/licenses/ >. - * + * @license + * (C) Copyright Contributors to the SearXNG project. + * (C) Copyright Contributors to the searx project (2014 - 2021). * (C) 2014 by Thomas Pointhuber, + * SPDX-License-Identifier: AGPL-3.0-or-later */ $(document).ready(function(){ var original_search_value = ''; - if(searx.autocompleter) { + if(searxng.autocompleter) { var searchResults = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'), queryTokenizer: Bloodhound.tokenizers.whitespace, diff --git a/searx/static/themes/oscar/src/js/element_modifiers.js b/searx/static/themes/oscar/src/js/element_modifiers.js index 087f7d479..58e87f0f2 100644 --- a/searx/static/themes/oscar/src/js/element_modifiers.js +++ b/searx/static/themes/oscar/src/js/element_modifiers.js @@ -1,18 +1,9 @@ /** - * searx is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * searx is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with searx. If not, see < http://www.gnu.org/licenses/ >. - * + * @license + * (C) Copyright Contributors to the SearXNG project. + * (C) Copyright Contributors to the searx project (2014 - 2021). * (C) 2014 by Thomas Pointhuber, + * SPDX-License-Identifier: AGPL-3.0-or-later */ $(document).ready(function(){ @@ -112,6 +103,6 @@ $(document).ready(function(){ /** * Layout images according to their sizes */ - searx.image_thumbnail_layout = new searx.ImageLayout('#main_results', '#main_results .result-images', 'img.img-thumbnail', 15, 200); - searx.image_thumbnail_layout.watch(); + searxng.image_thumbnail_layout = new searx.ImageLayout('#main_results', '#main_results .result-images', 'img.img-thumbnail', 15, 200); + searxng.image_thumbnail_layout.watch(); }); diff --git a/searx/static/themes/oscar/src/js/infobox.js b/searx/static/themes/oscar/src/js/infobox.js index cb7f1eec5..f3d0c04b9 100644 --- a/searx/static/themes/oscar/src/js/infobox.js +++ b/searx/static/themes/oscar/src/js/infobox.js @@ -1,3 +1,10 @@ +/** + * @license + * (C) Copyright Contributors to the SearXNG project. + * (C) Copyright Contributors to the searx project (2014 - 2021). + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + window.addEventListener('load', function() { // Hide infobox toggle if shrunk size already fits all content. $('.infobox').each(function() { diff --git a/searx/static/themes/oscar/src/js/leaflet_map.js b/searx/static/themes/oscar/src/js/leaflet_map.js index 08233c42b..5c9703cc7 100644 --- a/searx/static/themes/oscar/src/js/leaflet_map.js +++ b/searx/static/themes/oscar/src/js/leaflet_map.js @@ -1,22 +1,13 @@ /** - * searx is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * searx is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with searx. If not, see < http://www.gnu.org/licenses/ >. - * + * @license + * (C) Copyright Contributors to the SearXNG project. + * (C) Copyright Contributors to the searx project (2014 - 2021). * (C) 2014 by Thomas Pointhuber, + * SPDX-License-Identifier: AGPL-3.0-or-later */ $(document).ready(function(){ - $(".searx_init_map").on( "click", function( event ) { + $(".searxng_init_map").on( "click", function( event ) { var leaflet_target = $(this).data('leaflet-target'); var map_lon = $(this).data('map-lon'); var map_lat = $(this).data('map-lat'); diff --git a/searx/static/themes/oscar/src/js/preferences.js b/searx/static/themes/oscar/src/js/preferences.js index 25aac052f..d3a3a7d76 100644 --- a/searx/static/themes/oscar/src/js/preferences.js +++ b/searx/static/themes/oscar/src/js/preferences.js @@ -1,3 +1,10 @@ +/** + * @license + * (C) Copyright Contributors to the SearXNG project. + * (C) Copyright Contributors to the searx project (2014 - 2021). + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + $(document).ready(function(){ let engine_descriptions = null; function load_engine_descriptions() { @@ -7,7 +14,7 @@ $(document).ready(function(){ for (const [engine_name, description] of Object.entries(data)) { let elements = $('[data-engine-name="' + engine_name + '"] .description'); for(const element of elements) { - let source = ' (' + searx.translations['Source'] + ': ' + description[1] + ')'; + let source = ' (' + searxng.translations.Source + ': ' + description[1] + ')'; element.innerHTML = description[0] + source; } } diff --git a/searx/static/themes/oscar/src/js/toggleall.js b/searx/static/themes/oscar/src/js/toggleall.js index b6c484e3e..69acb9d72 100644 --- a/searx/static/themes/oscar/src/js/toggleall.js +++ b/searx/static/themes/oscar/src/js/toggleall.js @@ -1,3 +1,10 @@ +/** + * @license + * (C) Copyright Contributors to the SearXNG project. + * (C) Copyright Contributors to the searx project (2014 - 2021). + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + $(document).ready(function(){ $("#allow-all-engines").click(function() { $(".onoffswitch-checkbox").each(function() { this.checked = false;}); diff --git a/searx/static/themes/oscar/src/less/logicodev-dark/oscar.less b/searx/static/themes/oscar/src/less/logicodev-dark/oscar.less index c68dcd9c9..14f23111f 100644 --- a/searx/static/themes/oscar/src/less/logicodev-dark/oscar.less +++ b/searx/static/themes/oscar/src/less/logicodev-dark/oscar.less @@ -170,7 +170,7 @@ p.btn.btn-default{ background:#ad1f12 none !important; } -.searx-navbar { +.searxng-navbar { background: #333334; height: 2.3rem; font-size: 1.3rem; diff --git a/searx/static/themes/oscar/src/less/logicodev/navbar.less b/searx/static/themes/oscar/src/less/logicodev/navbar.less index 6e4f9ee10..e1bbd35c6 100644 --- a/searx/static/themes/oscar/src/less/logicodev/navbar.less +++ b/searx/static/themes/oscar/src/less/logicodev/navbar.less @@ -1,4 +1,4 @@ -.searx-navbar { +.searxng-navbar { background: @black; height: 2.3rem; font-size: 1.3rem; diff --git a/searx/static/themes/oscar/src/less/pointhi/navbar.less b/searx/static/themes/oscar/src/less/pointhi/navbar.less index a057f8240..59be047a3 100644 --- a/searx/static/themes/oscar/src/less/pointhi/navbar.less +++ b/searx/static/themes/oscar/src/less/pointhi/navbar.less @@ -1,4 +1,4 @@ -.searx-navbar { +.searxng-navbar { background: #eee; color: #aaa; height: 2.3rem; diff --git a/searx/templates/oscar/base.html b/searx/templates/oscar/base.html index df06763fa..01dedc782 100644 --- a/searx/templates/oscar/base.html +++ b/searx/templates/oscar/base.html @@ -3,9 +3,9 @@ - - - + + + {% block meta %}{% endblock %} @@ -97,7 +97,7 @@ {% if load_leaflet %}{{" "}}{{ "\n" }}{% endif %} {% if autocomplete %}{{" "}}{{ "\n" }}{% endif %} - diff --git a/searx/templates/oscar/index.html b/searx/templates/oscar/index.html index fd8625d17..3ddfbcd49 100644 --- a/searx/templates/oscar/index.html +++ b/searx/templates/oscar/index.html @@ -4,10 +4,10 @@
{{- "" -}}
{%- if cookies['oscar-style'] == 'pointhi' -%} -

searx logosearx

+

searx logoSearXNG

{%- else -%} {%- endif -%}
{{- "" -}} diff --git a/searx/templates/oscar/messages/first_time.html b/searx/templates/oscar/messages/first_time.html index 38db62bdf..8b29d7020 100644 --- a/searx/templates/oscar/messages/first_time.html +++ b/searx/templates/oscar/messages/first_time.html @@ -4,5 +4,5 @@ {{ _('Close') }} {{ icon('info-sign') }} {{ _('Heads up!') }} - {{ _('It look like you are using searx first time.') }} + {{ _('It look like you are using SearXNG first time.') }}
diff --git a/searx/templates/oscar/messages/no_results.html b/searx/templates/oscar/messages/no_results.html index fe8e39d33..a76e31bb9 100644 --- a/searx/templates/oscar/messages/no_results.html +++ b/searx/templates/oscar/messages/no_results.html @@ -10,7 +10,7 @@ ){{- '' -}}

{%- endfor -%} -

{{ _('Please, try again later or find another searx instance.') }} ({{ _('Public instances') }})

+

{{ _('Please, try again later or find another SearXNG instance.') }} ({{ _('Public instances') }})

{% else %}