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

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

Issue 10750017: Extensions Docs Server: Intro data source (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 8 years, 5 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/template_data_source.py
diff --git a/chrome/common/extensions/docs/server2/template_data_source.py b/chrome/common/extensions/docs/server2/template_data_source.py
index ef0219f0f94638c736687d4b502be5f394640441..a19cf167cb96829daa555017a1070a022f07a12e 100644
--- a/chrome/common/extensions/docs/server2/template_data_source.py
+++ b/chrome/common/extensions/docs/server2/template_data_source.py
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+from path_utils import FormatKey
from third_party.handlebar import Handlebar
EXTENSIONS_URL = '/chrome/extensions'
@@ -10,11 +11,17 @@ class TemplateDataSource(object):
"""This class fetches and compiles templates using the fetcher passed in with
|cache_builder|.
"""
- def __init__(self, branch, api_data_source, cache_builder, base_paths):
+ def __init__(self,
+ branch,
+ api_data_source,
+ intro_data_source,
+ cache_builder,
+ base_paths):
self._branch_info = self._MakeBranchDict(branch)
self._static_resources = ((('/' + branch) if branch != 'local' else '') +
'/static')
self._api_data_source = api_data_source
+ self._intro_data_source = intro_data_source
self._cache = cache_builder.build(self._LoadTemplate)
self._base_paths = base_paths
@@ -45,6 +52,7 @@ class TemplateDataSource(object):
return template.render({
'apis': self._api_data_source,
'branchInfo': self._branch_info,
+ 'intros': self._intro_data_source,
'partials': self,
'static': self._static_resources
}).text
@@ -53,11 +61,7 @@ class TemplateDataSource(object):
return self.get(key)
def get(self, key):
- index = key.rfind('.html')
- if index > 0:
- key = key[:index]
- safe_key = key.replace('.', '_')
- real_path = safe_key + '.html'
+ real_path = FormatKey(key)
for base_path in self._base_paths:
try:
return self._cache.get(base_path + '/' + real_path)

Powered by Google App Engine
This is Rietveld 408576698