on master help sign in
Load the list of icons only once
commite71b665fd5d62ddc52fda3eca141547bb3540522 authorCqoicebordel <Cqoicebordel@users.noreply.github.com> dateSat 13 Dec 2014, 21:37 (12 years ago) parent53a9af3
1 file changed+8−6
searx/webapp.py+8−6
searx/webapp.py+8−6
@@ -71,6 +71,13 @@ babel = Babel(app)
7171#TODO configurable via settings.yml
7272favicons = ['wikipedia', 'youtube', 'vimeo', 'dailymotion', 'soundcloud',
7373 'twitter', 'stackoverflow', 'github', 'deviantart']
74+
75+global_favicons = []
76+for indice,theme in enumerate(themes):
77+ global_favicons.append([])
78+ theme_img_path = searx_dir+"/static/"+theme+"/img/"
79+ for (dirpath, dirnames, filenames) in os.walk(theme_img_path):
80+ global_favicons[indice].extend(filenames)
7481
7582cookie_max_age = 60 * 60 * 24 * 365 * 23 # 23 years
7683
@@ -292,11 +299,6 @@ def index():
292299 if engine in favicons:
293300 result['favicon'] = engine
294301
295− mypath = searx_dir+"/static/"+get_current_theme_name()+"/img/"
296− favs=[]
297− for (dirpath, dirnames, filenames) in os.walk(mypath):
298− favs.extend(filenames)
299−
300302 # TODO, check if timezone is calculated right
301303 if 'publishedDate' in result:
302304 result['pubdate'] = result['publishedDate'].strftime('%Y-%m-%d %H:%M:%S%z')
@@ -350,7 +352,7 @@ def index():
350352 answers=search.answers,
351353 infoboxes=search.infoboxes,
352354 theme=get_current_theme_name(),
353− favicons=favs
355+ favicons=global_favicons[themes.index(get_current_theme_name())]
354356 )
355357
356358