| OLD | NEW |
| 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 from StringIO import StringIO | 7 from StringIO import StringIO |
| 8 import sys | 8 import sys |
| 9 | 9 |
| 10 from appengine_wrappers import webapp | 10 from appengine_wrappers import webapp |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 PUBLIC_TEMPLATE_PATH) | 126 PUBLIC_TEMPLATE_PATH) |
| 127 intro_data_source_factory = IntroDataSource.Factory( | 127 intro_data_source_factory = IntroDataSource.Factory( |
| 128 cache_factory, | 128 cache_factory, |
| 129 [INTRO_PATH, ARTICLE_PATH]) | 129 [INTRO_PATH, ARTICLE_PATH]) |
| 130 samples_data_source_factory = SamplesDataSource.Factory( | 130 samples_data_source_factory = SamplesDataSource.Factory( |
| 131 channel_name, | 131 channel_name, |
| 132 file_system, | 132 file_system, |
| 133 GITHUB_FILE_SYSTEM, | 133 GITHUB_FILE_SYSTEM, |
| 134 cache_factory, | 134 cache_factory, |
| 135 GITHUB_COMPILED_FILE_SYSTEM, | 135 GITHUB_COMPILED_FILE_SYSTEM, |
| 136 api_list_data_source_factory, |
| 136 EXAMPLES_PATH) | 137 EXAMPLES_PATH) |
| 137 api_data_source_factory = APIDataSource.Factory(cache_factory, | 138 api_data_source_factory = APIDataSource.Factory(cache_factory, |
| 138 API_PATH, | 139 API_PATH, |
| 139 samples_data_source_factory) | 140 samples_data_source_factory) |
| 140 template_data_source_factory = TemplateDataSource.Factory( | 141 template_data_source_factory = TemplateDataSource.Factory( |
| 141 channel_name, | 142 channel_name, |
| 142 api_data_source_factory, | 143 api_data_source_factory, |
| 143 api_list_data_source_factory, | 144 api_list_data_source_factory, |
| 144 intro_data_source_factory, | 145 intro_data_source_factory, |
| 145 samples_data_source_factory, | 146 samples_data_source_factory, |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 if channel in path: | 323 if channel in path: |
| 323 position = path.index(channel) | 324 position = path.index(channel) |
| 324 path.pop(position) | 325 path.pop(position) |
| 325 path.insert(0, channel) | 326 path.insert(0, channel) |
| 326 newUrl += '/'.join(path) | 327 newUrl += '/'.join(path) |
| 327 self.redirect(newUrl) | 328 self.redirect(newUrl) |
| 328 return True | 329 return True |
| 329 | 330 |
| 330 def get(self): | 331 def get(self): |
| 331 path = self.request.path | 332 path = self.request.path |
| 332 if path == '/favicon.ico' or path == '/robots.txt': | |
| 333 self.response.set_status(404) | |
| 334 return | |
| 335 | |
| 336 if self._RedirectSpecialCases(path): | 333 if self._RedirectSpecialCases(path): |
| 337 return | 334 return |
| 338 | 335 |
| 339 if path.startswith('/cron'): | 336 if path.startswith('/cron'): |
| 340 self._HandleCron(path) | 337 self._HandleCron(path) |
| 341 return | 338 return |
| 342 | 339 |
| 343 # Redirect paths like "directory" to "directory/". This is so relative | 340 # Redirect paths like "directory" to "directory/". This is so relative |
| 344 # file paths will know to treat this as a directory. | 341 # file paths will know to treat this as a directory. |
| 345 if os.path.splitext(path)[1] == '' and path[-1] != '/': | 342 if os.path.splitext(path)[1] == '' and path[-1] != '/': |
| 346 self.redirect(path + '/') | 343 self.redirect(path + '/') |
| 347 return | 344 return |
| 348 | 345 |
| 349 path = path.strip('/') | 346 path = path.strip('/') |
| 350 if not self._RedirectFromCodeDotGoogleDotCom(path): | 347 if not self._RedirectFromCodeDotGoogleDotCom(path): |
| 351 self._HandleGet(path) | 348 self._HandleGet(path) |
| OLD | NEW |