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

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

Issue 10834144: Extensions Docs Server: Split apps from extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up Created 8 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 | Annotate | Revision Log
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 sys 7 import sys
8 8
9 from appengine_wrappers import webapp 9 from appengine_wrappers import webapp
10 from appengine_wrappers import memcache 10 from appengine_wrappers import memcache
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 return BRANCH_URL + '/' + branch + '/src' 106 return BRANCH_URL + '/' + branch + '/src'
107 107
108 class Handler(webapp.RequestHandler): 108 class Handler(webapp.RequestHandler):
109 def __init__(self, request, response, local_path=EXTENSIONS_PATH): 109 def __init__(self, request, response, local_path=EXTENSIONS_PATH):
110 self._local_path = local_path 110 self._local_path = local_path
111 super(Handler, self).__init__(request, response) 111 super(Handler, self).__init__(request, response)
112 112
113 def _NavigateToPath(self, path): 113 def _NavigateToPath(self, path):
114 channel_name, real_path = BRANCH_UTILITY.SplitChannelNameFromPath(path) 114 channel_name, real_path = BRANCH_UTILITY.SplitChannelNameFromPath(path)
115 branch = BRANCH_UTILITY.GetBranchNumberForChannelName(channel_name) 115 branch = BRANCH_UTILITY.GetBranchNumberForChannelName(channel_name)
116 if real_path == '': 116 # TODO: Detect that these are directories and serve index.html out of them.
117 real_path = 'index.html' 117 if real_path.strip('/') == 'apps':
118 real_path = 'apps/index.html'
119 if real_path.strip('/') == 'extensions':
120 real_path = 'extensions/index.html'
118 # TODO: This leaks Server instances when branch bumps. 121 # TODO: This leaks Server instances when branch bumps.
119 _GetInstanceForBranch(branch, self._local_path).Get(real_path, 122 _GetInstanceForBranch(branch, self._local_path).Get(real_path,
120 self.request, 123 self.request,
121 self.response) 124 self.response)
122 125
123 def get(self): 126 def get(self):
124 path = self.request.path 127 path = self.request.path
125 if '_ah/warmup' in path: 128 if '_ah/warmup' in path:
126 logging.info('Warmup request.') 129 logging.info('Warmup request.')
127 if DEFAULT_BRANCH != 'local': 130 if DEFAULT_BRANCH != 'local':
128 self._NavigateToPath('trunk/samples.html') 131 self._NavigateToPath('extensions/trunk/samples.html')
129 self._NavigateToPath('dev/samples.html') 132 self._NavigateToPath('extensions/dev/samples.html')
130 self._NavigateToPath('beta/samples.html') 133 self._NavigateToPath('extensions/beta/samples.html')
131 self._NavigateToPath('stable/samples.html') 134 self._NavigateToPath('extensions/stable/samples.html')
132 return 135 return
133 136
134 # Redirect paths like "directory" to "directory/". This is so relative file 137 # Redirect paths like "directory" to "directory/". This is so relative file
135 # paths will know to treat this as a directory. 138 # paths will know to treat this as a directory.
136 if os.path.splitext(path)[1] == '' and path[-1] != '/': 139 if os.path.splitext(path)[1] == '' and path[-1] != '/':
137 self.redirect(path + '/') 140 self.redirect(path + '/')
138 path = path.replace('/chrome/extensions/', '') 141 path = path.replace('/chrome/', '')
139 path = path.strip('/') 142 path = path.strip('/')
140 self._NavigateToPath(path) 143 self._NavigateToPath(path)
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/branch_utility.py ('k') | chrome/common/extensions/docs/server2/integration_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698