| 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 logging | 5 import logging |
| 6 | 6 |
| 7 from docs_server_utils import FormatKey | 7 from docs_server_utils import FormatKey |
| 8 from file_system import FileNotFoundError | 8 from file_system import FileNotFoundError |
| 9 import compiled_file_system as compiled_fs | 9 import compiled_file_system as compiled_fs |
| 10 from third_party.handlebar import Handlebar | 10 from third_party.handlebar import Handlebar |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 self._private_template_path = private_template_path | 60 self._private_template_path = private_template_path |
| 61 self._static_resources = ( | 61 self._static_resources = ( |
| 62 (('/' + channel_name) if channel_name != 'local' else '') + '/static') | 62 (('/' + channel_name) if channel_name != 'local' else '') + '/static') |
| 63 | 63 |
| 64 def Create(self, request, path): | 64 def Create(self, request, path): |
| 65 """Returns a new TemplateDataSource bound to |request|. | 65 """Returns a new TemplateDataSource bound to |request|. |
| 66 """ | 66 """ |
| 67 branch_info = self._branch_info.copy() | 67 branch_info = self._branch_info.copy() |
| 68 branch_info['showWarning'] = (not path.startswith('apps') and | 68 branch_info['showWarning'] = (not path.startswith('apps') and |
| 69 branch_info['showWarning']) | 69 branch_info['showWarning']) |
| 70 samples_data_source = self._samples_data_source_factory.Create(request) |
| 70 return TemplateDataSource( | 71 return TemplateDataSource( |
| 71 branch_info, | 72 branch_info, |
| 72 self._api_data_source_factory.Create(request), | 73 self._api_data_source_factory.Create(request, samples_data_source), |
| 73 self._api_list_data_source_factory.Create(), | 74 self._api_list_data_source_factory.Create(), |
| 74 self._intro_data_source_factory.Create(), | 75 self._intro_data_source_factory.Create(), |
| 75 self._samples_data_source_factory.Create(request), | 76 samples_data_source, |
| 76 self._known_issues_data_source, | 77 self._known_issues_data_source, |
| 77 self._cache, | 78 self._cache, |
| 78 self._public_template_path, | 79 self._public_template_path, |
| 79 self._private_template_path, | 80 self._private_template_path, |
| 80 self._static_resources, | 81 self._static_resources, |
| 81 request) | 82 request) |
| 82 | 83 |
| 83 def __init__(self, | 84 def __init__(self, |
| 84 branch_info, | 85 branch_info, |
| 85 api_data_source, | 86 api_data_source, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 def get(self, key): | 139 def get(self, key): |
| 139 return self.GetTemplate(self._private_template_path, key) | 140 return self.GetTemplate(self._private_template_path, key) |
| 140 | 141 |
| 141 def GetTemplate(self, base_path, template_name): | 142 def GetTemplate(self, base_path, template_name): |
| 142 real_path = FormatKey(template_name) | 143 real_path = FormatKey(template_name) |
| 143 try: | 144 try: |
| 144 return self._cache.GetFromFile(base_path + '/' + real_path) | 145 return self._cache.GetFromFile(base_path + '/' + real_path) |
| 145 except FileNotFoundError as e: | 146 except FileNotFoundError as e: |
| 146 logging.info(e) | 147 logging.info(e) |
| 147 return None | 148 return None |
| OLD | NEW |