From 2f9a386c0db884ffbea27f43bdcff5bfd1876ad1 Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Thu, 1 Jan 2015 18:59:53 +0100 Subject: [enh] better result template handling --- searx/utils.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'searx/utils.py') diff --git a/searx/utils.py b/searx/utils.py index 0594339d5..5bd1ced4d 100644 --- a/searx/utils.py +++ b/searx/utils.py @@ -161,10 +161,23 @@ def get_themes(root): def get_static_files(base_path): + base_path = os.path.join(base_path, 'static') static_files = set() - base_path_length = len(base_path+'/static') + 1 - for directory, _, files in os.walk(os.path.join(base_path, 'static')): + base_path_length = len(base_path) + 1 + for directory, _, files in os.walk(base_path): for filename in files: f = os.path.join(directory[base_path_length:], filename) static_files.add(f) return static_files + + +def get_result_templates(base_path): + base_path = os.path.join(base_path, 'templates') + result_templates = set() + base_path_length = len(base_path) + 1 + for directory, _, files in os.walk(base_path): + if directory.endswith('result_templates'): + for filename in files: + f = os.path.join(directory[base_path_length:], filename) + result_templates.add(f) + return result_templates -- cgit v1.2.3