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

Side by Side Diff: chrome/common/extensions/docs/server2/template_data_source.py

Issue 14125010: Docserver: Add support for viewing docs with a codereview patch applied (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 8 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 unified diff | Download patch
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import os 6 import os
7 import traceback 7 import traceback
8 8
9 from branch_utility import BranchUtility 9 from branch_utility import BranchUtility
10 import compiled_file_system as compiled_fs 10 import compiled_file_system as compiled_fs
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 self._api_data_source_factory = api_data_source_factory 56 self._api_data_source_factory = api_data_source_factory
57 self._api_list_data_source_factory = api_list_data_source_factory 57 self._api_list_data_source_factory = api_list_data_source_factory
58 self._intro_data_source_factory = intro_data_source_factory 58 self._intro_data_source_factory = intro_data_source_factory
59 self._samples_data_source_factory = samples_data_source_factory 59 self._samples_data_source_factory = samples_data_source_factory
60 self._sidenav_data_source_factory = sidenav_data_source_factory 60 self._sidenav_data_source_factory = sidenav_data_source_factory
61 self._cache = compiled_fs_factory.Create(self._CreateTemplate, 61 self._cache = compiled_fs_factory.Create(self._CreateTemplate,
62 TemplateDataSource) 62 TemplateDataSource)
63 self._ref_resolver = ref_resolver_factory.Create() 63 self._ref_resolver = ref_resolver_factory.Create()
64 self._public_template_path = public_template_path 64 self._public_template_path = public_template_path
65 self._private_template_path = private_template_path 65 self._private_template_path = private_template_path
66 # TODO(fj): Make it point to correct paths when serving patched content
66 self._static_resources = '/%s/static' % channel_name 67 self._static_resources = '/%s/static' % channel_name
67 68
68 def _CreateTemplate(self, template_name, text): 69 def _CreateTemplate(self, template_name, text):
69 return Handlebar(self._ref_resolver.ResolveAllLinks(text)) 70 return Handlebar(self._ref_resolver.ResolveAllLinks(text))
70 71
71 def Create(self, request, path): 72 def Create(self, request, path):
72 """Returns a new TemplateDataSource bound to |request|. 73 """Returns a new TemplateDataSource bound to |request|.
73 """ 74 """
74 return TemplateDataSource( 75 return TemplateDataSource(
75 self._branch_info, 76 self._branch_info,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 def get(self, key): 141 def get(self, key):
141 return self.GetTemplate(self._private_template_path, key) 142 return self.GetTemplate(self._private_template_path, key)
142 143
143 def GetTemplate(self, base_path, template_name): 144 def GetTemplate(self, base_path, template_name):
144 try: 145 try:
145 return self._cache.GetFromFile( 146 return self._cache.GetFromFile(
146 '/'.join((base_path, FormatKey(template_name)))) 147 '/'.join((base_path, FormatKey(template_name))))
147 except FileNotFoundError as e: 148 except FileNotFoundError as e:
148 logging.warning(traceback.format_exc()) 149 logging.warning(traceback.format_exc())
149 return None 150 return None
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698