mirror of
https://github.com/searxng/searxng.git
synced 2025-07-24 21:59:22 +02:00
[enh] themes static content refactor
This commit is contained in:
parent
e3957d6adf
commit
9f12605f7e
184 changed files with 19 additions and 10 deletions
|
@ -38,7 +38,8 @@ from searx.engines import (
|
|||
categories, engines, get_engines_stats, engine_shortcuts
|
||||
)
|
||||
from searx.utils import (
|
||||
UnicodeWriter, highlight_content, html_to_text, get_themes
|
||||
UnicodeWriter, highlight_content, html_to_text, get_themes,
|
||||
get_static_files
|
||||
)
|
||||
from searx.version import VERSION_STRING
|
||||
from searx.languages import language_codes
|
||||
|
@ -55,6 +56,8 @@ static_path, templates_path, themes =\
|
|||
|
||||
default_theme = settings['server'].get('default_theme', 'default')
|
||||
|
||||
static_files = get_static_files(searx_dir)
|
||||
|
||||
app = Flask(
|
||||
__name__,
|
||||
static_folder=static_path,
|
||||
|
@ -123,9 +126,11 @@ def get_current_theme_name(override=None):
|
|||
|
||||
|
||||
def url_for_theme(endpoint, override_theme=None, **values):
|
||||
if endpoint == 'static' and values.get('filename', None):
|
||||
if endpoint == 'static' and values.get('filename'):
|
||||
theme_name = get_current_theme_name(override=override_theme)
|
||||
values['filename'] = "{}/{}".format(theme_name, values['filename'])
|
||||
filename_with_theme = "themes/{}/{}".format(theme_name, values['filename'])
|
||||
if filename_with_theme in static_files:
|
||||
values['filename'] = filename_with_theme
|
||||
return url_for(endpoint, **values)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue