]>
git.ipfire.org Git - people/shoehn/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_boot
import *
21 from handlers_download
import *
22 from handlers_iuse
import *
23 from handlers_mirrors
import *
24 from handlers_news
import *
25 from handlers_nopaste
import *
26 from handlers_planet
import *
27 from handlers_rss
import *
28 from handlers_stasy
import *
29 from handlers_tracker
import *
30 from handlers_wishlist
import *
32 class RootHandler(BaseHandler
):
34 This handler redirects any request directly to /.
36 It can be used to be compatible with some ancient index urls.
42 class LangCompatHandler(BaseHandler
):
44 Redirect links in the old format to current site:
46 E.g. /en/index -> /index
48 def get(self
, lang
, page
):
49 self
.redirect("/%s" % page
)
52 class IndexHandler(BaseHandler
):
56 This handler displays the welcome page.
59 # Get a list of the most recent news items and put them on the page.
60 latest_news
= self
.news
.get_latest(limit
=1, locale
=self
.locale
)
62 # Get the latest release.
63 latest_release
= self
.releases
.get_latest()
65 return self
.render("index.html", latest_news
=latest_news
,
66 latest_release
=latest_release
)
69 class StaticHandler(BaseHandler
):
71 This handler shows the files that are in plain html format.
74 def static_path(self
):
75 return os
.path
.join(self
.application
.settings
["template_path"], "static")
78 def static_files(self
):
79 for dir, subdirs
, files
in os
.walk(self
.static_path
):
80 dir = dir[len(self
.static_path
) + 1:]
82 if not file.endswith(".html"):
84 yield os
.path
.join(dir, file)
86 def get(self
, name
=None):
87 name
= "%s.html" % name
89 if not name
in self
.static_files
:
90 raise tornado
.web
.HTTPError(404)
92 self
.render("static/%s" % name
, lang
=self
.locale
.code
[:2])