Commit 421fbb0e authored by cduvall@chromium.org's avatar cduvall@chromium.org

Extensions Docs Server: Proper path handling

The docs now use paths with the branch first, like 'trunk/apps/storage.html'
instead of paths like 'apps/trunk/storage.html'.

Also a couple other fixes to the samples page.

BUG=131095

Review URL: https://chromiumcodereview.appspot.com/10826173

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150168 0039d316-1c4b-4281-b951-d872f2087c98
parent 772c3757
......@@ -15,22 +15,15 @@ class BranchUtility(object):
self._memcache = memcache
def SplitChannelNameFromPath(self, path):
prefix = ''
if path.startswith('extensions/'):
prefix = 'extensions/'
path = path[len('extensions/'):]
elif path.startswith('apps/'):
prefix = 'apps/'
path = path[len('apps/'):]
try:
first, second = path.split('/', 1)
except ValueError:
first = path
second = ''
if first in ['trunk', 'dev', 'beta', 'stable']:
return (first, prefix + second)
return (first, second)
else:
return (self._default_branch, prefix + path)
return (self._default_branch, path)
def GetBranchNumberForChannelName(self, channel_name):
"""Returns an empty string if the branch number cannot be found.
......
......@@ -128,10 +128,10 @@ class Handler(webapp.RequestHandler):
if '_ah/warmup' in path:
logging.info('Warmup request.')
if DEFAULT_BRANCH != 'local':
self._NavigateToPath('extensions/trunk/samples.html')
self._NavigateToPath('extensions/dev/samples.html')
self._NavigateToPath('extensions/beta/samples.html')
self._NavigateToPath('extensions/stable/samples.html')
self._NavigateToPath('trunk/extensions/samples.html')
self._NavigateToPath('dev/extensions/samples.html')
self._NavigateToPath('beta/extensions/samples.html')
self._NavigateToPath('stable/extensions/samples.html')
return
# Redirect paths like "directory" to "directory/". This is so relative file
......
......@@ -95,7 +95,7 @@ class SamplesDataSource(object):
if l10n_data['icon'] is None:
icon_path = self._static_path + DEFAULT_ICON_PATH
else:
icon_path = sample_base_path + '/' + l10n_data['icon']
icon_path = '/' + sample_base_path + '/' + l10n_data['icon']
l10n_data.update({
'icon': icon_path,
'path': sample_base_path,
......
......@@ -36,11 +36,13 @@ class ServerInstance(object):
def Get(self, path, request, response):
templates = self._template_data_source_factory.Create(request)
if fnmatch(path, 'examples/*.zip'):
content = self._example_zipper.Create(path[:-len('.zip')])
if fnmatch(path, 'extensions/examples/*.zip'):
content = self._example_zipper.Create(
path[len('extensions/'):-len('.zip')])
response.headers['content-type'] = mimetypes.types_map['.zip']
elif path.startswith('examples/'):
content = self._cache.GetFromFile(DOCS_PATH + '/' + path)
elif path.startswith('extensions/examples/'):
content = self._cache.GetFromFile(
DOCS_PATH + '/' + path[len('extensions/'):])
response.headers['content-type'] = 'text/plain'
elif path.startswith('static/'):
content = self._FetchStaticResource(path, response)
......
......@@ -9,12 +9,14 @@
return;
var current_branch = window.bootstrap.branchInfo.current;
var path = window.location.pathname.split('/');
if (path[0] == '')
path = path.slice(1);
var index = path.indexOf(current_branch);
if (index != -1)
path[index] = value;
else
path.splice(path.length - 1, 0, value);
window.location = path.join('/');
path.splice(0, 0, value);
window.location = '/' + path.join('/');
}
document.getElementById('branchChooser').addEventListener(
......
......@@ -14,12 +14,11 @@
{{?is_apps}}
api_names: {{*api_list.apps.chrome}}.concat(
{{*api_list.apps.experimental}}),
branchInfo: {{*branchInfo}}
{{:is_apps}}
api_names: {{*api_list.extensions.chrome}}.concat(
{{*api_list.extensions.experimental}}),
branchInfo: {{*branchInfo}}
{{/is_apps}}
branchInfo: {{*branchInfo}}
};
</script>
<script src="{{static}}/js/branch.js" type="text/javascript"></script>
......
......@@ -20,7 +20,7 @@
<td class="label">Filter by API:</td>
<td>
<div id="api_filter_items">
{{#api_list.chrome}}
{{#api_list.extensions.chrome}}
<span><a href="javascript:void(0)">{{name}}</a>{{^last}} | {{/}}</span>
{{/}}
</div>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment