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 SingleFile, Unicode | 9 from compiled_file_system import SingleFile, Unicode |
10 from data_source import DataSource | 10 from data_source import DataSource |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 return False | 53 return False |
54 | 54 |
55 | 55 |
56 class SidenavDataSource(DataSource): | 56 class SidenavDataSource(DataSource): |
57 '''Provides templates with access to JSON files used to create the side | 57 '''Provides templates with access to JSON files used to create the side |
58 navigation bar. | 58 navigation bar. |
59 ''' | 59 ''' |
60 def __init__(self, server_instance, request): | 60 def __init__(self, server_instance, request): |
61 self._cache = server_instance.compiled_fs_factory.Create( | 61 self._cache = server_instance.compiled_fs_factory.Create( |
62 server_instance.host_file_system_provider.GetTrunk(), | 62 server_instance.host_file_system_provider.GetMaster(), |
63 self._CreateSidenavDict, | 63 self._CreateSidenavDict, |
64 SidenavDataSource) | 64 SidenavDataSource) |
65 self._server_instance = server_instance | 65 self._server_instance = server_instance |
66 self._request = request | 66 self._request = request |
67 | 67 |
68 @SingleFile | 68 @SingleFile |
69 @Unicode | 69 @Unicode |
70 def _CreateSidenavDict(self, _, content): | 70 def _CreateSidenavDict(self, _, content): |
71 items = Parse(content) | 71 items = Parse(content) |
72 # Start at level 2, the top <ul> element is level 1. | 72 # Start at level 2, the top <ul> element is level 1. |
(...skipping 24 matching lines...) Expand all Loading... |
97 | 97 |
98 def get(self, key): | 98 def get(self, key): |
99 # TODO(mangini/kalman): Use |key| to decide which sidenav to use, | 99 # TODO(mangini/kalman): Use |key| to decide which sidenav to use, |
100 # which will require a more complex Cron method. | 100 # which will require a more complex Cron method. |
101 sidenav = self._cache.GetFromFile( | 101 sidenav = self._cache.GetFromFile( |
102 posixpath.join(JSON_TEMPLATES, 'chrome_sidenav.json')).Get() | 102 posixpath.join(JSON_TEMPLATES, 'chrome_sidenav.json')).Get() |
103 sidenav = copy.deepcopy(sidenav) | 103 sidenav = copy.deepcopy(sidenav) |
104 _AddAnnotations(sidenav, | 104 _AddAnnotations(sidenav, |
105 self._server_instance.base_path + self._request.path) | 105 self._server_instance.base_path + self._request.path) |
106 return sidenav | 106 return sidenav |
OLD | NEW |