Skip to content

Commit

Permalink
Addons: prepare the backend for the new flyout
Browse files Browse the repository at this point in the history
Return `addons.flyout.translations` and `addons.flyout.downloads`.
Remove `addons.flyout.vcs` for now because we don't have a reliable way to
implement it without injecting data into the build which we don't want to do
anymore.

Related readthedocs/addons#86
  • Loading branch information
humitos committed Aug 21, 2023
1 parent ac9fa94 commit a2a24e4
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions readthedocs/proxito/views/hosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ def _v0(self, project, version, build, filename):
.only("slug")
.order_by("slug")
)
project_translations = (
project.translations.all().only("language").order_by("language")
)

data = {
"comment": (
Expand Down Expand Up @@ -250,23 +253,47 @@ def _v0(self, project, version, build, filename):
"base_page": "",
},
"flyout": {
"translations": [],
"enabled": True,
"translations": [
{
# TODO: name this field "display_name"
"slug": translation.language,
"url": f"/{translation.language}/",
}
for translation in project_translations
],
"versions": [
{
# TODO: name this field "display_name"
"slug": version.slug,
"url": f"/{project.language}/{version.slug}/",
}
for version in versions_active_built
],
"downloads": [],
# TODO: get this values properly
"vcs": {
"url": "https://github.com",
"username": "readthedocs",
"repository": "test-builds",
"branch": version.identifier if version else None,
"filepath": "/docs/index.rst",
},
"downloads": [
{
# TODO: name this field "display_name"
"name": name,
"url": url,
}
for name, url in version.get_downloads(pretty=True).items()
],
# TODO: find a way to get this data in a reliably way.
# We don't have a simple way to map a URL to a file in the repository.
# This feature may be deprecated/removed in this implementation since it relies
# on data injected at build time and sent as `docroot=`, `source_suffix=` and `page=`.
# Example URL:
# /_/api/v2/footer_html/?project=weblate&version=latest&page=index&theme=furo&docroot=/docs/&source_suffix=.rst
# Data injected at:
# https://github.com/rtfd/readthedocs-sphinx-ext/blob/7c60d1646c12ac0b83d61abfbdd5bcd77d324124/readthedocs_ext/_templates/readthedocs-insert.html.tmpl#L23
#
# "vcs": {
# "url": "https://github.com",
# "username": "readthedocs",
# "repository": "test-builds",
# "branch": version.identifier if version else None,
# "filepath": "/docs/index.rst",
# },
},
"search": {
"enabled": True,
Expand Down

0 comments on commit a2a24e4

Please sign in to comment.