|
@@ -39,7 +39,7 @@ from searx.engines import (
|
39
|
39
|
)
|
40
|
40
|
from searx.utils import (
|
41
|
41
|
UnicodeWriter, highlight_content, html_to_text, get_themes,
|
42
|
|
- get_static_files
|
|
42
|
+ get_static_files, get_result_templates
|
43
|
43
|
)
|
44
|
44
|
from searx.version import VERSION_STRING
|
45
|
45
|
from searx.languages import language_codes
|
|
@@ -58,6 +58,8 @@ default_theme = settings['server'].get('default_theme', 'default')
|
58
|
58
|
|
59
|
59
|
static_files = get_static_files(searx_dir)
|
60
|
60
|
|
|
61
|
+result_templates = get_result_templates(searx_dir)
|
|
62
|
+
|
61
|
63
|
app = Flask(
|
62
|
64
|
__name__,
|
63
|
65
|
static_folder=static_path,
|
|
@@ -125,6 +127,13 @@ def get_current_theme_name(override=None):
|
125
|
127
|
return theme_name
|
126
|
128
|
|
127
|
129
|
|
|
130
|
+def get_result_template(theme, template_name):
|
|
131
|
+ themed_path = theme + '/result_templates/' + template_name
|
|
132
|
+ if themed_path in result_templates:
|
|
133
|
+ return themed_path
|
|
134
|
+ return 'result_templates/' + template_name
|
|
135
|
+
|
|
136
|
+
|
128
|
137
|
def url_for_theme(endpoint, override_theme=None, **values):
|
129
|
138
|
if endpoint == 'static' and values.get('filename'):
|
130
|
139
|
theme_name = get_current_theme_name(override=override_theme)
|
|
@@ -180,6 +189,8 @@ def render(template_name, override_theme=None, **kwargs):
|
180
|
189
|
# override url_for function in templates
|
181
|
190
|
kwargs['url_for'] = url_for_theme
|
182
|
191
|
|
|
192
|
+ kwargs['get_result_template'] = get_result_template
|
|
193
|
+
|
183
|
194
|
kwargs['theme'] = get_current_theme_name(override=override_theme)
|
184
|
195
|
|
185
|
196
|
kwargs['template_name'] = template_name
|