Browse Source

Load the list of icons only once

Cqoicebordel 10 years ago
parent
commit
e71b665fd5
1 changed files with 8 additions and 6 deletions
  1. 8
    6
      searx/webapp.py

+ 8
- 6
searx/webapp.py View File

@@ -71,6 +71,13 @@ babel = Babel(app)
71 71
 #TODO configurable via settings.yml
72 72
 favicons = ['wikipedia', 'youtube', 'vimeo', 'dailymotion', 'soundcloud',
73 73
             '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)
74 81
 
75 82
 cookie_max_age = 60 * 60 * 24 * 365 * 23  # 23 years
76 83
 
@@ -292,11 +299,6 @@ def index():
292 299
             if engine in favicons:
293 300
                 result['favicon'] = engine
294 301
                 
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
-
300 302
         # TODO, check if timezone is calculated right
301 303
         if 'publishedDate' in result:
302 304
             result['pubdate'] = result['publishedDate'].strftime('%Y-%m-%d %H:%M:%S%z')
@@ -350,7 +352,7 @@ def index():
350 352
         answers=search.answers,
351 353
         infoboxes=search.infoboxes,
352 354
         theme=get_current_theme_name(),
353
-        favicons=favs
355
+        favicons=global_favicons[themes.index(get_current_theme_name())]
354 356
     )
355 357
 
356 358