fork/cargo

git clone https://git.julia.blue/fork/cargo

borsAuto merge of #12853 - weihanglo:cname-warning, r=ehuss5225467af

0.93.0
1.7 KiB49 linesraw
1#!/usr/bin/env python3
2
3MAPPING = {
4    "build-script.html": "https://doc.rust-lang.org/cargo/reference/build-scripts.html",
5    "config.html": None,
6    "crates-io.html": "https://doc.rust-lang.org/cargo/reference/publishing.html",
7    "environment-variables.html": None,
8    "external-tools.html": None,
9    "faq.html": "https://doc.rust-lang.org/cargo/faq.html",
10    "guide.html": "https://doc.rust-lang.org/cargo/guide/",
11    "index.html": "https://doc.rust-lang.org/cargo/",
12    "manifest.html": None,
13    "pkgid-spec.html": None,
14    "policies.html": "https://crates.io/policies",
15    "source-replacement.html": None,
16    "specifying-dependencies.html": None,
17}
18
19TEMPLATE = """\
20<html>
21<head>
22<meta http-equiv="refresh" content="0; url={mapped}" />
23<script>
24window.location.replace("{mapped}" + window.location.hash);
25</script>
26<title>Page Moved</title>
27</head>
28<body>
29This page has moved. Click <a href="{mapped}">here</a> to go to the new page.
30</body>
31</html>
32"""
33
34def main():
35    for name in sorted(MAPPING):
36        with open(name, 'w') as f:
37            mapped = MAPPING[name]
38            if mapped is None:
39                mapped = "https://doc.rust-lang.org/cargo/reference/{}".format(name)
40            f.write(TEMPLATE.format(name=name, mapped=mapped))
41
42    # WARN: The CNAME file is for GitHub to redirect requests to the custom domain.
43    # Missing this may entail security hazard and domain takeover.
44    # See <https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site#securing-your-custom-domain>
45    with open('CNAME', 'w') as f:
46        f.write('doc.crates.io')
47
48if __name__ == '__main__':
49    main()