Skip to content

Commit 7383ada

Browse files
committed
Update get_absolute_url for External Versions
This allows us to properly set a new domain in production for the external version hosting. It's a bit hacky for now, mostly because we don't have a way to specify HTML or PDF versions of the external versions. We will need to think more about the UX around multiple types, but that's also an existing issue with our current doc builds (we only link to HTML).
1 parent f20e659 commit 7383ada

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,11 @@ 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+
return f"{settings.EXTERNAL_VERSION_URL}/html/{self.project.slug}/{self.slug}/index.html"
276281
if not self.built and not self.uploaded:
277282
return reverse(
278283
'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)