From 9f12605f7ebc9ca5575fc4ee9900e0e821366c4d Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Thu, 1 Jan 2015 17:48:12 +0100 Subject: [enh] themes static content refactor --- searx/utils.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'searx/utils.py') diff --git a/searx/utils.py b/searx/utils.py index 8a3f35531..0594339d5 100644 --- a/searx/utils.py +++ b/searx/utils.py @@ -73,11 +73,9 @@ class HTMLTextExtractor(HTMLParser): self.tags = [] def handle_starttag(self, tag, attrs): - print tag self.tags.append(tag) def handle_endtag(self, tag): - print tag,tag if tag != self.tags[-1]: raise Exception("invalid html") self.tags.pop() @@ -156,11 +154,17 @@ def get_themes(root): """Returns available themes list.""" static_path = os.path.join(root, 'static') - static_names = set(os.listdir(static_path)) templates_path = os.path.join(root, 'templates') - templates_names = set(os.listdir(templates_path)) - themes = [] - for name in static_names.intersection(templates_names): - themes += [name] + themes = os.listdir(os.path.join(static_path, 'themes')) return static_path, templates_path, themes + + +def get_static_files(base_path): + static_files = set() + base_path_length = len(base_path+'/static') + 1 + for directory, _, files in os.walk(os.path.join(base_path, 'static')): + for filename in files: + f = os.path.join(directory[base_path_length:], filename) + static_files.add(f) + return static_files -- cgit v1.2.3