33(subproject) {
44 # Caddy doesn't know this is a directory, so redirect to trailing / as
55 # would usually happen for them.
6- redir /{args.0 } /{args.0 }/ permanent
6+ redir /{args[1] } /{args[1] }/ permanent
77
8- handle_path /{args.0 }/* {
9- root * {{ caddy.site_dir }}/{args.0 }
8+ handle_path /{args[1] }/* {
9+ root * {{ caddy.site_dir }}/{args[0] }
1010 try_files {path}.html {path}
1111 file_server {
1212 hide .git
@@ -70,8 +70,8 @@ http://{{ caddy.addresses.main }}, http://{{ ansible_fqdn }} {
7070
7171 root * {{ caddy.site_dir }}
7272
73- {% for site in repos %}
74- import subproject {{ site }}
73+ {% for site , path in repos . items () %}
74+ import subproject {{ site }} {{ path | default(site, true) }}
7575{% endfor %}
7676
7777 # Hide mpl-altair until the site is fixed.
@@ -96,6 +96,16 @@ http://{{ caddy.addresses.main }}, http://{{ ansible_fqdn }} {
9696 }
9797 }
9898
99+ # Redirect the repo-named third-party packages path to the more-generic path.
100+ redir /3pp /thirdpartypackages/ # And also add a shortcut.
101+ @mpl-third-party path /mpl-third-party /mpl-third-party/*
102+ handle @mpl-third-party {
103+ route {
104+ uri strip_prefix /mpl-third-party
105+ redir * /thirdpartypackages{uri}
106+ }
107+ }
108+
99109 # Place the brochure site at the top level.
100110 @brochure file {
101111 root {{ caddy.site_dir }}/mpl-brochure-site
@@ -104,6 +114,70 @@ http://{{ caddy.addresses.main }}, http://{{ ansible_fqdn }} {
104114 rewrite / /mpl-brochure-site/index.html
105115 rewrite @brochure /mpl-brochure-site{http.matchers.file.relative}
106116
117+ # Redirect any of the old top-level files to the versioned docs.
118+ redir /citing.html /stable/project/citing.html permanent
119+ redir /contents.html /stable/users/ permanent
120+ redir /downloads.html /stable/users/installing/ permanent
121+ redir /gallery.html /stable/gallery/ permanent
122+ redir /py-modindex.html /stable/py-modindex.html permanent
123+ {# 3.5.0 was the last version to be synced to the top-level directory.
124+ We also try for stable, just to go to the best version possible. #}
125+ {% - with old_versions = [
126+ "stable" ,
127+ "3.5.0" ,
128+ "3.4.3" , "3.4.2" , "3.4.1" , "3.4.0" ,
129+ "3.3.4" , "3.3.3" , "3.3.2" , "3.3.1" , "3.3.0" ,
130+ "3.2.2" , "3.2.1" , "3.2.0" ,
131+ "3.1.3" , "3.1.1" , "3.1.0" ,
132+ "3.0.3" , "3.0.2" , "3.0.0" ,
133+ "2.2.5" , "2.2.4" , "2.2.3" , "2.2.2" , "2.2.0" ,
134+ "2.1.2" , "2.1.1" , "2.1.0" ,
135+ "2.0.2" , "2.0.1" , "2.0.0" ,
136+ "1.5.3" , "1.5.1" , "1.5.0" ,
137+ "1.4.3" , "1.4.2" , "1.4.1" , "1.4.0" ,
138+ "1.3.1" , "1.3.0" , "1.2.1" ,
139+ ] %}
140+ {% - with old_toplevel_dirs = [
141+ "_downloads" ,
142+ "_images" ,
143+ "_modules" ,
144+ "_panels_static" ,
145+ "_sources" ,
146+ "_static" ,
147+ "api" ,
148+ "devel" ,
149+ "examples" ,
150+ "faq" ,
151+ "gallery" ,
152+ "glossary" ,
153+ "mpl_examples" ,
154+ "mpl_toolkits" ,
155+ "plot_directive" ,
156+ "plot_types" ,
157+ "pyplots" ,
158+ "resources" ,
159+ "tutorials" ,
160+ "users" ,
161+ ] %}
162+ @old-toplevel-dirs {
163+ path{% for dir in old_toplevel_dirs %} /{{dir}} /{{dir}}/{% endfor +%}
164+ file {
165+ root {{ caddy.site_dir }}/matplotlib.github.com
166+ try_files{% for version in old_versions %} /{{version}}/{path}/index.html{% endfor +%}
167+ }
168+ }
169+ redir @old-toplevel-dirs {http.matchers.file.relative} permanent
170+ @old-toplevel-dir-contents {
171+ path{% for dir in old_toplevel_dirs %} /{{dir}}/*{% endfor +%}
172+ file {
173+ root {{ caddy.site_dir }}/matplotlib.github.com
174+ try_files{% for version in old_versions %} /{{version}}/{path}.html /{{version}}/{path}{% endfor +%}
175+ }
176+ }
177+ redir @old-toplevel-dir-contents {http.matchers.file.relative} permanent
178+ {% - endwith -%}
179+ {% - endwith +%}
180+
107181 # Finally try any of the versioned docs.
108182 handle {
109183 root * {{ caddy.site_dir }}/matplotlib.github.com
0 commit comments