summaryrefslogtreecommitdiff
path: root/searx/webapp.py
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2015-01-01 18:59:53 +0100
committerAdam Tauber <asciimoo@gmail.com>2015-01-01 18:59:53 +0100
commit2f9a386c0db884ffbea27f43bdcff5bfd1876ad1 (patch)
tree152d1e208533261ae8b351cfd9b18b89792008ee /searx/webapp.py
parent20c4de8f06cd7f4b04ec37bf8aa28f96be48c093 (diff)
downloadsearxng-2f9a386c0db884ffbea27f43bdcff5bfd1876ad1.tar.gz
searxng-2f9a386c0db884ffbea27f43bdcff5bfd1876ad1.zip
[enh] better result template handling
Diffstat (limited to 'searx/webapp.py')
-rw-r--r--searx/webapp.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/searx/webapp.py b/searx/webapp.py
index 2e3c2c119..fca42d48e 100644
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -39,7 +39,7 @@ from searx.engines import (
)
from searx.utils import (
UnicodeWriter, highlight_content, html_to_text, get_themes,
- get_static_files
+ get_static_files, get_result_templates
)
from searx.version import VERSION_STRING
from searx.languages import language_codes
@@ -58,6 +58,8 @@ default_theme = settings['server'].get('default_theme', 'default')
static_files = get_static_files(searx_dir)
+result_templates = get_result_templates(searx_dir)
+
app = Flask(
__name__,
static_folder=static_path,
@@ -125,6 +127,13 @@ def get_current_theme_name(override=None):
return theme_name
+def get_result_template(theme, template_name):
+ themed_path = theme + '/result_templates/' + template_name
+ if themed_path in result_templates:
+ return themed_path
+ return 'result_templates/' + template_name
+
+
def url_for_theme(endpoint, override_theme=None, **values):
if endpoint == 'static' and values.get('filename'):
theme_name = get_current_theme_name(override=override_theme)
@@ -180,6 +189,8 @@ def render(template_name, override_theme=None, **kwargs):
# override url_for function in templates
kwargs['url_for'] = url_for_theme
+ kwargs['get_result_template'] = get_result_template
+
kwargs['theme'] = get_current_theme_name(override=override_theme)
kwargs['template_name'] = template_name