diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2010-04-07 02:00:49 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2010-04-07 02:00:49 +0200 |
commit | 9764086ee9cc10ad1fe7b7cc6f2be82145f843e3 (patch) | |
tree | a2c16e52d2881fd62f1b053e731c92647d6f3bde | |
parent | b0a8979e00abddc538359a1f0c3f57e0c90ff16e (diff) | |
download | web-9764086ee9cc10ad1fe7b7cc6f2be82145f843e3.tar.gz web-9764086ee9cc10ad1fe7b7cc6f2be82145f843e3.tar.bz2 web-9764086ee9cc10ad1fe7b7cc6f2be82145f843e3.zip |
Implemented redirecting
-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") ] %> |