-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Addons: integrate with new beta addons flyout #1526
Open
humitos
wants to merge
23
commits into
master
Choose a base branch
from
humitos/addons-flyout
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
c1ea98e
Addons: integrate with new beta addons flyout
humitos 476abbd
`READTHEDOCS` variable has to be passed to the `html_context`
humitos 09c6a18
Update code to match the latest changes
humitos bc09448
Use `.join` to avoid rendering the Array with `,`
humitos 71c978e
Update code to use the v1 API structure response
humitos 70f94e1
Don't auto-remove the original flyout
humitos f6edac2
Join the values to avoid strange `,`s
humitos 04d7909
Support translations
humitos 775addd
Remove HTML tags for testing
humitos e068ac2
Merge branch 'master' into humitos/addons-flyout
humitos cb78b36
Show "Search" section on flyout
humitos 577f5a6
Render footer
humitos 6140050
Add some styling
humitos 92f65aa
TODO comments to work on
humitos 7a743bb
add `div.injected`
humitos 7671e07
Apply suggestions from code review
humitos 356cd80
Translate privacy policy
humitos 0033307
Add `.rtd-current-item` class to selected version/language
humitos ef0a57e
Refactor code to show sections only if there is content
humitos ecebe4c
Epub instead of EPUB for backward compatibility
humitos c805605
Show the modal when clicking on the "Search docs" from navbar
humitos 131de0d
Remove privacy policy link from flyout
humitos 53e32c6
Add UTM analytics
humitos File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,47 @@ | ||
{% if READTHEDOCS %} | ||
{# Add rst-badge after rst-versions for small badge style. #} | ||
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="{{ _('Versions') }}"> | ||
<script async type="text/javascript" src="http://localhost:8000/readthedocs-addons.js"></script> | ||
<script type="text/javascript"> | ||
document.addEventListener("readthedocs-addons-data-ready", function(event) { | ||
const config = event.detail; | ||
|
||
const flyout = ` | ||
humitos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<div class="rst-versions" data-toggle="rst-versions" role="note"> | ||
<span class="rst-current-version" data-toggle="rst-current-version"> | ||
<span class="fa fa-book"> Read the Docs</span> | ||
v: {{ current_version }} | ||
v: ${ config.versions.current.slug } | ||
<span class="fa fa-caret-down"></span> | ||
</span> | ||
<div class="rst-other-versions"> | ||
<dl> | ||
<dt>{{ _('Versions') }}</dt> | ||
{% for slug, url in versions %} | ||
<dd><a href="{{ url }}">{{ slug }}</a></dd> | ||
{% endfor %} | ||
<dt>Languages</dt> | ||
${ config.addons.flyout.translations.map( | ||
(language) => `<dd><a href="${ language.url }">${ language.slug }</a></dd>`).join("\n")} | ||
</dl> | ||
<dl> | ||
<dt>{{ _('Downloads') }}</dt> | ||
{% for type, url in downloads %} | ||
<dd><a href="{{ url }}">{{ type }}</a></dd> | ||
{% endfor %} | ||
<dt>Versions</dt> | ||
${ config.addons.flyout.versions.map( | ||
(version) => `<dd><a href="${ version.url }">${ version.slug }</a></dd>`).join("\n")} | ||
</dl> | ||
<dl> | ||
{# Translators: The phrase "Read the Docs" is not translated #} | ||
<dt>{{ _('On Read the Docs') }}</dt> | ||
<dt>Downloads</dt> | ||
${ config.addons.flyout.downloads.map( | ||
(download) => `<dd><a href="${ download.url }">${ download.name }</a></dd>`).join("\n")} | ||
</dl> | ||
<dl> | ||
<dt>On Read the Docs</dt> | ||
<dd> | ||
<a href="//{{ PRODUCTION_DOMAIN }}/projects/{{ slug }}/?fromdocs={{ slug }}">{{ _('Project Home') }}</a> | ||
<a href="//${ config.domains.dashboard }/projects/${ config.projects.current.slug }/">Project Home</a> | ||
</dd> | ||
<dd> | ||
<a href="//{{ PRODUCTION_DOMAIN }}/builds/{{ slug }}/?fromdocs={{ slug }}">{{ _('Builds') }}</a> | ||
<a href="//${ config.domains.dashboard }/projects/${ config.projects.current.slug }/builds/">Builds</a> | ||
</dd> | ||
</dl> | ||
</div> | ||
</div> | ||
{% endif %} | ||
`; | ||
|
||
document.body.insertAdjacentHTML("beforeend", flyout); | ||
|
||
{# TODO: disable the flyout auto-injected by `readthedocs-addons.js` somehow #} | ||
document.querySelector("readthedocs-flyout").remove(); | ||
humitos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
</script> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to above, we should no longer be using inline
script
for our code, it should go in our JS sources. Inline scripts and styles are one of the largest points for XSS, we should start a beta release from a solid base.