]> git.ipfire.org Git - ipfire.org.git/blobdiff - src/web/__init__.py
Migrate to libloc
[ipfire.org.git] / src / web / __init__.py
index 4821c43824ec55176d6f6401b34bb66593558773..eec28f2dc1bf1e5423380fb976455f312319146b 100644 (file)
@@ -11,6 +11,7 @@ import tornado.web
 
 import ipfire
 import ipfire.countries
+from .. import util
 
 from .handlers import *
 
@@ -49,6 +50,7 @@ class Application(tornado.web.Application):
 
                        # UI Methods
                        "ui_methods" : {
+                               "format_asn"                   : self.format_asn,
                                "format_country_name"          : self.format_country_name,
                                "format_language_name"         : self.format_language_name,
                                "format_month_name"            : self.format_month_name,
@@ -152,7 +154,7 @@ class Application(tornado.web.Application):
                ])
 
                # blog.ipfire.org
-               self.add_handlers(r"blog(\.dev)?\.ipfire\.org", [
+               self.add_handlers(r"blog\.ipfire\.org", [
                        (r"/", blog.IndexHandler),
                        (r"/authors/(\w+)", blog.AuthorHandler),
                        (r"/compose", blog.ComposeHandler),
@@ -170,20 +172,20 @@ class Application(tornado.web.Application):
                ] + authentication_handlers)
 
                # downloads.ipfire.org
-               self.add_handlers(r"downloads?(\.dev)?\.ipfire\.org", [
+               self.add_handlers(r"downloads?\.ipfire\.org", [
                        (r"/", tornado.web.RedirectHandler, { "url" : "https://www.ipfire.org/" }),
                        (r"/release/(.*)", download.ReleaseRedirectHandler),
                        (r"/(.*)", download.FileHandler),
                ])
 
                # mirrors.ipfire.org
-               self.add_handlers(r"mirrors(\.dev)?\.ipfire\.org", [
+               self.add_handlers(r"^mirrors\.ipfire\.org", [
                        (r"/", mirrors.IndexHandler),
                        (r"/mirrors/(.*)", mirrors.MirrorHandler),
                ])
 
                # planet.ipfire.org
-               self.add_handlers(r"planet(\.dev)?\.ipfire\.org", [
+               self.add_handlers(r"planet\.ipfire\.org", [
                        (r"/", tornado.web.RedirectHandler, { "url" : "https://blog.ipfire.org/" }),
                        (r"/post/([A-Za-z0-9_-]+)", handlers.PlanetPostHandler),
                        (r"/user/([a-z0-9_-]+)", handlers.PlanetUserHandler),
@@ -195,7 +197,7 @@ class Application(tornado.web.Application):
                ])
 
                # fireinfo.ipfire.org
-               self.add_handlers(r"fireinfo(\.dev)?\.ipfire\.org", [
+               self.add_handlers(r"fireinfo\.ipfire\.org", [
                        (r"/", fireinfo.IndexHandler),
 
                        # Admin
@@ -221,7 +223,7 @@ class Application(tornado.web.Application):
                ] + authentication_handlers)
 
                # i-use.ipfire.org
-               self.add_handlers(r"i-use(\.dev)?\.ipfire\.org", [
+               self.add_handlers(r"i-use\.ipfire\.org", [
                        (r"/", tornado.web.RedirectHandler, { "url" : "https://www.ipfire.org/" }),
                        (r"/profile/([a-f0-9]{40})/([0-9]+).png", iuse.ImageHandler),
                ])
@@ -242,14 +244,14 @@ class Application(tornado.web.Application):
                ])
 
                # nopaste.ipfire.org
-               self.add_handlers(r"nopaste(\.dev)?\.ipfire\.org", [
+               self.add_handlers(r"nopaste\.ipfire\.org", [
                        (r"/", nopaste.CreateHandler),
                        (r"/raw/(.*)", nopaste.RawHandler),
                        (r"/view/(.*)", nopaste.ViewHandler),
                ] + authentication_handlers)
 
                # location.ipfire.org
-               self.add_handlers(r"location(\.dev)?\.ipfire\.org", [
+               self.add_handlers(r"location\.ipfire\.org", [
                        (r"/", location.IndexHandler),
                        (r"/how\-to\-use", StaticHandler, { "template" : "../location/how-to-use.html" }),
                        (r"/lookup/(.+)/blacklists", location.BlacklistsHandler),
@@ -257,17 +259,17 @@ class Application(tornado.web.Application):
                ])
 
                # geoip.ipfire.org
-               self.add_handlers(r"geoip(\.dev)?\.ipfire\.org", [
+               self.add_handlers(r"geoip\.ipfire\.org", [
                        (r"/", tornado.web.RedirectHandler, { "url" : "https://location.ipfire.org/" }),
                ])
 
                # talk.ipfire.org
-               self.add_handlers(r"talk(\.dev)?\.ipfire\.org", [
+               self.add_handlers(r"talk\.ipfire\.org", [
                        (r"/", tornado.web.RedirectHandler, { "url" : "https://people.ipfire.org/" }),
                ])
 
                # people.ipfire.org
-               self.add_handlers(r"people(\.dev)?\.ipfire\.org", [
+               self.add_handlers(r"people\.ipfire\.org", [
                        (r"/", people.IndexHandler),
                        (r"/activate/([a-z_][a-z0-9_-]{0,31})/(\w+)", auth.ActivateHandler),
                        (r"/conferences", people.ConferencesHandler),
@@ -304,7 +306,7 @@ class Application(tornado.web.Application):
                ]  + authentication_handlers)
 
                # wiki.ipfire.org
-               self.add_handlers(r"wiki(\.dev)?\.ipfire\.org",
+               self.add_handlers(r"wiki\.ipfire\.org",
                        authentication_handlers + [
 
                        # Actions
@@ -335,6 +337,9 @@ class Application(tornado.web.Application):
 
                logging.info("Successfully initialied application")
 
+       def format_asn(self, handler, asn):
+               return util.format_asn(asn)
+
        def format_country_name(self, handler, country_code):
                return ipfire.countries.get_name(country_code)