diff options
| author | Adam Tauber <asciimoo@gmail.com> | 2015-01-01 17:48:12 +0100 |
|---|---|---|
| committer | Adam Tauber <asciimoo@gmail.com> | 2015-01-01 17:48:12 +0100 |
| commit | 9f12605f7ebc9ca5575fc4ee9900e0e821366c4d (patch) | |
| tree | cbb1e9c475134ebbc22edefa4128b0a48f1e5770 /searx/webapp.py | |
| parent | e3957d6adf5298dbc009a0892f5c088c397c586b (diff) | |
[enh] themes static content refactor
Diffstat (limited to 'searx/webapp.py')
| -rw-r--r-- | searx/webapp.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/searx/webapp.py b/searx/webapp.py index be7feee82..2e3c2c119 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -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) |