Index: chrome/common/extensions/docs/server2/sidenav_data_source.py |
=================================================================== |
--- chrome/common/extensions/docs/server2/sidenav_data_source.py (revision 201930) |
+++ chrome/common/extensions/docs/server2/sidenav_data_source.py (working copy) |
@@ -14,17 +14,21 @@ |
menu. |
""" |
class Factory(object): |
- def __init__(self, compiled_fs_factory, json_path): |
+ def __init__(self, compiled_fs_factory, json_path, base_path): |
self._cache = compiled_fs_factory.Create(self._CreateSidenavDict, |
SidenavDataSource) |
self._json_path = json_path |
+ self._base_path = base_path |
def Create(self, path): |
"""Create a SidenavDataSource, binding it to |path|. |path| is the url |
of the page that is being rendered. It is used to determine which item |
in the sidenav should be highlighted. |
""" |
- return SidenavDataSource(self._cache, self._json_path, path) |
+ return SidenavDataSource(self._cache, |
+ self._json_path, |
+ path, |
+ self._base_path) |
def _AddLevels(self, items, level): |
"""Levels represent how deeply this item is nested in the sidenav. We |
@@ -40,10 +44,11 @@ |
self._AddLevels(items, 2); |
return items |
- def __init__(self, cache, json_path, path): |
+ def __init__(self, cache, json_path, path, base_path): |
self._cache = cache |
self._json_path = json_path |
self._file_name = path.split('/')[-1] |
+ self._base_path = base_path |
def _AddSelected(self, items): |
for item in items: |
@@ -56,8 +61,19 @@ |
return True |
return False |
+ def _ConvertToAbsolutePath(self, items, key): |
+ for item in items: |
+ fileName = item.get('fileName') |
not at google - send to devlin
2013/05/24 16:58:29
file_name = ...
方觉(Fang Jue)
2013/05/25 00:08:39
Done.
|
+ if fileName is not None and not fileName.startswith(('/', |
+ 'http://', |
+ 'https://')): |
+ item['fileName'] = '%s/%s/%s' % (self._base_path, key, fileName) |
+ if 'items' in item: |
+ self._ConvertToAbsolutePath(item['items'], key) |
+ |
def get(self, key): |
sidenav = copy.deepcopy(self._cache.GetFromFile( |
'%s/%s_sidenav.json' % (self._json_path, key))) |
self._AddSelected(sidenav) |
+ self._ConvertToAbsolutePath(sidenav, key) |
not at google - send to devlin
2013/05/24 16:58:29
it would be more correct to use the path of the re
方觉(Fang Jue)
2013/05/25 00:08:39
path here is something like 'extensions/index.html
not at google - send to devlin
2013/05/28 14:53:37
Why is the 'extensions/index.html' example special
|
return sidenav |