]> git.ipfire.org Git - ipfire.org.git/blobdiff - src/web/__init__.py
Show background image only on main page
[ipfire.org.git] / src / web / __init__.py
index 5f94d90588194a410535fe6437ddad3661ebc99e..b6bfab197c9d51d3823a079d127a20aefc9d67fd 100644 (file)
@@ -11,6 +11,8 @@ import ipfire
 from handlers import *
 from ui_modules import *
 
+from . import blog
+
 BASEDIR = os.path.join(os.path.dirname(__file__), "..")
 
 class Application(tornado.web.Application):
@@ -37,6 +39,10 @@ class Application(tornado.web.Application):
                                "format_month_name" : self.format_month_name,
                        },
                        "ui_modules" : {
+                               "BlogPost"             : blog.PostModule,
+                               "BlogPosts"            : blog.PostsModule,
+
+                               # Old modules
                                "Advertisement"        : AdvertisementModule,
                                "DonationBox"          : DonationBoxModule,
                                "DonationButton"       : DonationButtonModule,
@@ -69,18 +75,14 @@ class Application(tornado.web.Application):
                                "TalkLines"            : TalkLinesModule,
                                "TalkOngoingCalls"     : TalkOngoingCallsModule,
                        },
+
+                       # Call this when a page wasn't found
+                       "default_handler_class" : NotFoundHandler,
                }
                settings.update(kwargs)
 
                tornado.web.Application.__init__(self, **settings)
 
-               self.settings["static_path"] = static_path = os.path.join(BASEDIR, "static")
-               static_handlers = [
-                       (r"/static/(.*)", tornado.web.StaticFileHandler, dict(path = static_path)),
-                       (r"/(favicon\.ico)", tornado.web.StaticFileHandler, dict(path = static_path)),
-                       (r"/(robots\.txt)", tornado.web.StaticFileHandler, dict(path = static_path)),
-               ]
-
                authentication_handlers = [
                        (r"/login", LoginHandler),
                        (r"/logout", LogoutHandler),
@@ -106,12 +108,27 @@ class Application(tornado.web.Application):
                        # RSS feed
                        (r"/news.rss", RSSNewsHandler),
 
+                       # Static Pages
+                       (r"/artwork", StaticHandler, { "template" : "artwork.html" }),
+                       (r"/chat", StaticHandler, { "template" : "chat.html" }),
+                       (r"/features", StaticHandler, { "template" : "features.html" }),
+                       (r"/get-involved", StaticHandler, { "template" : "get-involved.html" }),
+                       (r"/get-started", StaticHandler, { "template" : "get-started.html" }),
+                       (r"/get-support", StaticHandler, { "template" : "get-support.html" }),
+                       (r"/hardware", StaticHandler, { "template" : "hardware.html" }),
+                       (r"/legal", StaticHandler, { "template" : "legal.html" }),
+
                        # Handle old pages that have moved elsewhere
                        (r"/imprint", tornado.web.RedirectHandler, { "url" : "/legal" }),
-                       (r"/(de|en)/(.*)", LangCompatHandler)
-               ] + static_handlers + [
-                       # Always the last rule
-                       (r"/(.*)", StaticHandler),
+                       (r"/(de|en)/(.*)", LangCompatHandler),
+               ])
+
+               # blog.ipfire.org
+               self.add_handlers(r"blog(\.dev)?\.ipfire\.org", [
+                       (r"/", blog.IndexHandler),
+                       (r"/authors/(\w+)", blog.AuthorHandler),
+                       (r"/post/(.*)", blog.PostHandler),
+                       (r"/search", blog.SearchHandler),
                ])
 
                # downloads.ipfire.org
@@ -125,7 +142,6 @@ class Application(tornado.web.Application):
                        (r"/mirrors", tornado.web.RedirectHandler, { "url" : "https://mirrors.ipfire.org/" }),
                        (r"/source", tornado.web.RedirectHandler, { "url" : "https://source.ipfire.org/" }),
                        (r"/download-splash", DownloadSplashHandler),
-               ] + static_handlers + [
                        (r"/(iso|torrent)/(.*)", DownloadCompatHandler),
                        (r"/(.*)", DownloadFileHandler),
                ])
@@ -134,7 +150,7 @@ class Application(tornado.web.Application):
                self.add_handlers(r"mirrors(\.dev)?\.ipfire\.org", [
                        (r"/", MirrorIndexHandler),
                        (r"/mirror/(.*)", MirrorItemHandler),
-               ] + static_handlers)
+               ])
 
                # planet.ipfire.org
                self.add_handlers(r"planet(\.dev)?\.ipfire\.org", [
@@ -149,7 +165,7 @@ class Application(tornado.web.Application):
                        (r"/rss", RSSPlanetAllHandler),
                        (r"/user/([a-z0-9_-]+)/rss", RSSPlanetUserHandler),
                        (r"/news.rss", tornado.web.RedirectHandler, { "url" : "/rss" }),
-               ] + static_handlers)
+               ])
 
                # fireinfo.ipfire.org
                self.add_handlers(r"fireinfo(\.dev)?\.ipfire\.org", [
@@ -186,7 +202,7 @@ class Application(tornado.web.Application):
                        (r"/stats/virtual", tornado.web.RedirectHandler, { "url" : "/statistics/virtualization" }),
                        (r"/vendor/(pci|usb)/([0-9a-f]{4})", FireinfoDeviceVendorCompatHandler),
                        (r"/model/(pci|usb)/([0-9a-f]{4})/([0-9a-f]{4})", FireinfoDeviceModelCompatHandler),
-               ] + static_handlers)
+               ])
 
                # i-use.ipfire.org
                self.add_handlers(r"i-use(\.dev)?\.ipfire\.org", [
@@ -213,12 +229,12 @@ class Application(tornado.web.Application):
                        (r"/", NopasteCreateHandler),
                        (r"/raw/(.*)", NopasteRawHandler),
                        (r"/view/(.*)", NopasteViewHandler),
-               ] + authentication_handlers + static_handlers)
+               ] + authentication_handlers)
 
                # geoip.ipfire.org
                self.add_handlers(r"geoip(\.dev)?\.ipfire\.org", [
                        (r"/", GeoIPHandler),
-               ] + static_handlers)
+               ])
 
                # talk.ipfire.org
                self.add_handlers(r"talk(\.dev)?\.ipfire\.org", [
@@ -229,12 +245,12 @@ class Application(tornado.web.Application):
                        (r"/phonebook/(\w+)", TalkPhonebookAccountHandler),
                        (r"/phonebook", TalkPhonebookHandler),
                        (r"/profile", TalkProfileHandler),
-               ] + authentication_handlers + static_handlers)
+               ] + authentication_handlers)
 
                # accounts.ipfire.org
                self.add_handlers(r"accounts(\.dev)?\.ipfire\.org", [
                        (r"/avatar/(\w+)\.jpg", AccountsAvatarHandler),
-               ] + static_handlers)
+               ])
 
                # admin.ipfire.org
                self.add_handlers(r"admin(\.dev)?\.ipfire\.org", [
@@ -262,10 +278,10 @@ class Application(tornado.web.Application):
                        (r"/downloads/mirrors", AdminDownloadsMirrorsHandler),
                        # API
                        (r"/api/planet/render", AdminApiPlanetRenderMarkupHandler)
-               ] + authentication_handlers + static_handlers)
+               ] + authentication_handlers)
 
                # ipfire.org
-               self.add_handlers(r".*", [
+               self.add_handlers(r"ipfire\.org", [
                        (r".*", tornado.web.RedirectHandler, { "url" : "https://www.ipfire.org" })
                ])