]>
git.ipfire.org Git - ipfire.org.git/blob - www/webapp/handlers.py
11 #import tornado.database
12 #import tornado.locale
18 from handlers_admin
import *
19 from handlers_base
import *
20 from handlers_download
import *
21 from handlers_mirrors
import *
22 from handlers_news
import *
23 from handlers_planet
import *
24 from handlers_stasy
import *
25 from handlers_tracker
import *
28 class RootHandler(BaseHandler
):
30 This handler redirects any request directly to /.
32 It can be used to be compatible with some ancient index urls.
38 class LangCompatHandler(BaseHandler
):
40 Redirect links in the old format to current site:
42 E.g. /en/index -> /index
44 def get(self
, lang
, page
):
45 self
.redirect("/%s" % page
)
48 class IndexHandler(BaseHandler
):
50 This handler displays the welcome page.
53 # Get a list of the most recent news items and put them on the page.
54 latest_news
= self
.news
.get_latest(limit
=1, locale
=self
.locale
)
55 recent_news
= self
.news
.get_latest(limit
=2, locale
=self
.locale
, offset
=1)
57 return self
.render("index.html",
58 latest_news
=latest_news
, recent_news
=recent_news
)
61 class StaticHandler(BaseHandler
):
63 This handler shows the files that are in plain html format.
66 def static_path(self
):
67 return os
.path
.join(self
.application
.settings
["template_path"], "static")
70 def static_files(self
):
72 for filename
in os
.listdir(self
.static_path
):
73 if filename
.endswith(".html"):
77 def get(self
, name
=None):
78 name
= "%s.html" % name
80 if not name
in self
.static_files
:
81 raise tornado
.web
.HTTPError(404)
83 self
.render("static/%s" % name
, lang
=self
.locale
.code
[:2])