OLD | NEW |
1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import logging | 5 import logging |
6 import re | 6 import re |
7 import json | 7 import json |
8 from webapp2 import * | 8 from webapp2 import * |
9 from datetime import datetime, timedelta | 9 from datetime import datetime, timedelta |
10 from google.appengine.ext import blobstore | 10 from google.appengine.ext import blobstore |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 291 |
292 self.error(404) | 292 self.error(404) |
293 | 293 |
294 def redir_bare_lib_name(handler, *args, **kwargs): | 294 def redir_bare_lib_name(handler, *args, **kwargs): |
295 version = kwargs['version'] | 295 version = kwargs['version'] |
296 libname = kwargs['libname'] | 296 libname = kwargs['libname'] |
297 | 297 |
298 # /1.12.0/dart-async => /1.12.0/dart-async/dart-async-library.html | 298 # /1.12.0/dart-async => /1.12.0/dart-async/dart-async-library.html |
299 return '/%s/dart-%s/dart-%s-library.html' % (version, libname, libname) | 299 return '/%s/dart-%s/dart-%s-library.html' % (version, libname, libname) |
300 | 300 |
| 301 # /dart_core.html => /stable/dart-core/dart-core-library.html |
| 302 def redir_legacy_lib(handler, *args, **kwargs): |
| 303 libname = kwargs['libname'] |
| 304 return '/stable/dart-%s/dart-%s-library.html' % (libname, libname) |
| 305 |
| 306 # /dart_core/Iterable.html => /stable/dart-core/Iterable-class.html |
| 307 def redir_legacy_lib_class(handler, *args, **kwargs): |
| 308 libname = kwargs['libname'] |
| 309 classname = kwargs['classname'] |
| 310 return '/stable/dart-%s/%s-class.html' % (libname, classname) |
| 311 |
301 application = WSGIApplication( | 312 application = WSGIApplication( |
302 [ | 313 [ |
303 # Legacy URL redirection schemes. | 314 # Legacy URL redirection schemes. |
304 # Redirect all old URL package requests to our updated URL scheme. | 315 # Redirect all old URL package requests to our updated URL scheme. |
305 # TODO(efortuna): Remove this line when pkg gets moved off of | 316 # TODO(efortuna): Remove this line when pkg gets moved off of |
306 # api.dartlang.org. | 317 # api.dartlang.org. |
307 Route('/docs/pkg/<pkg:args|crypto|custom_element|fixnum|http_server|intl|' | 318 Route('/docs/pkg/<pkg:args|crypto|custom_element|fixnum|http_server|intl|' |
308 'json|logging|matcher|mime|mock|observe|path|polymer|' | 319 'json|logging|matcher|mime|mock|observe|path|polymer|' |
309 'polymer_expressions|sequence_zip|serialization|source_maps|' | 320 'polymer_expressions|sequence_zip|serialization|source_maps|' |
310 'template_binding|unittest|unmodifiable_collection|utf><:/?>', | 321 'template_binding|unittest|unmodifiable_collection|utf><:/?>', |
(...skipping 21 matching lines...) Expand all Loading... |
332 Route('/bleeding_edge', RedirectHandler, | 343 Route('/bleeding_edge', RedirectHandler, |
333 defaults={'_uri': '/be'}), | 344 defaults={'_uri': '/be'}), |
334 | 345 |
335 Route('/stable/latest', RedirectHandler, | 346 Route('/stable/latest', RedirectHandler, |
336 defaults={'_uri': '/stable'}), | 347 defaults={'_uri': '/stable'}), |
337 Route('/dev/latest', RedirectHandler, | 348 Route('/dev/latest', RedirectHandler, |
338 defaults={'_uri': '/dev'}), | 349 defaults={'_uri': '/dev'}), |
339 Route('/be/latest', RedirectHandler, | 350 Route('/be/latest', RedirectHandler, |
340 defaults={'_uri': '/be'}), | 351 defaults={'_uri': '/be'}), |
341 | 352 |
| 353 Route('/dart_<libname:[\w]+>.html', RedirectHandler, |
| 354 defaults={'_uri': redir_legacy_lib}), |
| 355 |
| 356 Route('/dart_<libname:[\w]+>/<classname:[\w]+>.html', RedirectHandler, |
| 357 defaults={'_uri': redir_legacy_lib_class}), |
| 358 |
342 # temp routing till stable docs are rolled out | 359 # temp routing till stable docs are rolled out |
343 Route('/stable', RedirectHandler, | 360 Route('/stable', RedirectHandler, |
344 defaults={'_uri': redir_stable_latest}), #ApiDocs), | 361 defaults={'_uri': redir_stable_latest}), #ApiDocs), |
345 Route('/dev', RedirectHandler, | 362 Route('/dev', RedirectHandler, |
346 defaults={'_uri': redir_dev_latest}), #ApiDocs), | 363 defaults={'_uri': redir_dev_latest}), #ApiDocs), |
347 Route('/be', RedirectHandler, | 364 Route('/be', RedirectHandler, |
348 defaults={'_uri': redir_be_latest}),#ApiDocs), | 365 defaults={'_uri': redir_be_latest}),#ApiDocs), |
349 | 366 |
350 Route('/stable<path:.*>', RedirectHandler, | 367 Route('/stable<path:.*>', RedirectHandler, |
351 defaults={'_uri': redir_stable_path}), | 368 defaults={'_uri': redir_stable_path}), |
(...skipping 26 matching lines...) Expand all Loading... |
378 defaults={'_uri': '/stable'}), | 395 defaults={'_uri': '/stable'}), |
379 | 396 |
380 Route('/<version:[\w.-]+>/dart-<libname:\w+>', RedirectHandler, | 397 Route('/<version:[\w.-]+>/dart-<libname:\w+>', RedirectHandler, |
381 defaults={'_uri': redir_bare_lib_name}), | 398 defaults={'_uri': redir_bare_lib_name}), |
382 | 399 |
383 Route('/', RedirectHandler, defaults={'_uri': '/stable'}), | 400 Route('/', RedirectHandler, defaults={'_uri': '/stable'}), |
384 | 401 |
385 Route('<path:.*>', ApiDocs) | 402 Route('<path:.*>', ApiDocs) |
386 ], | 403 ], |
387 debug=True) | 404 debug=True) |
OLD | NEW |