Skip to content

Addons: load_when_embedded config #11765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 18, 2024
Merged

Conversation

humitos
Copy link
Member

@humitos humitos commented Nov 13, 2024

Add an extra addons config to decide whether or not force the injection of addons when the page is embedded (eg. iframe). By default, we are not loading addons if embedded.

Required by readthedocs/addons#415
Closes readthedocs/addons#412

@humitos humitos requested a review from a team as a code owner November 13, 2024 11:43
@humitos humitos requested a review from stsewd November 13, 2024 11:43
@humitos humitos requested review from agjohnson and removed request for stsewd November 13, 2024 11:44
@humitos humitos force-pushed the humitos/addons-embedded-http-header branch from 00bcd15 to 0fe2246 Compare November 13, 2024 12:03
Add an extra addons config to decide whether or not force the injection of
addons when the page is embedded (eg. iframe). By default, we are not loading
addons if embedded.

Required by readthedocs/addons#415
Closes readthedocs/addons#412
@humitos humitos changed the title Addons: add X-RTD-Load-Addons-When-Embedded HTTP header Addons: load_when_embedded config Nov 13, 2024
@humitos humitos force-pushed the humitos/addons-embedded-http-header branch from 0fe2246 to 7095954 Compare November 13, 2024 12:43
Copy link
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just a note on naming.

We talked about giving users a way to inject a JavaScript file they
control using our Cloudflare Worker infrastructure to allow them
manipulate frozen documentations.

This could be used in different ways to fix bugs or add features to a
particular frozen set of docs or even to all the versions. The user can
make usage of API data to filter by version or not
(e.g. `if (versions.current == "v3.0") { .. do something ...} `)

The script could live in Read the Docs itself using a relative URL, or
outside it, using an absolute URL.


### Example using Sphinx

1. [Tell Sphinx to include `static`
folder](https://github.com/readthedocs/test-builds/blob/full-feature/docs/conf.py#L25)
2. [Include a `readthedocs.js` file in your
project](https://github.com/readthedocs/test-builds/blob/full-feature/docs/static/readthedocs.js)
3. Make `AddonsConfig.userjsfile_src` to be
`/en/full-feature/readthedocs.js` from addons admin UX

The console will render the following:


![Screenshot_2024-11-11_18-13-59](https://github.com/user-attachments/assets/9fa46525-3b20-4d88-9950-f0a93a1199ab)

Related #11474
Related readthedocs/addons#431
Comment on lines 124 to 126
"configs": {
"load_when_embedded": false
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.com tests will probably need to be updated

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm, I don't think we have this file in .com. At least, I didn't find it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have two files in tests/responses/addons/

@humitos humitos enabled auto-merge (squash) November 18, 2024 16:36
…thedocs/readthedocs.org into humitos/addons-embedded-http-header
@humitos humitos merged commit 13679ad into main Nov 18, 2024
5 checks passed
@humitos humitos deleted the humitos/addons-embedded-http-header branch November 18, 2024 16:54
Copy link

sentry-io bot commented Nov 19, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ ProgrammingError: column projects_addonsconfig.options_load_when_embedded does not exist /{path} View Issue

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplication of fly-out and banners
3 participants