]>
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_iuse
import *
22 from handlers_mirrors
import *
23 from handlers_news
import *
24 from handlers_planet
import *
25 from handlers_rss
import *
26 from handlers_stasy
import *
27 from handlers_tracker
import *
30 class RootHandler(BaseHandler
):
32 This handler redirects any request directly to /.
34 It can be used to be compatible with some ancient index urls.
40 class LangCompatHandler(BaseHandler
):
42 Redirect links in the old format to current site:
44 E.g. /en/index -> /index
46 def get(self
, lang
, page
):
47 self
.redirect("/%s" % page
)
50 class IndexHandler(BaseHandler
):
54 This handler displays the welcome page.
57 # Get a list of the most recent news items and put them on the page.
58 latest_news
= self
.news
.get_latest(limit
=1, locale
=self
.locale
)
59 recent_planets
= self
.planet
.get_entries(limit
=1)
61 return self
.render("index.html",
62 latest_news
=latest_news
, recent_planets
=recent_planets
)
65 class StaticHandler(BaseHandler
):
67 This handler shows the files that are in plain html format.
70 def static_path(self
):
71 return os
.path
.join(self
.application
.settings
["template_path"], "static")
74 def static_files(self
):
76 for filename
in os
.listdir(self
.static_path
):
77 if filename
.endswith(".html"):
81 def get(self
, name
=None):
82 name
= "%s.html" % name
84 if not name
in self
.static_files
:
85 raise tornado
.web
.HTTPError(404)
87 self
.render("static/%s" % name
, lang
=self
.locale
.code
[:2])