Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1511)

Unified Diff: chrome/common/extensions/docs/server2/sidenav_data_source.py

Issue 12521030: Extension docs: Include sidenav in 404 pages (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: Extension docs: Include sidenav in 404 pages Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698