Skip to content

Commit

Permalink
Addons: expose readthedocs.resolver.filename in the API response
Browse files Browse the repository at this point in the history
This is required to be able to dynamically update the URLs from the versions in
the flyout when the page is changed using `history` object (without reloading /
SPA) as Docusaurus does.

In that scenario we cannot use the HTML META tag because it was injected with
the old value by CF Worker. Note that the CF Worker is not run after the initial
request on SPA.

The addons frontend will use this attribute to update those URLs accordingly
when the URL changes.

Required by:
* readthedocs/addons#504
  • Loading branch information
humitos committed Jan 22, 2025
1 parent aa0b4d1 commit f94f5aa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions readthedocs/proxito/views/hosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from django.contrib.auth.models import AnonymousUser
from django.http import Http404, JsonResponse
from django.shortcuts import get_object_or_404
from django.utils.encoding import iri_to_uri
from django.utils.html import escape
from rest_framework import permissions
from rest_framework.renderers import JSONRenderer
from rest_framework.views import APIView
Expand Down Expand Up @@ -452,6 +454,9 @@ def _v1(self, project, version, build, filename, url, request):
"analytics": {
"code": settings.GLOBAL_ANALYTICS_CODE,
},
"resolver": {
"filename": escape(iri_to_uri(filename)),
},
},
# TODO: the ``features`` is not polished and we expect to change drastically.
# Mainly, all the fields including a Project, Version or Build will use the exact same
Expand Down

0 comments on commit f94f5aa

Please sign in to comment.