Skip to content

Commit 2b470e4

Browse files
authored
Merge pull request #6020 from readthedocs/external-version-url-update
Update get_absolute_url for External Versions
2 parents 2444c8e + 4d57b4b commit 2b470e4

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

docs/development/settings.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,13 @@ project and build documentations without having elasticsearch.
180180

181181

182182
.. _elasticsearch-dsl-py.connections.configure: https://elasticsearch-dsl.readthedocs.io/en/stable/configuration.html#multiple-clusters
183+
184+
EXTERNAL_VERSION_URL
185+
--------------------
186+
187+
Default: ``None``
188+
189+
The URL where we host external version builds (Pull Requests).
190+
Set this to the URL where the static files are uploaded to,
191+
with a prefix of `/external/`,
192+
to make it work.

readthedocs/builds/models.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,16 @@ def commit_name(self):
273273
return self.identifier
274274

275275
def get_absolute_url(self):
276+
# Hack external versions for now.
277+
# TODO: We can integrate them into the resolver
278+
# but this is much simpler to handle since we only link them a couple places for now
279+
if self.type == EXTERNAL:
280+
url = f'{settings.EXTERNAL_VERSION_URL}/html/' \
281+
f'{self.project.slug}/{self.slug}/'
282+
# Django's static file serving doesn't automatically append index.html
283+
if settings.DEBUG:
284+
url += 'index.html'
285+
return url
276286
if not self.built and not self.uploaded:
277287
return reverse(
278288
'project_version_detail',

readthedocs/settings/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class CommunityBaseSettings(Settings):
4141
PUBLIC_DOMAIN_USES_HTTPS = False
4242
USE_SUBDOMAIN = False
4343
PUBLIC_API_URL = 'https://{}'.format(PRODUCTION_DOMAIN)
44+
EXTERNAL_VERSION_URL = None # for pull request builds
4445

4546
# Doc Builder Backends
4647
MKDOCS_BACKEND = 'readthedocs.doc_builder.backends.mkdocs'

readthedocs/settings/dev.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ def DATABASES(self): # noqa
3232
SLUMBER_API_HOST = 'http://127.0.0.1:8000'
3333
PUBLIC_API_URL = 'http://127.0.0.1:8000'
3434

35+
EXTERNAL_VERSION_URL = 'http://127.0.0.1:8000/static/external'
36+
3537
BROKER_URL = 'redis://localhost:6379/0'
3638
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
3739
CELERY_RESULT_SERIALIZER = 'json'

0 commit comments

Comments
 (0)