blob: 4528189956e8e174586af49830629a4a3cd92907 [file] [log] [blame]
import os
from urllib.parse import urlparse
redirects = [
('llvmpipe', 'gallium/drivers/llvmpipe.html'),
('postprocess', 'gallium/postprocess.html'),
('webmaster', 'https://www.mesa3d.org/website/')
]
def create_redirect(dst):
tpl = '<html><head><meta http-equiv="refresh" content="0; url={0}"><script>window.location.replace("{0}")</script></head></html>'
return tpl.format(dst)
def create_redirects(app, docname):
if not app.builder.name == 'html':
return
for src, dst in redirects:
path = os.path.join(app.outdir, '{0}.html'.format(src))
os.makedirs(os.path.dirname(path), exist_ok=True)
if urlparse(dst).scheme == "":
if not os.path.isfile(os.path.join(os.path.dirname(path), dst)):
raise Exception('{0} does not exitst'.format(dst))
with open(path, 'w') as f:
f.write(create_redirect(dst))
def setup(app):
app.connect('build-finished', create_redirects)