Permalink
Browse files

Add language REGEX

  • Loading branch information...
1 parent 25a6101 commit 04127d9a5623e99fff62e85edc6ea3089a1bfcb6 @ericholscher ericholscher committed Mar 18, 2013
Showing with 8 additions and 1 deletion.
  1. +6 −0 readthedocs/projects/constants.py
  2. +2 −1 readthedocs/urls.py
@@ -2,6 +2,8 @@
including available theme names and repository types.
"""
+import re
+
from django.utils.translation import ugettext_lazy as _
THEME_DEFAULT = 'default'
@@ -128,3 +130,7 @@
("zh_CN", "Simplified Chinese"),
("zh_TW", "Traditional Chinese"),
)
+
+LANGUAGES_REGEX = "|".join(
+ [re.escape(code[0]) for code in LANGUAGES]
+)
View
@@ -11,6 +11,7 @@
from core.views import SearchView
from projects.feeds import LatestProjectsFeed, NewProjectsFeed
from projects.filters import ProjectFilter
+from projects.constants import LANGUAGES_REGEX
v1_api = Api(api_name='v1')
v1_api.register(BuildResource())
@@ -29,7 +30,7 @@
url(r'^security/', direct_to_template, {'template': 'security.html'}),
# For serving docs locally and when nginx isn't
- url(r'^docs/(?P<project_slug>[-\w]+)/(?P<lang_slug>en)/(?P<version_slug>[-._\w]+?)/(?P<filename>.*)$',
+ url(r'^docs/(?P<project_slug>[-\w]+)/(?P<lang_slug>%s)/(?P<version_slug>[-._\w]+?)/(?P<filename>.*)$' % LANGUAGES_REGEX,
'core.views.serve_docs',
name='docs_detail'
),

0 comments on commit 04127d9

Please sign in to comment.