-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Auto-fill missing leading 0
s in URL
#2420
Comments
I have a more general solution I'd like to try, but won't be immediate (timeframe of weeks not days). What's the urgency on this? A |
The migration to GitHub Issues should happen at the end of the months, but PEP autolinking is not high priority -- the autolinking could be disabled until a fix is in place. Just out of curiosity, what kind of solution are you thinking about? |
Two approaches to try -- the first would create a dummy file for each PEP with the zeros stripped (e.g. The entire PEPs website doesn't require JS at all though (except for a toggle button for colour schemes), so I want to avoid the second approach. A |
I can see three possible ways of using the dummy files:
The downside of these approaches is that they will create a lot of dummy files, and it will still fail with e.g. PEP-008 or similar. If you have access to the webserver, you could also configure HTTP redirects or use URL rewrite, but I'm not sure if this is possible with the current setup. I appreciate the intent of keeping the repo as JS-free as possible, but I think having some JS in the 404 page is ok: if people have JS disabled and click on a broken link they will meet the same 404 page they always met; if they have JS enabled they will get redirected. Adding a link to the PEP index to the 404 page will also help people without JS to reach the index and from there it's easy enough to |
Rather than running JavaScript client-side (not everyone has JS enabled, it's relatively slow, more code to maintain), how about Nginx server redirect rules (similar to python/pythondotorg#2006) that will update the URL before even hitting the GitHub Pages/RTD website? Something along the lines of:
(See also https://stackoverflow.com/a/27504007/724176) Ping also @ewdurbin for comment :) |
I'll respond to @ezio-melotti's point from #2421 (comment) here too. My general concern is that whatever we support we will have to support forever, as links will start to propogate with non-canonical forms. Allowing
The original rationale was that barely anybody writes the leading zeros, so for e.g.
For me with awful internet, it still is fairly fast -- I put the redirect script at the top of
I don't think A |
If that's an option, I think it would be ok. Let's see what @ewdurbin says about that :)
The concern is understandable, but wouldn't this introduce a new type of URL (without the |
This originally came up in #2255 . To note, the canonical way of referencing PEPs in prose text, as defined by PEP 1 and PEP 12, is with no leading zeros and a space instead of a dash. As GitHub apparently does not allow spaces (or requires a dash) in references, it was decided there that requiring the leading zeros too was acceptable, since it made more clear that the number was a GitHub autolink reference rather than a canonical PEP name, to avoid confusing others about the canonical way of referring to PEPs themselves. I typically do so like this: As in PEP 8 (PEP-0008). That said, if we do add a new URL form, which the non-leading-zero form already is, I would support the shorter and more distinct It could be done all in HTML without either JavaScript or server-side redirect rules by using |
#2421 now takes the A |
Ah right, peps.python.org goes straight to GitHub Pages (https://hostingchecker.com): And not into the same place as python.org: So these server redirects aren't possible. |
Depending on what decision is made as far as what the best course of action is, we can move peps.python.org behind Fastly and support redirects. |
Nice, that sounds best to me, we ran into some problems with #2421. We'd actually want something like:
So @CAM-Gerlach @ezio-melotti Is this pattern right? Shall we move peps.python.org behind Fastly and use redirects? |
That's what @AA-Turner preferred and I thought it sounded reasonable, since it is shorter and more distinct, but I'm not sure @ezio-melotti agreed. The main problem with #2421 was that |
Sounds like @CAM-Gerlach, @AA-Turner and I are in agreement with this and @ezio-melotti doesn't mind on the actual solution as long as it works. @ewdurbin Please could you go ahead with this? I've edited the suggestion in #2420 (comment) to include a trailing slash on the target, because
I believe server redirects avoids the problem entirely. The user types in |
What happens if the users tries https://peps.python.org/123 ? |
It would match this rule:
Fastly would do this:
And then GitHub Pages will show The problem with #2421 was internal to the website/Sphinx, but with Fastly redirects we're getting the proper redirect URL before the website itself is even loaded. |
I will proceed with this next week! |
Thanks @ewdurbin ! |
Do we actually still even need the |
@brettcannon Indeed, that's exactly what we're proposing to do, and AFAIK what @ewdurbin agreed to implement :) |
@ewdurbin, what's the status on this? |
Ironically it's been deprioritized by the hiring process for another Infrastructure team member. I should have time to sit down with this and #2493 tomorrow. |
Thanks for the update! The migration to GitHub Issues is scheduled for tomorrow, so the timing is perfect :) |
Lost time to work on this... due to the GitHub issues migration... perhaps this weekend but likely next week. |
peps.python.org deployed to Fastly including these redirects. They are configured as 301s for now. Overview of the implementation: |
Please let me know if this is satisfies the requirements by closing this issue :) I'll update to permanent redirects then. |
Thanks! We want the request so we have only digits after Some examples:
We didn't discuss having leading zeros in the request, but I guess these are fine too:
|
d'oh. Ok :) https://fiddle.fastlydemo.net/fiddle/71cc868a is the sketch of the service now. changes are active and cover all above scenarios. |
Opened #2527 to make the fastly service transparent... even if terraform and fastly might be a little obscure 😅 |
I'll close this, as requirements in #2420 (comment) are all addressed. |
Thanks for fixing this!
Here are some tests: Note that old autolinks might take 1 day or so to update, but these should use the new autolinking rule directly. |
In some sense having the autolink references require the zeros made clear that they weren't actually the correct canonical names for/references to PEPs (even though, admittedly, I was the first to complain about the requirement), but I suppose that's a fairly small (and somewhat pedantic) price to pay for the substantially increased convenience. Thanks @ewdurbin ! |
I was going to add
pep-*
autolinking to thepython/cpython
repo, but I realized that the URL requires the right amount of leading0
in order to work. For example:https://peps.python.org/pep-0008/ -- works fine
https://peps.python.org/pep-8/ -- fails
People rarely mention the leading
0
s when they write e.g. PEP-8 in a message, and the autolinker doesn't offer any formatting option. Because of this, clicking the link results in a 404.Would it be possible to create a script that, in case of 404, tries to extract the pep number and redirects to
f'https://peps.python.org/pep-{num:04d}/'
?If it's handled on this end, it will have the advantage that every repo will be able to autolink PEPs, and it will also work for people editing the URL manually (something I happen to do from time to time).
The text was updated successfully, but these errors were encountered: