| Index: chrome/common/extensions/docs/server2/samples_data_source.py
|
| diff --git a/chrome/common/extensions/docs/server2/samples_data_source.py b/chrome/common/extensions/docs/server2/samples_data_source.py
|
| index 3fdd09e5d540ad0b3c6f8658b4e78671ff987b84..f306f62753fe7cd169121bf9ed10d362f34125db 100644
|
| --- a/chrome/common/extensions/docs/server2/samples_data_source.py
|
| +++ b/chrome/common/extensions/docs/server2/samples_data_source.py
|
| @@ -10,11 +10,14 @@ import re
|
| import traceback
|
|
|
| from compiled_file_system import CompiledFileSystem
|
| +from extensions_paths import EXAMPLES
|
| import third_party.json_schema_compiler.json_comment_eater as json_comment_eater
|
| import third_party.json_schema_compiler.model as model
|
| import url_constants
|
|
|
| -DEFAULT_ICON_PATH = 'images/sample-default-icon.png'
|
| +
|
| +_DEFAULT_ICON_PATH = 'images/sample-default-icon.png'
|
| +
|
|
|
| class SamplesDataSource(object):
|
| '''Constructs a list of samples and their respective files and api calls.
|
| @@ -28,12 +31,10 @@ class SamplesDataSource(object):
|
| app_samples_file_system,
|
| compiled_fs_factory,
|
| ref_resolver_factory,
|
| - extension_samples_path,
|
| base_path):
|
| self._host_file_system = host_file_system
|
| self._app_samples_file_system = app_samples_file_system
|
| self._ref_resolver = ref_resolver_factory.Create()
|
| - self._extension_samples_path = extension_samples_path
|
| self._base_path = base_path
|
| self._extensions_cache = compiled_fs_factory.Create(
|
| host_file_system,
|
| @@ -51,7 +52,6 @@ class SamplesDataSource(object):
|
| '''
|
| return SamplesDataSource(self._extensions_cache,
|
| self._apps_cache,
|
| - self._extension_samples_path,
|
| self._base_path,
|
| request)
|
|
|
| @@ -103,10 +103,7 @@ class SamplesDataSource(object):
|
| l10n_data['locales'][path[len(locales_path):].split('/')[0]] = json_
|
| return l10n_data
|
|
|
| - def _MakeSamplesList(self, base_dir, files, is_apps=False):
|
| - # HACK(kalman): The code here (for legacy reasons) assumes that |files| is
|
| - # prefixed by |base_dir|, so make it true.
|
| - files = ['%s%s' % (base_dir, f) for f in files]
|
| + def _MakeSamplesList(self, base_path, files, is_apps=False):
|
| file_system = (self._app_samples_file_system if is_apps else
|
| self._host_file_system)
|
| samples_list = []
|
| @@ -119,9 +116,10 @@ class SamplesDataSource(object):
|
| sample_files = [path for path in files
|
| if path.startswith(sample_path + '/')]
|
| js_files = [path for path in sample_files if path.endswith('.js')]
|
| - js_contents = file_system.Read(js_files).Get()
|
| + js_contents = file_system.Read(
|
| + [posixpath.join(base_path, js_file) for js_file in js_files]).Get()
|
| api_items = set()
|
| - for js in js_contents.values():
|
| + for js in js_contents.itervalues():
|
| api_items.update(self._GetAPIItems(js))
|
|
|
| api_calls = []
|
| @@ -148,7 +146,7 @@ class SamplesDataSource(object):
|
| 'link': ref_data['href']
|
| })
|
|
|
| - sample_base_path = sample_path.split('/', 1)[1]
|
| + sample_base_path = posixpath.join('examples', sample_path)
|
| if is_apps:
|
| url = url_constants.GITHUB_BASE + '/' + sample_base_path
|
| icon_base = url_constants.RAW_GITHUB_BASE + '/' + sample_base_path
|
| @@ -158,10 +156,11 @@ class SamplesDataSource(object):
|
| icon_base = sample_base_path
|
| download_url = sample_base_path + '.zip'
|
|
|
| - manifest_data = self._GetDataFromManifest(sample_path, file_system)
|
| + manifest_data = self._GetDataFromManifest(
|
| + posixpath.join(base_path, sample_path), file_system)
|
| if manifest_data['icon'] is None:
|
| icon_path = posixpath.join(
|
| - self._base_path, 'static', DEFAULT_ICON_PATH)
|
| + self._base_path, 'static', _DEFAULT_ICON_PATH)
|
| else:
|
| icon_path = '%s/%s' % (icon_base, manifest_data['icon'])
|
| manifest_data.update({
|
| @@ -178,12 +177,10 @@ class SamplesDataSource(object):
|
| def __init__(self,
|
| extensions_cache,
|
| apps_cache,
|
| - extension_samples_path,
|
| base_path,
|
| request):
|
| self._extensions_cache = extensions_cache
|
| self._apps_cache = apps_cache
|
| - self._extension_samples_path = extension_samples_path
|
| self._base_path = base_path
|
| self._request = request
|
|
|
| @@ -210,8 +207,7 @@ class SamplesDataSource(object):
|
| if key == 'apps':
|
| samples_list = self._apps_cache.GetFromFileListing('/').Get()
|
| else:
|
| - samples_list = self._extensions_cache.GetFromFileListing(
|
| - self._extension_samples_path + '/').Get()
|
| + samples_list = self._extensions_cache.GetFromFileListing(EXAMPLES).Get()
|
| return_list = []
|
| for dict_ in samples_list:
|
| name = dict_['name']
|
|
|