浏览代码

Load the list of icons only once

Cqoicebordel 10 年前
父节点
当前提交
e71b665fd5
共有 1 个文件被更改,包括 8 次插入6 次删除
  1. 8
    6
      searx/webapp.py

+ 8
- 6
searx/webapp.py 查看文件

71
 #TODO configurable via settings.yml
71
 #TODO configurable via settings.yml
72
 favicons = ['wikipedia', 'youtube', 'vimeo', 'dailymotion', 'soundcloud',
72
 favicons = ['wikipedia', 'youtube', 'vimeo', 'dailymotion', 'soundcloud',
73
             'twitter', 'stackoverflow', 'github', 'deviantart']
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
 cookie_max_age = 60 * 60 * 24 * 365 * 23  # 23 years
82
 cookie_max_age = 60 * 60 * 24 * 365 * 23  # 23 years
76
 
83
 
292
             if engine in favicons:
299
             if engine in favicons:
293
                 result['favicon'] = engine
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
         # TODO, check if timezone is calculated right
302
         # TODO, check if timezone is calculated right
301
         if 'publishedDate' in result:
303
         if 'publishedDate' in result:
302
             result['pubdate'] = result['publishedDate'].strftime('%Y-%m-%d %H:%M:%S%z')
304
             result['pubdate'] = result['publishedDate'].strftime('%Y-%m-%d %H:%M:%S%z')
350
         answers=search.answers,
352
         answers=search.answers,
351
         infoboxes=search.infoboxes,
353
         infoboxes=search.infoboxes,
352
         theme=get_current_theme_name(),
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