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

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

Issue 10689144: Extensions Docs Server: Samples zip files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Samples page with full links and descriptions 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/server_instance.py
diff --git a/chrome/common/extensions/docs/server2/server_instance.py b/chrome/common/extensions/docs/server2/server_instance.py
index ba978ceedef86cd7343052aba42e02d028dcd753..5efefe7d506fcafd95a19e37facb65963c269f8c 100644
--- a/chrome/common/extensions/docs/server2/server_instance.py
+++ b/chrome/common/extensions/docs/server2/server_instance.py
@@ -5,14 +5,16 @@
import mimetypes
import os
-STATIC_DIR_PREFIX = 'docs/server2/'
+STATIC_DIR_PREFIX = 'docs/server2'
+DOCS_PREFIX = 'docs'
class ServerInstance(object):
"""This class is used to hold a data source and fetcher for an instance of a
server. Each new branch will get its own ServerInstance.
"""
- def __init__(self, template_data_source, cache_builder):
+ def __init__(self, template_data_source, example_zipper, cache_builder):
self._template_data_source = template_data_source
+ self._example_zipper = example_zipper
self._cache = cache_builder.build(lambda x: x)
mimetypes.init()
@@ -20,7 +22,7 @@ class ServerInstance(object):
"""Fetch a resource in the 'static' directory.
"""
try:
- result = self._cache.get(STATIC_DIR_PREFIX + path)
+ result = self._cache.get(STATIC_DIR_PREFIX + '/' + path)
base, ext = os.path.splitext(path)
request_handler.response.headers['content-type'] = (
mimetypes.types_map[ext])
@@ -29,7 +31,14 @@ class ServerInstance(object):
return ''
def Get(self, path, request_handler):
- if path.startswith('static'):
+ if path.endswith('.zip'):
not at google - send to devlin 2012/07/12 00:22:48 Could be even smarter here: if fnmatch(path, 'exa
cduvall 2012/07/12 01:51:23 Done.
+ content = self._example_zipper[path]
+ request_handler.response.headers['content-type'] = (
+ mimetypes.types_map['.zip'])
+ elif path.startswith('example'):
+ content = self._cache.get(DOCS_PREFIX + '/' + path)
+ request_handler.response.headers['content-type'] = 'text/plain'
not at google - send to devlin 2012/07/12 00:22:48 This has the potential to be pretty cool if we wan
+ elif path.startswith('static'):
content = self._FetchStaticResource(path, request_handler)
else:
content = self._template_data_source.Render(path)

Powered by Google App Engine
This is Rietveld 408576698