Skip to content

Commit f0ce265

Browse files
committed
Redirect old top-level files to versioned docs
1 parent 4046780 commit f0ce265

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

templates/Caddyfile.j2

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,70 @@ http://{{ caddy.addresses.main }}, http://{{ ansible_fqdn }} {
108108
rewrite / /mpl-brochure-site/index.html
109109
rewrite @brochure /mpl-brochure-site{http.matchers.file.relative}
110110

111+
# Redirect any of the old top-level files to the versioned docs.
112+
redir /citing.html /stable/project/citing.html permanent
113+
redir /contents.html /stable/users/ permanent
114+
redir /downloads.html /stable/users/installing/ permanent
115+
redir /gallery.html /stable/gallery/ permanent
116+
redir /py-modindex.html /stable/py-modindex.html permanent
117+
{# 3.5.0 was the last version to be synced to the top-level directory.
118+
We also try for stable, just to go to the best version possible. #}
119+
{%- with old_versions = [
120+
"stable",
121+
"3.5.0",
122+
"3.4.3", "3.4.2", "3.4.1", "3.4.0",
123+
"3.3.4", "3.3.3", "3.3.2", "3.3.1", "3.3.0",
124+
"3.2.2", "3.2.1", "3.2.0",
125+
"3.1.3", "3.1.1", "3.1.0",
126+
"3.0.3", "3.0.2", "3.0.0",
127+
"2.2.5", "2.2.4", "2.2.3", "2.2.2", "2.2.0",
128+
"2.1.2", "2.1.1", "2.1.0",
129+
"2.0.2", "2.0.1", "2.0.0",
130+
"1.5.3", "1.5.1", "1.5.0",
131+
"1.4.3", "1.4.2", "1.4.1", "1.4.0",
132+
"1.3.1", "1.3.0", "1.2.1",
133+
] %}
134+
{%- with old_toplevel_dirs = [
135+
"_downloads",
136+
"_images",
137+
"_modules",
138+
"_panels_static",
139+
"_sources",
140+
"_static",
141+
"api",
142+
"devel",
143+
"examples",
144+
"faq",
145+
"gallery",
146+
"glossary",
147+
"mpl_examples",
148+
"mpl_toolkits",
149+
"plot_directive",
150+
"plot_types",
151+
"pyplots",
152+
"resources",
153+
"tutorials",
154+
"users",
155+
] %}
156+
@old-toplevel-dirs {
157+
path{% for dir in old_toplevel_dirs %} /{{dir}} /{{dir}}/{% endfor +%}
158+
file {
159+
root {{ caddy.site_dir }}/matplotlib.github.com
160+
try_files{% for version in old_versions %} /{{version}}/{path}/index.html{% endfor +%}
161+
}
162+
}
163+
redir @old-toplevel-dirs {http.matchers.file.relative} permanent
164+
@old-toplevel-dir-contents {
165+
path{% for dir in old_toplevel_dirs %} /{{dir}}/*{% endfor +%}
166+
file {
167+
root {{ caddy.site_dir }}/matplotlib.github.com
168+
try_files{% for version in old_versions %} /{{version}}/{path}.html /{{version}}/{path}{% endfor +%}
169+
}
170+
}
171+
redir @old-toplevel-dir-contents {http.matchers.file.relative} permanent
172+
{%- endwith -%}
173+
{%- endwith +%}
174+
111175
# Finally try any of the versioned docs.
112176
handle {
113177
root * {{ caddy.site_dir }}/matplotlib.github.com

0 commit comments

Comments
 (0)