Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 38 lines (31 sloc) 1.362 kb
9be22d3 @jacobian Updated the little serving app to send out redirects for the old site.
jacobian authored
1 """
2 The simplest possible app that can serve these Sphinx docs and issue
3 redirects for the previous URLs.
4 """
5
fd9362a @jacobian Heroku-ifiy.
jacobian authored
6 import static
9be22d3 @jacobian Updated the little serving app to send out redirects for the old site.
jacobian authored
7 import selector
8 from unipath import FSPath as Path
9
10 app = selector.Selector()
11
12 def redirect(to):
13 """
14 Create a 301 redirect WSGI app.
15
16 `to` may contain str.format-style formatting which'll be formatted against
17 the routing arguments (wsgiorg.routing_args).
18 """
19 def _redirect(environ, start_response):
20 args, kwargs = environ['wsgiorg.routing_args']
21 start_response('301 MOVED PERMANENTLY',
22 [('Location', to.format(*args, **kwargs))])
23 return []
24 return _redirect
25
26 # Redirects for old doc URLs, since Cool URIs Don't Change.
27 app.add('/', GET=redirect('/en/2.0/index.html'))
28 app.add('/license/', GET=redirect('/en/2.0/license.html'))
29 app.add('/about/', GET=redirect('/en/2.0/frontmatter.html'))
30 app.add('/en/1.0/', GET=redirect('/en/2.0/index.html'))
31 app.add('/en/1.0/{doc:chunk}/', GET=redirect('/en/2.0/{doc}.html'))
32 app.add('/en/2.0/{doc:chunk}/', GET=redirect('/en/2.0/{doc}.html'))
fd9362a @jacobian Heroku-ifiy.
jacobian authored
33
9be22d3 @jacobian Updated the little serving app to send out redirects for the old site.
jacobian authored
34 # Serve docs at "/en/2.0" still, to leave room for the future.
35 # One of these days I'll actually do this, not just talk about it!
36 docs = static.Cling(Path(__file__).parent.child('_build', 'html'))
37 app.add("/en/2.0|", GET=docs)
Something went wrong with that request. Please try again.