##// END OF EJS Templates
Cache tweaks
neko259 -
r2015:4d5ec608 default
parent child Browse files
Show More
@@ -214,20 +214,12 b' class UrlViewer(AbstractViewer):'
214
214
215 domain = get_domain(self.url)
215 domain = get_domain(self.url)
216
216
217 if protocol in URL_PROTOCOLS:
217 image_path = 'images/{}.png'.format(self._get_image_name(protocol, domain))
218 url_image_name = URL_PROTOCOLS.get(protocol)
219 elif domain:
220 url_image_name = self._find_image_for_domains(domain) or FILE_STUB_URL
221 else:
222 url_image_name = FILE_STUB_URL
223
224 image_path = 'images/{}.png'.format(url_image_name)
225 image = static(image_path)
218 image = static(image_path)
226 w, h = self.get_static_dimensions(image_path)
219 w, h = self.get_static_dimensions(image_path)
227
220
228 return URL_FORMAT_VIEW.format(self.url, image, w, h)
221 return URL_FORMAT_VIEW.format(self.url, image, w, h)
229
222
230 @cached_result()
231 def _find_image_for_domains(self, domain):
223 def _find_image_for_domains(self, domain):
232 """
224 """
233 Searches for the domain image for every domain level except top.
225 Searches for the domain image for every domain level except top.
@@ -243,3 +235,15 b' class UrlViewer(AbstractViewer):'
243 return 'domains/' + domain
235 return 'domains/' + domain
244 else:
236 else:
245 del levels[0]
237 del levels[0]
238
239 @cached_result()
240 def _get_image_name(self, protocol, domain):
241 if protocol in URL_PROTOCOLS:
242 url_image_name = URL_PROTOCOLS.get(protocol)
243 elif domain:
244 url_image_name = self._find_image_for_domains(domain) or FILE_STUB_URL
245 else:
246 url_image_name = FILE_STUB_URL
247
248 return url_image_name
249
General Comments 0
You need to be logged in to leave comments. Login now