X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fchrome%2Fcommon%2Fextensions%2Fdocs%2Fserver2%2Fsidenav_data_source.py;h=ca51aec51f648373b5b8292adee5896b20c388b4;hb=3545e9f2671f595d2a2f3ee75ca0393b01e35ef6;hp=1a7bae9d68494a5c171332e215dfe2b17bc66bb2;hpb=7d210d4c7e9ba36e635eabc5b5780495f8a63292;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/chrome/common/extensions/docs/server2/sidenav_data_source.py b/src/chrome/common/extensions/docs/server2/sidenav_data_source.py index 1a7bae9..ca51aec 100644 --- a/src/chrome/common/extensions/docs/server2/sidenav_data_source.py +++ b/src/chrome/common/extensions/docs/server2/sidenav_data_source.py @@ -6,7 +6,7 @@ import copy import logging import posixpath -from compiled_file_system import SingleFile, Unicode +from compiled_file_system import Cache, SingleFile, Unicode from data_source import DataSource from extensions_paths import JSON_TEMPLATES from future import Future @@ -24,13 +24,13 @@ def _AddLevels(items, level): def _AddAnnotations(items, path, parent=None): - '''Add 'selected', 'child_selected' and 'related' properties to - |items| so that the sidenav can be expanded to show which menu item has + '''Add 'selected', 'child_selected' and 'related' properties to + |items| so that the sidenav can be expanded to show which menu item has been selected and the related pages section can be drawn. 'related' is added to all items with the same parent as the selected item. - If more than one item exactly matches the path, the deepest one is considered + If more than one item exactly matches the path, the deepest one is considered 'selected'. A 'parent' property is added to the selected path. - + Returns True if an item was marked 'selected'. ''' for item in items: @@ -42,12 +42,12 @@ def _AddAnnotations(items, path, parent=None): if item.get('href', '') == path: item['selected'] = True if parent: - item['parent'] = { 'title': parent.get('title', None), + item['parent'] = { 'title': parent.get('title', None), 'href': parent.get('href', None) } - + for sibling in items: sibling['related'] = True - + return True return False @@ -59,12 +59,13 @@ class SidenavDataSource(DataSource): ''' def __init__(self, server_instance, request): self._cache = server_instance.compiled_fs_factory.Create( - server_instance.host_file_system_provider.GetTrunk(), + server_instance.host_file_system_provider.GetMaster(), self._CreateSidenavDict, SidenavDataSource) self._server_instance = server_instance self._request = request + @Cache @SingleFile @Unicode def _CreateSidenavDict(self, _, content): @@ -91,13 +92,13 @@ class SidenavDataSource(DataSource): href = href.lstrip('/') item['href'] = self._server_instance.base_path + href - def Cron(self): + def Refresh(self, path=None): return self._cache.GetFromFile( posixpath.join(JSON_TEMPLATES, 'chrome_sidenav.json')) def get(self, key): # TODO(mangini/kalman): Use |key| to decide which sidenav to use, - # which will require a more complex Cron method. + # which will require a more complex Refresh method. sidenav = self._cache.GetFromFile( posixpath.join(JSON_TEMPLATES, 'chrome_sidenav.json')).Get() sidenav = copy.deepcopy(sidenav)