diff options
-rw-r--r-- | controller.py | 19 | ||||
-rwxr-xr-x | index.py | 1 | ||||
-rw-r--r-- | redirects | 2 | ||||
-rw-r--r-- | templates/menu.mako | 5 |
4 files changed, 25 insertions, 2 deletions
diff --git a/controller.py b/controller.py index e694148..7de70f1 100644 --- a/controller.py +++ b/controller.py @@ -1,3 +1,5 @@ +from __future__ import with_statement + import web from renderer import render @@ -9,6 +11,23 @@ class Page: if not name or name == '/': name = 'index' return render(name) +class Redirect: + """ + Redirecting to another page. + """ + + redirects = {} + with open("redirects") as f: + for line in f: + name, url = line.split() + redirects[name.strip()] = url.strip() + + def GET(self, name): + if name not in self.redirects: + raise web.TempRedirect("/") + else: + raise web.Redirect(self.redirects[name], absolute = True) + def FourOhFour(page): """ 404 error page. @@ -7,6 +7,7 @@ import controller # URL Mappings # urls = ( + "/r/(.*)", "controller.Redirect", "/(.*)", "controller.Page" ) diff --git a/redirects b/redirects new file mode 100644 index 0000000..b429db2 --- /dev/null +++ b/redirects @@ -0,0 +1,2 @@ +bugs https://bugs.launchpad.net/portato +blog http://necoro.wordpress.com diff --git a/templates/menu.mako b/templates/menu.mako index cf9923e..d74a144 100644 --- a/templates/menu.mako +++ b/templates/menu.mako @@ -2,8 +2,9 @@ menu = [ ("/index", "Portato"), ("/download", "Download"), - ("/development", "Development"), ("/translating", "Translating"), - ("http://necoro.wordpress.com", "Blog") + ("/development", "Development"), + ("/r/bugs", "Bugs"), + ("/r/blog", "Blog") ] %> |