aboutsummaryrefslogtreecommitdiff
path: root/docs/source/_extensions
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2019-11-01 19:58:56 +0100
committerKristian Evers <kristianevers@gmail.com>2019-11-01 19:58:56 +0100
commitc64d3fcb3a60f27631b80b6c7eebb800315ac8eb (patch)
tree370653ea3e75061e1479b876a1b874608771d593 /docs/source/_extensions
parent1e960f99c719a4c51913b1cec168253c1ededb7f (diff)
parent8a31e8778b95eb8e857c30f276fbf1e5047f78fe (diff)
downloadPROJ-c64d3fcb3a60f27631b80b6c7eebb800315ac8eb.tar.gz
PROJ-c64d3fcb3a60f27631b80b6c7eebb800315ac8eb.zip
Merge remote-tracking branch 'osgeo/master'
Diffstat (limited to 'docs/source/_extensions')
-rw-r--r--docs/source/_extensions/redirects.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/docs/source/_extensions/redirects.py b/docs/source/_extensions/redirects.py
new file mode 100644
index 00000000..6a59b622
--- /dev/null
+++ b/docs/source/_extensions/redirects.py
@@ -0,0 +1,39 @@
+import os
+
+# https://tech.signavio.com/2017/managing-sphinx-redirects
+
+
+template="""<html>
+ <head>
+ <meta http-equiv="refresh" content="1; url=%s" />
+ <script>
+ window.location.href = "%s"
+ </script>
+ </head>
+</html>"""
+
+
+def gather_redirects():
+ output = {}
+
+ output.update({ 'projjson.html' : 'usage/projjson.html' })
+ return output
+
+from shutil import copyfile
+# copy legacy redirects
+def copy_legacy_redirects(app, docname): # Sphinx expects two arguments
+ if app.builder.name == 'html':
+ for key in app.config.redirect_files:
+ src = key
+ tgt = app.config.redirect_files[key]
+ html = template % (tgt, tgt)
+ with open(os.path.join(app.outdir, src), 'wb') as f:
+ f.write(html.encode('utf-8'))
+ f.close()
+
+
+
+def setup(app):
+ app.add_config_value('redirect_files', {}, 'html')
+ app.connect('build-finished', copy_legacy_redirects)
+ return { 'parallel_read_safe': False, 'parallel_write_safe': True }