]> git.ipfire.org Git - people/shoehn/ipfire.org.git/blame - www/webapp/__init__.py
Initial checkin.
[people/shoehn/ipfire.org.git] / www / webapp / __init__.py
CommitLineData
81675874 1#/usr/bin/python
2
3import os.path
4
5import tornado.locale
6import tornado.options
7import tornado.web
8
9from .handlers import *
10from .ui_modules import *
11
12BASEDIR = os.path.join(os.path.dirname(__file__), "..")
13
14tornado.locale.load_translations(os.path.join(BASEDIR, "translations"))
15tornado.options.enable_pretty_logging()
16
17class Application(tornado.web.Application):
18 def __init__(self):
19 handlers = [
20 # Entry sites that lead the user to index
21 (r"/", MainHandler),
22 (r"/[A-Za-z]{2}/?", MainHandler),
23 #
24 (r"/[A-Za-z]{2}/index", IndexHandler),
25 (r"/[A-Za-z]{2}/news", NewsHandler),
26 (r"/[A-Za-z]{2}/builds", BuildHandler),
27 (r"/[A-Za-z]{2}/translations?", TranslationHandler),
28 # Download sites
29 (r"/[A-Za-z]{2}/downloads?", DownloadHandler),
30 (r"/[A-Za-z]{2}/downloads?/all", DownloadAllHandler),
31 (r"/[A-Za-z]{2}/downloads?/development", DownloadDevelopmentHandler),
32 (r"/[A-Za-z]{2}/downloads?/torrents", DownloadTorrentHandler),
33 # API
34 (r"/api/cluster_info", ApiClusterInfoHandler),
35 # Always the last rule
36 (r"/[A-Za-z]{2}/(.*)", StaticHandler),
37 ]
38
39 settings = dict(
40 cookie_secret = "aXBmaXJlY29va2llc2VjcmV0Cg==",
41 #debug = True,
42 gzip = True,
43 static_path = os.path.join(BASEDIR, "static"),
44 template_path = os.path.join(BASEDIR, "templates"),
45 ui_modules = {
46 "Build" : BuildModule,
47 "Menu" : MenuModule,
48 "MenuItem" : MenuItemModule,
49 "NewsItem" : NewsItemModule,
50 "ReleaseItem" : ReleaseItemModule,
51 "SidebarBanner" : SidebarBannerModule,
52 "SidebarItem" : SidebarItemModule,
53 "SidebarRelease" : SidebarReleaseModule,
54 },
55 xsrf_cookies = True,
56 )
57 tornado.web.Application.__init__(self, handlers, **settings)