| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import copy | 5 import copy |
| 6 import logging | 6 import logging |
| 7 import posixpath | 7 import posixpath |
| 8 | 8 |
| 9 from compiled_file_system import Cache, SingleFile, Unicode | 9 from compiled_file_system import Cache, SingleFile, Unicode |
| 10 from data_source import DataSource | 10 from data_source import DataSource |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 self._QualifyHrefs(item['items']) | 85 self._QualifyHrefs(item['items']) |
| 86 | 86 |
| 87 href = item.get('href') | 87 href = item.get('href') |
| 88 if href is not None and not href.startswith(('http://', 'https://')): | 88 if href is not None and not href.startswith(('http://', 'https://')): |
| 89 if not href.startswith('/'): | 89 if not href.startswith('/'): |
| 90 logging.warn('Paths in sidenav must be qualified. %s is not.' % href) | 90 logging.warn('Paths in sidenav must be qualified. %s is not.' % href) |
| 91 else: | 91 else: |
| 92 href = href.lstrip('/') | 92 href = href.lstrip('/') |
| 93 item['href'] = self._server_instance.base_path + href | 93 item['href'] = self._server_instance.base_path + href |
| 94 | 94 |
| 95 def Refresh(self, path=None): | 95 def Refresh(self): |
| 96 return self._cache.GetFromFile( | 96 return self._cache.GetFromFile( |
| 97 posixpath.join(JSON_TEMPLATES, 'chrome_sidenav.json')) | 97 posixpath.join(JSON_TEMPLATES, 'chrome_sidenav.json')) |
| 98 | 98 |
| 99 def get(self, key): | 99 def get(self, key): |
| 100 # TODO(mangini/kalman): Use |key| to decide which sidenav to use, | 100 # TODO(mangini/kalman): Use |key| to decide which sidenav to use, |
| 101 # which will require a more complex Refresh method. | 101 # which will require a more complex Refresh method. |
| 102 sidenav = self._cache.GetFromFile( | 102 sidenav = self._cache.GetFromFile( |
| 103 posixpath.join(JSON_TEMPLATES, 'chrome_sidenav.json')).Get() | 103 posixpath.join(JSON_TEMPLATES, 'chrome_sidenav.json')).Get() |
| 104 sidenav = copy.deepcopy(sidenav) | 104 sidenav = copy.deepcopy(sidenav) |
| 105 _AddAnnotations(sidenav, | 105 _AddAnnotations(sidenav, |
| 106 self._server_instance.base_path + self._request.path) | 106 self._server_instance.base_path + self._request.path) |
| 107 return sidenav | 107 return sidenav |
| OLD | NEW |