Skip to content

Redirect old top-level files to versioned docs #41

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 3 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Redirect old top-level files to versioned docs
  • Loading branch information
QuLogic committed Oct 9, 2024
commit 08a0ec72f6e1c2c2adc96ba23a6b986cf917f348
2 changes: 2 additions & 0 deletions matplotlib.org.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
site_dir: "/usr/share/caddy"
tls_config: "tls /etc/caddy/tls/cert.pem /etc/caddy/tls/privkey.pem"
repos:
# Key is repo name, value is the site /path/ (which defaults to the repo
# name if not set).
mpl-brochure-site:
matplotlib.github.com:
basemap:
Expand Down
64 changes: 64 additions & 0 deletions templates/Caddyfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,70 @@ http://{{ caddy.addresses.main }}, http://{{ ansible_fqdn }} {
rewrite / /mpl-brochure-site/index.html
rewrite @brochure /mpl-brochure-site{http.matchers.file.relative}

# Redirect any of the old top-level files to the versioned docs.
redir /citing.html /stable/project/citing.html permanent
redir /contents.html /stable/users/ permanent
redir /downloads.html /stable/users/installing/ permanent
redir /gallery.html /stable/gallery/ permanent
redir /py-modindex.html /stable/py-modindex.html permanent
{# 3.5.0 was the last version to be synced to the top-level directory.
We also try for stable, just to go to the best version possible. #}
{%- with old_versions = [
"stable",
"3.5.0",
"3.4.3", "3.4.2", "3.4.1", "3.4.0",
"3.3.4", "3.3.3", "3.3.2", "3.3.1", "3.3.0",
"3.2.2", "3.2.1", "3.2.0",
"3.1.3", "3.1.1", "3.1.0",
"3.0.3", "3.0.2", "3.0.0",
"2.2.5", "2.2.4", "2.2.3", "2.2.2", "2.2.0",
"2.1.2", "2.1.1", "2.1.0",
"2.0.2", "2.0.1", "2.0.0",
"1.5.3", "1.5.1", "1.5.0",
"1.4.3", "1.4.2", "1.4.1", "1.4.0",
"1.3.1", "1.3.0", "1.2.1",
] %}
{%- with old_toplevel_dirs = [
"_downloads",
"_images",
"_modules",
"_panels_static",
"_sources",
"_static",
"api",
"devel",
"examples",
"faq",
"gallery",
"glossary",
"mpl_examples",
"mpl_toolkits",
"plot_directive",
"plot_types",
"pyplots",
"resources",
"tutorials",
"users",
] %}
@old-toplevel-dirs {
path{% for dir in old_toplevel_dirs %} /{{dir}} /{{dir}}/{% endfor +%}
file {
root {{ caddy.site_dir }}/matplotlib.github.com
try_files{% for version in old_versions %} /{{version}}/{path}/index.html{% endfor +%}
}
}
redir @old-toplevel-dirs {http.matchers.file.relative} permanent
@old-toplevel-dir-contents {
path{% for dir in old_toplevel_dirs %} /{{dir}}/*{% endfor +%}
file {
root {{ caddy.site_dir }}/matplotlib.github.com
try_files{% for version in old_versions %} /{{version}}/{path}.html /{{version}}/{path}{% endfor +%}
}
}
redir @old-toplevel-dir-contents {http.matchers.file.relative} permanent
{%- endwith -%}
{%- endwith +%}

# Finally try any of the versioned docs.
handle {
root * {{ caddy.site_dir }}/matplotlib.github.com
Expand Down
Loading