This commit is contained in:
Alexandre Flament 2022-07-10 13:31:02 +02:00 committed by GitHub
commit 89cc93ebfc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 78 additions and 122 deletions

View file

@ -24,7 +24,6 @@ Sample response
"images",
],
"default_locale": "",
"default_theme": "simple",
"engines": [
{
"categories": [

View file

@ -18,12 +18,12 @@ All of the engines above are just commented out in the :origin:`settings.yml
dependencies before using them.
By default, the engines use the ``key-value`` template for displaying results /
see :origin:`simple <searx/templates/simple/result_templates/key-value.html>`
theme. If you are not satisfied with the original result layout, you can use
your own template, set ``result_template`` attribute to ``{template_name}`` and
place the templates at::
see :origin:`simple <searx/templates/result_templates/key-value.html>`.
If you are not satisfied with the original result layout, you can use your own
template, set ``result_template`` attribute to ``{template_name}`` and place
the templates at::
searx/templates/{theme_name}/result_templates/{template_name}
searx/templates/result_templates/{template_name}
Futhermore, if you do not wish to expose these engines on a public instance, you
can still add them and limit the access by setting ``tokens`` as described in

View file

@ -232,7 +232,6 @@ Global Settings
query_in_title: false
infinite_scroll: false
center_alignment: false
default_theme: simple
theme_args:
simple_style: auto
@ -254,9 +253,6 @@ Global Settings
side of the screen. This setting only affects the *desktop layout*
(:origin:`min-width: @tablet <searx/static/themes/simple/src/less/definitions.less>`)
``default_theme`` :
Name of the theme you want to use by default on your SearXNG instance.
``theme_args.simple_style``:
Style of simple theme: ``auto``, ``light``, ``dark``

View file

@ -30,12 +30,12 @@ engines, e.g. ``database:`` ...
query_str: ...
By default, the engines use the ``key-value`` template for displaying results /
see :origin:`simple <searx/templates/simple/result_templates/key-value.html>`
theme. If you are not satisfied with the original result layout, you can use
see :origin:`simple <searx/templates/result_templates/key-value.html>`.
If you are not satisfied with the original result layout, you can use
your own template, set ``result_template`` attribute to ``{template_name}`` and
place the templates at::
searx/templates/{theme_name}/result_templates/{template_name}
searx/templates/result_templates/{template_name}
If you do not wish to expose these engines on a public instance, you can still
add them and limit the access by setting ``tokens`` as described in section

View file

@ -25,7 +25,7 @@ choose a meaningful commit message and we are happy to receive your pull
request. To not end in *wild west* we have some directives, please pay attention
to our ":ref:`how to contribute`" guideline.
If you implement themes, you will need to setup a :ref:`make node.env` once:
If you implement theme, you will need to setup a :ref:`make node.env` once:
.. code:: sh

View file

@ -75,15 +75,6 @@ Parameters
Filter search results of engines which support safe search. See if an engine
supports safe search in the preferences page of an instance.
``theme`` : default ``simple``
[ ``simple`` ]
Theme of instance.
Please note, available themes depend on an instance. It is possible that an
instance administrator deleted, created or renamed themes on their instance.
See the available options in the preferences page of the instance.
``enabled_plugins`` : optional
List of enabled plugins.

View file

@ -290,7 +290,7 @@ class PluginsSetting(BooleanChoices):
class Preferences:
"""Validates and saves preferences to cookies"""
def __init__(self, themes: List[str], categories: List[str], engines: Dict[str, Engine], plugins: Iterable[Plugin]):
def __init__(self, categories: List[str], engines: Dict[str, Engine], plugins: Iterable[Plugin]):
super().__init__()
self.key_value_settings: Dict[str, Setting] = {
@ -340,11 +340,6 @@ class Preferences:
'2': 2
}
),
'theme': EnumStringSetting(
settings['ui']['default_theme'],
locked=is_locked('theme'),
choices=themes
),
'results_on_new_tab': MapSetting(
settings['ui']['results_on_new_tab'],
locked=is_locked('results_on_new_tab'),

View file

@ -91,8 +91,6 @@ ui:
query_in_title: false
# infinite_scroll: When true, automatically loads the next page when scrolling to bottom of the current page.
infinite_scroll: false
# ui theme
default_theme: simple
# center the results ?
center_alignment: false
# Default interface locale - leave blank to detect from browser information or

View file

@ -180,7 +180,6 @@ SCHEMA = {
'static_path': SettingsDirectoryValue(str, os.path.join(searx_dir, 'static')),
'static_use_hash': SettingsValue(bool, False),
'templates_path': SettingsDirectoryValue(str, os.path.join(searx_dir, 'templates')),
'default_theme': SettingsValue(str, 'simple'),
'default_locale': SettingsValue(str, ''),
'theme_args': {
'simple_style': SettingsValue(SIMPLE_STYLE, 'auto'),

View file

@ -145,7 +145,7 @@ module.exports = function (grunt) {
svgo: ['--config', 'svg4web.svgo.js']
},
files: {
'<%= _templates %>/simple/searxng-wordmark.min.svg': '<%= _brand %>/searxng-wordmark.svg',
'<%= _templates %>/searxng-wordmark.min.svg': '<%= _brand %>/searxng-wordmark.svg',
'img/searxng.svg': '<%= _brand %>/searxng.svg',
'img/img_load_error.svg': '<%= _brand %>/img_load_error.svg'
}
@ -192,7 +192,7 @@ module.exports = function (grunt) {
'heart-outline': 'node_modules/ionicons/dist/svg/heart-outline.svg',
'information-circle-outline': 'src/svg/information-circle-outline.svg',
},
dest: '../../../templates/simple/icons.html',
dest: '../../../templates/icons.html',
},
},
});

View file

@ -1,4 +1,4 @@
{% extends "simple/base.html" %}
{% extends "base.html" %}
{% block content %}
<div class="center">
<h1>{{ _('Page not found') }}</h1>

View file

@ -28,7 +28,7 @@
<link rel="icon" href="{{ url_for('static', filename='img/favicon.svg') }}" type="image/svg+xml">
</head>
<body class="{{ endpoint }}_endpoint" >
<main id="main_{{ self._TemplateReference__context.name|replace("simple/", "")|replace(".html", "") }}" class="{{body_class}}">
<main id="main_{{ self._TemplateReference__context.name|replace(".html", "") }}" class="{{body_class}}">
{% if errors %}
<div class="dialog-error" role="alert">
<a href="#" class="close" aria-label="close" title="close">×</a>
@ -41,7 +41,7 @@
{% endif %}
<nav id="links_on_top">
{%- from 'simple/icons.html' import icon_big -%}
{%- from 'icons.html' import icon_big -%}
{%- block linkto_about -%}
<a href="{{ url_for('info', pagename='about') }}" class="link_on_top_about">{{ icon_big('information-circle-outline') }}<span>{{ _('About') }}</span></a>
{%- endblock -%}

View file

@ -1,4 +1,4 @@
{% from 'simple/icons.html' import icon_big %}
{% from 'icons.html' import icon_big %}
{%- set category_icons = {
'general': 'search-outline',
'images': 'image-outline',

View file

@ -0,0 +1,8 @@
{% extends "base.html" %}
{% from 'icons.html' import icon_big %}
{% block content %}
<div class="index">
<div class="title"><h1>SearXNG</h1></div>
{% include 'simple_search.html' %}
</div>
{% endblock %}

View file

@ -1,4 +1,4 @@
{% extends 'simple/page_with_header.html' %}
{% extends 'page_with_header.html' %}
{% block title %}{{ active_page.title }} - {% endblock %}
{% block linkto_about %}{% endblock %}
{% block linkto_donate %}{% endblock %}

View file

@ -1,4 +1,4 @@
{% from 'simple/icons.html' import icon_small %}
{% from 'icons.html' import icon_small %}
<!-- Draw favicon -->
{% macro draw_favicon(favicon) -%}

View file

@ -1,4 +1,4 @@
{% from 'simple/icons.html' import icon %}
{% from 'icons.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.') }}

View file

@ -1,4 +1,4 @@
{% from 'simple/icons.html' import icon_big %}
{% from 'icons.html' import icon_big %}
{% if unresponsive_engines %}
<div class="dialog-error" role="alert">
{{ icon_big('warning') }}

View file

@ -1,5 +1,5 @@
{% set body_class = "page_with_header" %}
{% extends "simple/base.html" %}
{% extends "base.html" %}
{% block header %}
<a href="{{ url_for('index') }}"><img class="logo" src="{{ url_for('static', filename='img/searxng.png') }}" alt="SearXNG"></a>
{% endblock %}

View file

@ -1,7 +1,7 @@
{% from 'simple/macros.html' import tabs_open, tabs_close, tab_header, tab_footer, checkbox_onoff, checkbox %}
{% from 'simple/icons.html' import icon_big %}
{% from 'macros.html' import tabs_open, tabs_close, tab_header, tab_footer, checkbox_onoff, checkbox %}
{% from 'icons.html' import icon_big %}
{% extends "simple/page_with_header.html" %}
{% extends "page_with_header.html" %}
{%- macro plugin_preferences(section) -%}
{%- for plugin in plugins -%}
@ -107,7 +107,7 @@
<fieldset>
<legend>{{ _('Default categories') }}</legend>
{% set display_tooltip = false %}
{% include 'simple/categories.html' %}
{% include 'categories.html' %}
</fieldset>
{% endif %}
{% if 'language' not in locked_preferences %}
@ -191,17 +191,6 @@
</fieldset>
{% endif %}
{% if 'theme' not in locked_preferences %}
<fieldset>
<legend id="pref_theme">{{ _('Theme') }}</legend>
<p class="value">
<select name="theme" aria-labelledby="pref_theme">
{%- for name in themes -%}
<option value="{{ name }}" {% if name == theme %}selected="selected"{% endif %}>{{ name }}</option>
{%- endfor -%}
</select>
</p>
<div class="description">{{ _('Change SearXNG layout') }}</div>
</fieldset>
<fieldset>
<legend id="pref_simple_style">{{ _('Theme style') }}</legend>
<p class="value">
@ -409,7 +398,7 @@
{% endfor %}
</table>
{% else %}
{% include 'simple/messages/no_cookies.html' %}
{% include 'messages/no_cookies.html' %}
{% endif %}
<h4>{{ _('Search URL of the currently saved preferences') }} :</h4>
<div class="selectable_url">

View file

@ -1,4 +1,4 @@
{% from 'simple/macros.html' import result_header, result_sub_header, result_sub_footer, result_footer with context %}
{% from 'macros.html' import result_header, result_sub_header, result_sub_footer, result_footer with context %}
{{ result_header(result, favicons, image_proxify) -}}
{{- result_sub_header(result) -}}

View file

@ -1,4 +1,4 @@
{% from 'simple/macros.html' import result_header, result_sub_header, result_sub_footer, result_footer with context %}
{% from 'macros.html' import result_header, result_sub_header, result_sub_footer, result_footer with context %}
{{ result_header(result, favicons, image_proxify) -}}
{{- result_sub_header(result) -}}

View file

@ -1,5 +1,5 @@
{% from 'simple/macros.html' import result_header, result_sub_header, result_sub_footer, result_footer with context %}
{% from 'simple/icons.html' import icon_small %}
{% from 'macros.html' import result_header, result_sub_header, result_sub_footer, result_footer with context %}
{% from 'icons.html' import icon_small %}
{{ result_header(result, favicons, image_proxify) -}}
{{- result_sub_header(result) -}}

View file

@ -0,0 +1,14 @@
{% from 'simple/macros.html' import result_header, result_sub_header, result_sub_footer, result_footer, result_footer_rtl with context %}
{{ result_header(result, favicons, image_proxify) -}}
{{- result_sub_header(result) -}}
{% if result.price %}<div class="result_price">{{ result.price }}</div></br>{% endif %}
{% if result.shipping %}<div class="result_shipping">{{ result.shipping }}</div></br>{% endif %}
{% if result.source_country %}<div class="result_source_country">{{ result.source_country }}</div></br>{% endif %}
{%- if result.content %}
<p class="content">
{{ result.content }}
</p>
{% endif -%}
{{- result_sub_footer(result, proxify) -}}
{{- result_footer(result) }}

View file

@ -1,4 +1,4 @@
{% from 'simple/macros.html' import result_header, result_sub_header, result_sub_footer, result_footer, result_link with context %}
{% from 'macros.html' import result_header, result_sub_header, result_sub_footer, result_footer, result_link with context %}
{{ result_header(result, favicons, image_proxify) -}}
{{- result_sub_header(result) -}}

View file

@ -1,4 +1,4 @@
{% from 'simple/macros.html' import result_header, result_sub_header, result_sub_footer, result_footer with context %}
{% from 'macros.html' import result_header, result_sub_header, result_sub_footer, result_footer with context %}
{{ result_header(result, favicons, image_proxify) }}
{{ result_sub_header(result) }}

View file

@ -1,5 +1,5 @@
{% extends "simple/base.html" %}
{% from 'simple/icons.html' import icon, icon_big, icon_small %}
{% extends "base.html" %}
{% from 'icons.html' import icon, icon_big, icon_small %}
{% macro engine_data_form(engine_data) -%}
{% for engine_name, kv_data in engine_data.items() %}
{% for k, v in kv_data.items() %}
@ -10,7 +10,7 @@
{% block title %}{% if query_in_title %}{{- q|e }} - {% endif %}{% endblock %}
{% block meta %}<link rel="alternate" type="application/rss+xml" title="Searx search: {{ q|e }}" href="{{ url_for('search', _external=True) }}?q={{ q|urlencode }}&amp;categories={{ selected_categories|join(",") | replace(' ','+') }}&amp;pageno={{ pageno }}&amp;time_range={{ time_range }}&amp;language={{ current_language }}&amp;safesearch={{ safesearch }}&amp;format=rss">{% endblock %}
{% block content %}
{% include 'simple/search.html' %}
{% include 'search.html' %}
{% if results and results|map(attribute='template')|unique|list|count == 1 %}
{% set only_template = 'only_template_' + results[0]['template']|default('default')|replace('.html', '') %}
@ -58,7 +58,7 @@
{% if infoboxes %}
<div id="infoboxes">
{% for infobox in infoboxes -%}
{% include 'simple/infobox.html' %}
{% include 'infobox.html' %}
{%- endfor %}
</div>
{% endif %}
@ -145,7 +145,7 @@
{% if result.close_group and not only_template %}</div>{% endif %}
{% endfor %}
{% if not results and not answers %}
{% include 'simple/messages/no_results.html' %}
{% include 'messages/no_results.html' %}
{% endif %}
</div>
<div id="backToTop">

View file

@ -2,7 +2,7 @@
<div id="search_header">
<a id="search_logo" href="{{ url_for('index') }}" tabindex="0" title="{{ _('Display the front page') }}">
<span hidden>SearXNG</span>
{% include 'simple/searxng-wordmark.min.svg' without context %}
{% include 'searxng-wordmark.min.svg' without context %}
</a>
<div id="search_view">
<div class="search_box">
@ -12,12 +12,12 @@
</div>
</div>
{% set display_tooltip = true %}
{% include 'simple/categories.html' %}
{% include 'categories.html' %}
</div>
<div class="search_filters">
{% include 'simple/filters/languages.html' %}
{% include 'simple/filters/time_range.html' %}
{% include 'simple/filters/safesearch.html' %}
{% include 'filters/languages.html' %}
{% include 'filters/time_range.html' %}
{% include 'filters/safesearch.html' %}
</div>
<input type="hidden" name="theme" value="{{ theme }}" >
{% if timeout_limit %}<input type="hidden" name="timeout_limit" value="{{ timeout_limit|e }}" >{% endif %}

View file

Before

Width:  |  Height:  |  Size: 711 B

After

Width:  |  Height:  |  Size: 711 B

Before After
Before After

View file

@ -1,8 +0,0 @@
{% extends "simple/base.html" %}
{% from 'simple/icons.html' import icon_big %}
{% block content %}
<div class="index">
<div class="title"><h1>SearXNG</h1></div>
{% include 'simple/simple_search.html' %}
</div>
{% endblock %}

View file

@ -1,7 +1,7 @@
{% from 'simple/icons.html' import icon_big %}
{% from 'simple/new_issue.html' import new_issue with context %}
{% from 'icons.html' import icon_big %}
{% from 'new_issue.html' import new_issue with context %}
{% extends "simple/page_with_header.html" %}
{% extends "page_with_header.html" %}
{%- macro th_sort(column_order, column_name) -%}
{% if selected_engine_name %}

View file

@ -73,7 +73,6 @@ from searx.webutils import (
highlight_content,
get_static_files,
get_result_templates,
get_themes,
prettify_url,
new_hmac,
is_hmac_of,
@ -138,9 +137,7 @@ static_files = get_static_files(settings['ui']['static_path'])
# about templates
logger.debug('templates directory is %s', settings['ui']['templates_path'])
default_theme = settings['ui']['default_theme']
templates_path = settings['ui']['templates_path']
themes = get_themes(templates_path)
result_templates = get_result_templates(templates_path)
STATS_SORT_PARAMETERS = {
@ -299,9 +296,7 @@ def custom_url_for(endpoint: str, **values):
if endpoint == 'static' and values.get('filename'):
file_hash = static_files.get(values['filename'])
if not file_hash:
# try file in the current theme
theme_name = request.preferences.get_value('theme')
filename_with_theme = "themes/{}/{}".format(theme_name, values['filename'])
filename_with_theme = "themes/simple/" + values['filename']
file_hash = static_files.get(filename_with_theme)
if file_hash:
values['filename'] = filename_with_theme
@ -489,7 +484,7 @@ def render(template_name: str, **kwargs):
kwargs['styles'].add(css)
start_time = default_timer()
result = render_template('{}/{}'.format(kwargs['theme'], template_name), **kwargs)
result = render_template(template_name, **kwargs)
request.render_time += default_timer() - start_time # pylint: disable=assigning-non-slot
return result
@ -502,7 +497,7 @@ def pre_request():
request.timings = [] # pylint: disable=assigning-non-slot
request.errors = [] # pylint: disable=assigning-non-slot
preferences = Preferences(themes, list(categories.keys()), engines, plugins) # pylint: disable=redefined-outer-name
preferences = Preferences(list(categories.keys()), engines, plugins) # pylint: disable=redefined-outer-name
user_agent = request.headers.get('User-Agent', '').lower()
if 'webkit' in user_agent and 'android' in user_agent:
preferences.key_value_settings['method'].value = 'GET'
@ -1083,7 +1078,6 @@ def preferences():
disabled_engines = disabled_engines,
autocomplete_backends = autocomplete_backends,
shortcuts = {y: x for x, y in engine_shortcuts.items()},
themes = themes,
plugins = plugins,
doi_resolvers = settings['doi_resolvers'],
current_doi_resolver = get_doi_resolver(request.preferences),
@ -1301,9 +1295,8 @@ def opensearch():
@app.route('/favicon.ico')
def favicon():
theme = request.preferences.get_value("theme")
return send_from_directory(
os.path.join(app.root_path, settings['ui']['static_path'], 'themes', theme, 'img'),
os.path.join(app.root_path, settings['ui']['static_path'], 'themes/simple/img'),
'favicon.png',
mimetype='image/vnd.microsoft.icon',
)
@ -1358,7 +1351,6 @@ def config():
'default_locale': settings['ui']['default_locale'],
'autocomplete': settings['search']['autocomplete'],
'safe_search': settings['search']['safe_search'],
'default_theme': settings['ui']['default_theme'],
'version': VERSION_STRING,
'brand': {
'PRIVACYPOLICY_URL': get_setting('general.privacypolicy_url'),

View file

@ -51,11 +51,6 @@ class UnicodeWriter:
self.writerow(row)
def get_themes(templates_path):
"""Returns available themes list."""
return os.listdir(templates_path)
def get_hash_for_file(file: pathlib.Path) -> str:
m = hashlib.sha1()
with file.open('rb') as f:

View file

@ -105,7 +105,7 @@ def get_search_query(
"language": args.lang,
"time_range": args.timerange,
}
preferences = searx.preferences.Preferences(['simple'], engine_categories, searx.engines.engines, [])
preferences = searx.preferences.Preferences(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]

View file

@ -24,7 +24,6 @@ server:
ui:
static_path: ""
templates_path: ""
default_theme: simple
preferences:
lock: []

View file

@ -27,7 +27,6 @@ server:
ui:
static_path: ""
templates_path: ""
default_theme: simple
default_locale: ""
theme_args:
simple_style: auto

View file

@ -122,7 +122,7 @@ class TestPreferences(SearxTestCase):
def test_encode(self):
from searx.preferences import Preferences
pref = Preferences(['simple'], ['general'], {}, [])
pref = Preferences(['general'], {}, [])
url_params = (
'eJx1Vk1z4zYM_TXxRZNMd7eddg8-pe21nWnvGoiEJEQkofDDtvzrC1qSRdnbQxQTBA'
'Hw8eGRCiJ27AnDsUOHHszBgOsSdHjU-Pr7HwfDCkweHCBFVmxHgxGPB7LiU4-eL9Px'

View file

@ -30,14 +30,14 @@ class ValidateQueryCase(SearxTestCase):
searx.search.initialize(TEST_ENGINES)
def test_query_private_engine_without_token(self):
preferences = Preferences(['simple'], ['general'], engines, [])
preferences = Preferences(['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(['simple'], ['general'], engines, [])
preferences_with_tokens = Preferences(['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(['simple'], ['general'], engines, [])
preferences_with_tokens = Preferences(['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)

View file

@ -7,7 +7,6 @@ from searx.results import Timing
import searx.search.processors
from searx.search import Search
from searx.preferences import Preferences
from tests import SearxTestCase
@ -78,15 +77,6 @@ class ViewsTestCase(SearxTestCase):
self.setattr4test(Search, 'search', search_mock)
original_preferences_get_value = Preferences.get_value
def preferences_get_value(preferences_self, user_setting_name: str):
if user_setting_name == 'theme':
return 'simple'
return original_preferences_get_value(preferences_self, user_setting_name)
self.setattr4test(Preferences, 'get_value', preferences_get_value)
self.maxDiff = None # to see full diffs
def test_index_empty(self):

View file

@ -8,8 +8,8 @@ STATIC_BUILT_PATHS=(
'searx/static/themes/simple/js'
'searx/static/themes/simple/src/generated/pygments.less'
'searx/static/themes/simple/img'
'searx/templates/simple/searxng-wordmark.min.svg'
'searx/templates/simple/icons.html'
'searx/templates/searxng-wordmark.min.svg'
'searx/templates/icons.html'
)
static_help(){