Skip to content

Commit 3319558

Browse files
committed
Support single version subprojects URLs to serve from Django
1 parent 843ce09 commit 3319558

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

readthedocs/core/urls/subdomain.py

+12
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@
4646
serve_docs,
4747
name='docs_detail',
4848
),
49+
50+
# Special case for single-version subprojects
51+
# docs.customdomain.org/projects/subproject/_static/readthedocs-data.js
52+
# docs.customdomain.org/projects/subproject/chapter/section/page.html
53+
url(
54+
(
55+
r'^projects/(?P<subproject_slug>{project_slug})/'
56+
r'(?P<filename>{filename_slug})$'.format(**pattern_opts)
57+
),
58+
serve_docs,
59+
name='docs_detail_singleversion_subproject',
60+
),
4961
]
5062

5163
groups = [subdomain_urls]

readthedocs/core/views/serve.py

+8
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ def inner_view( # noqa
110110
def redirect_project_slug(request, project, subproject): # pylint: disable=unused-argument
111111
"""Handle / -> /en/latest/ directs on subdomains."""
112112
urlparse_result = urlparse(request.get_full_path())
113+
114+
# When accessing docs.customdomain.org/projects/subproject/ and the
115+
# ``subproject`` is a single-version, we don't have to redirect but to serve
116+
# the index file instead.
117+
if subproject and subproject.single_version:
118+
# TODO: find a way to import ``serve_docs`` from corporate
119+
return serve_docs(request, project, project.slug, subproject, subproject.slug)
120+
113121
return HttpResponseRedirect(
114122
resolve(
115123
subproject or project,

0 commit comments

Comments
 (0)