Chromium Code Reviews| Index: chrome/common/extensions/docs/server2/template_data_source.py |
| diff --git a/chrome/common/extensions/docs/server2/template_data_source.py b/chrome/common/extensions/docs/server2/template_data_source.py |
| index ba78f434a58b257c1ae225e74937c40e5ab15e92..fcef4f31ca52cf81299ae8316f797a7a2abf3788 100644 |
| --- a/chrome/common/extensions/docs/server2/template_data_source.py |
| +++ b/chrome/common/extensions/docs/server2/template_data_source.py |
| @@ -3,11 +3,9 @@ |
| # found in the LICENSE file. |
| import logging |
| -import os |
| import traceback |
| from branch_utility import BranchUtility |
| -import compiled_file_system as compiled_fs |
| from docs_server_utils import FormatKey |
| from file_system import FileNotFoundError |
| from third_party.handlebar import Handlebar |
| @@ -15,14 +13,18 @@ import url_constants |
| EXTENSIONS_URL = '/chrome/extensions' |
| -def _MakeChannelDict(channel_name): |
| +def _MakeChannelDict(channel_name, path): |
| + splitpath = path.split('/') |
| channel_dict = { |
| 'channels': [{'name': name} for name in BranchUtility.GetAllChannelNames()], |
| 'current': channel_name |
| } |
| + |
| for channel in channel_dict['channels']: |
| if channel['name'] == channel_name: |
| channel['isCurrent'] = True |
| + if splitpath[0] in ['extensions', 'apps']: |
| + channel_dict['base_url'] = '/%s/%s/' % (channel_name, splitpath[0]) |
|
not at google - send to devlin
2013/05/11 18:32:01
Ok I think this is the wrong place for this. siden
jshumway
2013/05/11 22:08:20
I went with the changes to *_sidenav.json and remo
|
| return channel_dict |
| class TemplateDataSource(object): |
| @@ -50,9 +52,10 @@ class TemplateDataSource(object): |
| sidenav_data_source_factory, |
| compiled_fs_factory, |
| ref_resolver_factory, |
| + manifest_data_source, |
| public_template_path, |
| private_template_path): |
| - self._branch_info = _MakeChannelDict(channel_name) |
| + self.channel_name = channel_name |
| self._api_data_source_factory = api_data_source_factory |
| self._api_list_data_source_factory = api_list_data_source_factory |
| self._intro_data_source_factory = intro_data_source_factory |
| @@ -64,6 +67,7 @@ class TemplateDataSource(object): |
| self._public_template_path = public_template_path |
| self._private_template_path = private_template_path |
| self._static_resources = '/%s/static' % channel_name |
| + self._manifest_data_source = manifest_data_source |
| def _CreateTemplate(self, template_name, text): |
| return Handlebar(self._ref_resolver.ResolveAllLinks(text)) |
| @@ -72,13 +76,14 @@ class TemplateDataSource(object): |
| """Returns a new TemplateDataSource bound to |request|. |
| """ |
| return TemplateDataSource( |
| - self._branch_info, |
| + _MakeChannelDict(self.channel_name, path), |
|
not at google - send to devlin
2013/05/11 18:32:01
I preferred the way it was with storing the _branc
jshumway
2013/05/11 22:08:20
Done.
|
| self._api_data_source_factory.Create(request), |
| self._api_list_data_source_factory.Create(), |
| self._intro_data_source_factory.Create(), |
| self._samples_data_source_factory.Create(request), |
| self._sidenav_data_source_factory.Create(path), |
| self._cache, |
| + self._manifest_data_source, |
| self._public_template_path, |
| self._private_template_path, |
| self._static_resources) |
| @@ -91,6 +96,7 @@ class TemplateDataSource(object): |
| samples_data_source, |
| sidenav_data_source, |
| cache, |
| + manifest_data_source, |
| public_template_path, |
| private_template_path, |
| static_resources): |
| @@ -104,6 +110,7 @@ class TemplateDataSource(object): |
| self._public_template_path = public_template_path |
| self._private_template_path = private_template_path |
| self._static_resources = static_resources |
| + self._manifest_data_source = manifest_data_source |
| def Render(self, template_name): |
| """This method will render a template named |template_name|, fetching all |
| @@ -121,6 +128,7 @@ class TemplateDataSource(object): |
| 'intros': self._intro_data_source, |
| 'sidenavs': self._sidenav_data_source, |
| 'partials': self, |
| + 'manifest_source': self._manifest_data_source, |
| 'samples': self._samples_data_source, |
| 'static': self._static_resources, |
| 'app': 'app', |
| @@ -149,6 +157,6 @@ class TemplateDataSource(object): |
| try: |
| return self._cache.GetFromFile( |
| '/'.join((base_path, FormatKey(template_name)))) |
| - except FileNotFoundError as e: |
| + except FileNotFoundError: |
| logging.warning(traceback.format_exc()) |
| return None |