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

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

Issue 441053004: Docserver: Modify DocumentRenderer to generate absolute links (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 hashlib 5 import hashlib
6 import logging 6 import logging
7 import posixpath 7 import posixpath
8 import traceback 8 import traceback
9 9
10 from branch_utility import BranchUtility 10 from branch_utility import BranchUtility
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 if not content_and_type.content: 110 if not content_and_type.content:
111 logging.error('%s had empty content' % path) 111 logging.error('%s had empty content' % path)
112 112
113 content = content_and_type.content 113 content = content_and_type.content
114 if isinstance(content, Handlebar): 114 if isinstance(content, Handlebar):
115 template_content, template_warnings = ( 115 template_content, template_warnings = (
116 server_instance.template_renderer.Render(content, self._request)) 116 server_instance.template_renderer.Render(content, self._request))
117 # HACK: the site verification file (google2ed...) doesn't have a title. 117 # HACK: the site verification file (google2ed...) doesn't have a title.
118 content, doc_warnings = server_instance.document_renderer.Render( 118 content, doc_warnings = server_instance.document_renderer.Render(
119 template_content, 119 template_content,
120 self._request.host,
120 path, 121 path,
121 render_title=path != SITE_VERIFICATION_FILE) 122 render_title=path != SITE_VERIFICATION_FILE)
122 warnings = template_warnings + doc_warnings 123 warnings = template_warnings + doc_warnings
123 if warnings: 124 if warnings:
124 sep = '\n - ' 125 sep = '\n - '
125 logging.warning('Rendering %s:%s%s' % (path, sep, sep.join(warnings))) 126 logging.warning('Rendering %s:%s%s' % (path, sep, sep.join(warnings)))
126 # Content was dynamic. The new etag is a hash of the content. 127 # Content was dynamic. The new etag is a hash of the content.
127 etag = None 128 etag = None
128 elif content_and_type.version is not None: 129 elif content_and_type.version is not None:
129 # Content was static. The new etag is the version of the content. Hash it 130 # Content was static. The new etag is the version of the content. Hash it
(...skipping 12 matching lines...) Expand all
142 if etag is None: 143 if etag is None:
143 # Note: we're using md5 as a convenient and fast-enough way to identify 144 # Note: we're using md5 as a convenient and fast-enough way to identify
144 # content. It's not intended to be cryptographic in any way, and this 145 # content. It's not intended to be cryptographic in any way, and this
145 # is *not* what etags is for. That's what SSL is for, this is unrelated. 146 # is *not* what etags is for. That's what SSL is for, this is unrelated.
146 etag = '"%s"' % hashlib.md5(content).hexdigest() 147 etag = '"%s"' % hashlib.md5(content).hexdigest()
147 148
148 headers = _MakeHeaders(content_type, etag=etag) 149 headers = _MakeHeaders(content_type, etag=etag)
149 if etag == self._request.headers.get('If-None-Match'): 150 if etag == self._request.headers.get('If-None-Match'):
150 return Response.NotModified('Not Modified', headers=headers) 151 return Response.NotModified('Not Modified', headers=headers)
151 return Response.Ok(content, headers=headers) 152 return Response.Ok(content, headers=headers)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698