- Notifications
You must be signed in to change notification settings - Fork54
Fix do all redirects#49
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Procedure for a release:As before
If a file is removed from 2.0.0, then the make_redirects_links will link it to 1.9.9 (or whatever the last version was). A new file will then just be linked back to Conversely, we could leave out the rsync step from now on, so new docs are never installed at the top level (newest is always in stable) |
This pull requestintroduces 3 alerts andfixes 1414 when mergingddbe02b intoae49ba9 -view on LGTM.com new alerts:
fixed alerts:
|
So I think this should also go back through all the html files, and change the canonical. canonical would be the latest available version, usually |
d4f4528
to7a1c948
CompareThis pull requestintroduces 5 alerts andfixes 1414 when merging83007d9 into512a813 -view on LGTM.com new alerts:
fixed alerts:
|
83007d9
to694bc49
CompareThis pull requestintroduces 5 alerts andfixes 1414 when merging694bc49 into512a813 -view on LGTM.com new alerts:
fixed alerts:
|
A possible improvement of this script might be to put a banner after |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
694bc49
toad5b63c
Comparead5b63c
to67572bf
CompareNote I've dropped the second commit because there is no reason to upload it here until its ready to go. Let me know if you'd like me to regenerate it, or if one of you would like to do it. |
Ah, I have been indpendently working on the script, have some ways to make it faster. I think it is possible to make the re-directs relative as a kindness to anyone who wants to host these files locally / on an airgapped network. |
This pull requestintroduces 4 alerts when merging67572bf intoaa7c836 -view on LGTM.com new alerts:
|
os.raname does not work across filesystems
This is helpful to people who want to host off-line versions of thedocs.
Does a relative redirect work so that the new address looks correct? We don't want |
Added the banner logic. It somewhat fragilely assumes that the Also removed the double recursion under do_canonical! Its quite fast now and I'm 90% sure it hits everything. |
This pull requestintroduces 4 alerts when merging4fd177e intoaa7c836 -view on LGTM.com new alerts:
|
This pull requestintroduces 1 alert when merging1e9977f intoaa7c836 -view on LGTM.com new alerts:
|
Note I don't think this needs to wait formatplotlib/matplotlib#19456 |
This is working so far as I can tell. Header and start of body now look like: ...<linkrel="canonical"href="https://matplotlib.org/stable/index.html"/><linkrel="stylesheet"href="_static/custom.css"type="text/css"/><metaname="viewport"content="width=device-width, initial-scale=0.9, maximum-scale=0.9"/></head><body><divid="olddocs-message"> You are reading an old version of thedocumentation (v3.3.2). For the latest version see<ahref="https://matplotlib.org/stable/index.html">https://matplotlib.org/stable/index.html</a></div> |
This pull requestintroduces 1 alert when merging2f144a8 intoaa7c836 -view on LGTM.com new alerts:
|
@tacaswell@QuLogic I don't see any reason to not move forward with this. If you do, happy to chat, but if its OK, I think implementing it sooner rather than later is preferable... |
last = findlast(basename, tocheck) | ||
if last is not None: | ||
update_canonical(fullname, last, dname == tocheck[1]) | ||
for fullname in dname.rglob("*.html"): |
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.
Note,Path.rglob
doesn't seem to support multiple patterns, but we do not have any.htm
files.
I pushed a few cleanups and improvements. |
Hmmm, is |
Oh, yes, but it's basically a lighter version of |
I don't mind, I just need to upgrade my env |
if not args.no_canonicals: | ||
if np is not None: | ||
with multiprocessing.Pool(np) as pool: | ||
pool.map(do_canonicals, tocheck[1:]) |
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.
This option now fails:
Traceback (most recent call last): File "/Users/jklymak/anaconda3/envs/matplotlibdev/lib/python3.9/multiprocessing/pool.py", line 125, in worker result = (True, func(*args, **kwds)) File "/Users/jklymak/anaconda3/envs/matplotlibdev/lib/python3.9/multiprocessing/pool.py", line 48, in mapstar return list(map(*args)) File "/Users/jklymak/matplotlib.github.com/_websiteutils/make_redirects_links.py", line 142, in do_canonicals last = findlast(basename, tocheck)TypeError: unhashable type: 'list'
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.
Perhaps just remove it?
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.
Ah,map
must convert it from a tuple to a list.
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.
so its the cache that is causing the problem? Happy to remove my optimization in favour of your optimization ;-)
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.
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.
That aside, I think this is working great....
Uh oh!
There was an error while loading.Please reload this page.
(Update 31 Jan 2021):
closes:matplotlib/matplotlib#12374
closes:#25
Obviously this blows git hub up, but the script that does this is in the first commit...
Problem 1:
Currently the top level of the website has a copy of every file that has existed on our webpage, even if the file is obsolete, and not part of current matplotlib docs. For instance the
/examples/
directory was removed after 2.0.2 (and replaced by/gallery/
) but is still accessible athttps://matplotlib.org/examples/.@tacaswell wants this to remain so old links do not die, but it also means that search engines think this is a perfectly acceptable current set of webpages, whereas we would like these versions to not show up in searches.Proposed solution:
The script here either soft links all top-level files to theirnewest version in the docs, or makes an html-refresh to do that.
So, for example
gallery/api
was moved for 3.0.0, so:ls -halt gallery/api
gives:and
less quad_bezier.html
givesProblem 2:
Similarly our canonical links go to the top level or the level they were introduced in. So
https://matplotlib.org/stable/gallery/showcase/mandelbrot.html
has<link rel="canonical" href="https://matplotlib.org/3.3.4/gallery/showcase/mandelbrot.html"/>
as its canonical link. Older versions of the docs would link to<link rel="canonical" href="https://matplotlib.org/gallery/showcase/mandelbrot.html"/>
Solution:
The script goes through each html file in all versions (including old versions) and changes the canonical link to the newest version. So for
quad_bezier.html
:less 2.2.5/gallery/api/quad_bezier.html
gives<link rel="canonical" href="https://matplotlib.org/2.2.5/gallery/api/quad_bezier.html" />
less 2.2.4/gallery/api/quad_bezier.html
gives the same link (because 2.2.5 is the newest).For files that exist in
stable
:less 2.2.4/tutorials/intermediate/artists.html
gives the canonical version in stable.<link rel="canonical" href="https://matplotlib.org/stable/tutorials/intermediate/artists.html" />
Maintenance Burden