PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/r2/r2/config/rewrites.py

https://github.com/stevewilber/reddit
Python | 32 lines | 6 code | 3 blank | 23 comment | 1 complexity | e00b49d42f853edc74fa9c37775c0b69 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, Apache-2.0
  1. # The contents of this file are subject to the Common Public Attribution
  2. # License Version 1.0. (the "License"); you may not use this file except in
  3. # compliance with the License. You may obtain a copy of the License at
  4. # http://code.reddit.com/LICENSE. The License is based on the Mozilla Public
  5. # License Version 1.1, but Sections 14 and 15 have been added to cover use of
  6. # software over a computer network and provide for limited attribution for the
  7. # Original Developer. In addition, Exhibit A has been modified to be consistent
  8. # with Exhibit B.
  9. #
  10. # Software distributed under the License is distributed on an "AS IS" basis,
  11. # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  12. # the specific language governing rights and limitations under the License.
  13. #
  14. # The Original Code is reddit.
  15. #
  16. # The Original Developer is the Initial Developer. The Initial Developer of
  17. # the Original Code is reddit Inc.
  18. #
  19. # All portions of the code written by reddit are Copyright (c) 2006-2012 reddit
  20. # Inc. All Rights Reserved.
  21. ###############################################################################
  22. import re
  23. rewrites = (#these first two rules prevent the .embed rewrite from
  24. #breaking other js that should work
  25. ("\A/_(.*)", "/_$1"),
  26. ("\A/static/(.*\.js)", "/static/$1"),
  27. #This next rewrite makes it so that all the embed stuff works.
  28. ("\A(.*)(?<!button)(?<!buttonlite)(\.js)\Z", "$1.embed"))
  29. rewrites = tuple((re.compile(r[0]), r[1]) for r in rewrites)