-
Notifications
You must be signed in to change notification settings - Fork 7
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
Flyout: link to change version drops page name #211
Flyout: link to change version drops page name #211
Comments
Actually, to expand on this, I've noticed a couple issues with both of our flyout menus, so I'll note them all and we can work forward here. Our old flyout also doesn't handle the locale links correctly after switching versions. That is:
I'm also going to guess that the page name is dropped from the locale switcher links too. |
I made this decision on purpose mainly because we can't guarantee that the page will exist in the other version (or language) and when clicking on these links the user will see a 404. So, it makes more sense to switch to the "homepage of the version/language" There is more context in readthedocs/readthedocs.org#10102 I think both approaches have pros and cons and I decided to go with the simplest use case for now until we can have a better UX for users. If we want to implement "See this page in |
It seems that Material for MkDocs has arrived to the same conclusion: squidfunk/mkdocs-material#4835 The behavior described seems to be: "Stay on the same page only if that same page exists. Otherwise, go to the homepage." I'd like to see how the implemented UX is, because it could be pretty confusing as well if there is no indication that there is no translation/version for the page. I think this opens the door to improve the UX on the front-end side without backend intervention maybe. The front-end could listen to the
I'm not sure what's the best UX here yet, but I think this is probably a good direction to discuss more. |
Explicit comment about this: squidfunk/mkdocs-material#4835 (comment) |
Yeah, I figured that was the reason behind this. I think losing the page entirely is rather confusing UX, and users would encounter losing the page URL more commonly than hitting a missing page when switching versions. I think we optimize for the more common case here instead.
Yeah, this would be ideal UX. I think we can easily do this from the backend. Proxito can redirect to the relative root if a missing page is encountered -- that is, we might link to Doing it from the front end is probably okay too, but I might be worried about edge cases like potential cross domain requests or handling existing redirects. I still think we should lean towards writing backend code when we can too.
I think if we implemented anything like that, the UX should match the flyout. I'd focus on the UX at the flyout first before making any features that might conflict though. I'm not yet convinced we even need to implement a secondary form of language/version switching. The user/theme can always implement something like if needed. An overlap here might be a user feature that warns when the page name doesn't match the referring page name -- "The page you requested does not exist so we're showing you the home page instead". Something to give the user explicit information about what just happened. |
Also, note #223 points out the same issue as here. I feel this is going to be a pretty expected UX. |
I would also prefer it to keep the page structure when changing versions. For example, that's what the custom switcher currently used by https://docs.python.org. Here's some transitions when changing version and language:
If a page isn't found in the destination version, it shows the homepage: |
It seems like the decision we need to make here is just which pattern we should use:
I lean towards a Proxito solution because I think we can be more precise about the redirect with application logic. The application can tell where to redirect the request to directly, where a JavaScript solution would need to do a series of guesses to come to the same conclusion. And we avoid any browser blocking and CORS side headaches. @humitos do you have more opinions here? |
Yeah, Proxito solution seems to be the most accurate, easier to maintain and gives us more control over time.
One problem that I see with this implementation is that we will loose the per-project cached flyout response and it will become per-page instead, degrading the performance of addons a lot. This is because the resolver will need to act over the filename of the current page instead: https://github.com/readthedocs/readthedocs.org/blob/3cfc29be8add5a0cf37d795e1c189d8aaa22a069/readthedocs/proxito/views/hosting.py#L350-L374 We may need a way to "resolve" the URL in the front-end, or communicate this to the backend somehow. Maybe we need to change the approach here and the URLs from the flyout need to be different:
Would this approach solve this issue without affecting our per-project cached flyout responses? Footnotes
|
If we resolve the URL in the flyout API, I see this being a problem as well. I don't think we want to do this due to the cost of the resolver logic, even with caching.
I think you're describing the pattern I was here. I was thinking we don't do anything different with the flyout response but would wait for the reader to click a link instead. That is, the flyout version/translation URLs would be naive and just simple text concatenation instead of using the resolver in the initial API response. To avoid magic at Proxito we probably should have a dedicated endpoint, or should include some query parameter like what you're describing or simply |
I don't like too much the idea of using the same URL than a regular docs URL with I'd avoid the implicit arguments like IMO, the most technically accurate solution is a the API endpoint because that will give us lot of flexibility and re-usability as well. However, from that pattern I don't like the idea of using an API URL in the flyout as document.querySelector("#spanish-translation").addEventListener("click", () => {
const params = {
"url": window.location.href,
"language": "es",
}
fetch("/_/api/v3/redirect/", params, (data) => {
window.location.href = data.redirect_to;
});
}); I think this is a good compromise from our side:
@agjohnson What do you think? I'm on the fence between this solution and using
|
Yeah, prepending That is, the link URLs in the flyout would be:
Instead of using the current version/language as the URL:
Using the actual URL seems less confusing than URLs with multiple languages/versions -- once in the URL and once in the query params. The URL on hover would (almost all of the time) match the URL the user will end at after clicking the link.
I'm not so sure on this yet. If we aren't using the response from this request, then it feels like a mismatch for our API maybe. We have needed in places to work around the resolver response time, usually relying on URLs returned from established API endpoints. Instead of using application code from the templates to resolve a URL to a version/page, UI elements capture point-in-time use of these links (on hover/click) and instead hit an API to get the resolver response. This is basically what you are describing with the second option. However, I can't think of any place we still need generic access to a resolver API though. But it's worth noting, as if we did need this still, there would be multiple uses for a generic API like this. |
OK, I think you convinced me about this 😄 . I will add this issue to the roadmap and the next sprint. |
@agjohnson what do you think about the following issues? Can you comment there? I think we can tackle the three of them at the same time: |
The anchor in #131 would be a new feature of both flyouts, but would be nice to have eventually. I see it not being a huge feature on top of parsing and building link URLs though, so it might be worth giving a quick try at. I'd say use your judgement there, bail out if it feels like too much work. #130 seems like what I noticed above too, and would be a good issue to address at the same time.
I will say that my suggestion is still just a guess, and I don't dislike the other solutions we've discussed here so far. I might not being considering the API response as deeply as I should either. I'm assuming we won't have trouble building URLs in JS with data from the API response. Thinking a little more, I could see generating version/language specific URLs in the response might require a per-version/language cached API response instead of per-project -- but at least that is far better than per-page. |
Ideas for implementation here:
We should add a GET argument onto the URL ( We could pass the data in the file similarly to the Sphinx extension, which currently outputs this during Sphinx builds:
|
Return `X-RTD-Resolver-Filename` from El Proxito and inject it as HTML `meta` tag from Cloudflare Worker. Required by readthedocs/addons#211
Return `X-RTD-Resolver-Filename` from El Proxito and inject it as HTML `meta` tag from Cloudflare Worker. Required by readthedocs/addons#211
…11100) * Development: use `wrangler` locally (update NGINX/Dockerfile config) Related readthedocs/addons#217 * Add CF Worker .js script * Proxy JS files to Addons GitHub's repository * Point common to wrangler branch * Addons + Proxito: return `X-RTD-Resolver-Filename` and inject via CF Return `X-RTD-Resolver-Filename` from El Proxito and inject it as HTML `meta` tag from Cloudflare Worker. Required by readthedocs/addons#211 * Feedback from review * Validate the header value before injecting it * Initialize `request.unresolved_url` as `None` * Add test for longer filename * Inject the `unresolved_url` on 404 pages
Backend changes are good, #242 is close, reopening this to track that. |
We lost this work when moving the `.js` file from the ops repository into community and then again to common. This is required to be deployed together with addons 0.10.0. Related: * readthedocs/readthedocs.org#11126 * readthedocs/addons#211
This change is deployed. Now, switching between versions/languages from the flyout addons will keep the page the user is looking at on the version/language destination. |
We lost this work when moving the `.js` file from the ops repository into community and then again to common. This is required to be deployed together with addons 0.10.0. Related: * readthedocs/readthedocs.org#11126 * readthedocs/addons#211
Tested it and it works 🙏 Thank you folks! |
Noticed here:
https://docs.astropy.org/en/stable/coordinates/inplace.html
The versions should all link to
/en/{version}/coordinates/inplace.html
. They link to/en/{version}/
instead.The text was updated successfully, but these errors were encountered: