]> git.ipfire.org Git - ipfire.org.git/blobdiff - src/web/__init__.py
people: List ongoing conferences
[ipfire.org.git] / src / web / __init__.py
index f897e8220fcf1d7e7a92c4485fc3e2dfc1b6e943..20c3f2ced712c9026cc480f745d2512c62c348bf 100644 (file)
@@ -3,6 +3,8 @@
 import logging
 import itertools
 import os.path
+import phonenumbers
+import phonenumbers.geocoder
 import tornado.locale
 import tornado.options
 import tornado.web
@@ -11,12 +13,12 @@ import ipfire
 
 from .handlers import *
 
-from . import accounts
 from . import auth
 from . import blog
 from . import download
 from . import location
-from . import talk
+from . import newsletter
+from . import people
 from . import ui_modules
 
 class Application(tornado.web.Application):
@@ -40,12 +42,13 @@ class Application(tornado.web.Application):
 
                        # UI Modules
                        "ui_methods" : {
-                               "format_month_name" : self.format_month_name,
-                               "grouper"           : grouper,
+                               "format_month_name"            : self.format_month_name,
+                               "format_phone_number"          : self.format_phone_number,
+                               "format_phone_number_to_e164"  : self.format_phone_number_to_e164,
+                               "format_phone_number_location" : self.format_phone_number_location,
+                               "grouper"                      : grouper,
                        },
                        "ui_modules" : {
-                               "Menu"                 : ui_modules.MenuModule,
-
                                # Blog
                                "BlogHistoryNavigation": blog.HistoryNavigationModule,
                                "BlogList"             : blog.ListModule,
@@ -56,10 +59,12 @@ class Application(tornado.web.Application):
                                "Map"                  : ui_modules.MapModule,
 
                                # Talk
-                               "TalkAccountsList"     : talk.AccountsListModule,
-                               "TalkCDR"              : talk.CDRModule,
-                               "TalkChannels"         : talk.ChannelsModule,
-                               "TalkRegistrations"    : talk.RegistrationsModule,
+                               "AccountsList"         : people.AccountsListModule,
+                               "CDR"                  : people.CDRModule,
+                               "Channels"             : people.ChannelsModule,
+                               "MOS"                  : people.MOSModule,
+                               "Registrations"        : people.RegistrationsModule,
+                               "SIPStatus"            : people.SIPStatusModule,
 
                                # Old modules
                                "LanguageName"         : ui_modules.LanguageNameModule,
@@ -100,6 +105,9 @@ class Application(tornado.web.Application):
                        (r"/donate", DonateHandler),
                        (r"/donation", tornado.web.RedirectHandler, { "url" : "/donate" }),
 
+                       # Newsletter
+                       (r"/newsletter/subscribe", newsletter.SubscribeHandler),
+
                        # RSS feed
                        (r"/news.rss", tornado.web.RedirectHandler, { "url" : "https://blog.ipfire.org/feed.xml" }),
 
@@ -107,12 +115,10 @@ class Application(tornado.web.Application):
                        (r"/news/(.*)", tornado.web.RedirectHandler, { "url" : "https://blog.ipfire.org/posts/{1}" }),
 
                        # Static Pages
+                       (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" }),
+                       (r"/support", StaticHandler, { "template" : "support.html" }),
 
                        # Handle old pages that have moved elsewhere
                        (r"/imprint", tornado.web.RedirectHandler, { "url" : "/legal" }),
@@ -120,6 +126,9 @@ class Application(tornado.web.Application):
 
                        # Export arbitrary error pages
                        (r"/error/([45][0-9]{2})", ErrorHandler),
+
+                       # Block page
+                       (r"/blocked", BlockedHandler),
                ])
 
                # blog.ipfire.org
@@ -128,9 +137,9 @@ class Application(tornado.web.Application):
                        (r"/authors/(\w+)", blog.AuthorHandler),
                        (r"/compose", blog.ComposeHandler),
                        (r"/drafts", blog.DraftsHandler),
-                       (r"/post/([0-9a-z\-\.]+)", blog.PostHandler),
-                       (r"/post/([0-9a-z\-\.]+)/edit", blog.EditHandler),
-                       (r"/post/([0-9a-z\-\.]+)/publish", blog.PublishHandler),
+                       (r"/post/([0-9a-z\-\._]+)", blog.PostHandler),
+                       (r"/post/([0-9a-z\-\._]+)/edit", blog.EditHandler),
+                       (r"/post/([0-9a-z\-\._]+)/publish", blog.PublishHandler),
                        (r"/search", blog.SearchHandler),
                        (r"/tags/([0-9a-z\-\.]+)", blog.TagHandler),
                        (r"/years/([0-9]+)", blog.YearHandler),
@@ -240,51 +249,27 @@ class Application(tornado.web.Application):
 
                # talk.ipfire.org
                self.add_handlers(r"talk(\.dev)?\.ipfire\.org", [
-                       (r"/", talk.IndexHandler),
-                       (r"/search", talk.SearchHandler),
-                       (r"/users", talk.UsersHandler),
-                       (r"/users/(\w+)", talk.UserHandler),
-                       (r"/users/(\w+)/registrations", talk.RegistrationsHandler),
-                       (r"/conferences", TalkConferencesHandler),
-                       (r"/diagnosis", TalkDiagnosisHandler),
-                       (r"/hangup/(.*)", TalkHangupChannelHandler),
-                       (r"/phonebook/(\w+)", TalkPhonebookAccountHandler),
-                       (r"/phonebook", TalkPhonebookHandler),
-                       (r"/profile", TalkProfileHandler),
-               ] + authentication_handlers)
-
-               # accounts.ipfire.org
-               self.add_handlers(r"accounts(\.dev)?\.ipfire\.org", [
-                       (r"/avatar/(\w+)\.jpg", accounts.AvatarHandler),
+                       (r"/", tornado.web.RedirectHandler, { "url" : "https://people.ipfire.org/" }),
                ])
 
-               # admin.ipfire.org
-               self.add_handlers(r"admin(\.dev)?\.ipfire\.org", [
-                       (r"/", AdminIndexHandler),
-                       # Accounts
-                       (r"/accounts", AdminAccountsHandler),
-                       #(r"/accounts/delete/([0-9]+)", AdminAccountsDeleteHandler),
-                       #(r"/accounts/edit/([0-9]+)", AdminAccountsEditHandler),
-                       # Planet
-                       (r"/planet", AdminPlanetHandler),
-                       (r"/planet/compose", AdminPlanetComposeHandler),
-                       (r"/planet/edit/(.*)", AdminPlanetEditHandler),
-                       (r"/planet/publish/(.*)", AdminPlanetPublishHandler),
-                       # Mirrors
-                       (r"/mirrors", AdminMirrorsHandler),
-                       (r"/mirrors/create", AdminMirrorsCreateHandler),
-                       (r"/mirrors/delete/([0-9]+)", AdminMirrorsDeleteHandler),
-                       (r"/mirrors/edit/([0-9]+)", AdminMirrorsEditHandler),
-                       (r"/mirrors/details/([0-9]+)", AdminMirrorsDetailsHandler),
-                       (r"/mirrors/update", AdminMirrorsUpdateHandler),
-                       # Fireinfo
-                       (r"/fireinfo", AdminFireinfoHandler),
-                       # Downloads
-                       (r"/downloads", AdminDownloadsHandler),
-                       (r"/downloads/mirrors", AdminDownloadsMirrorsHandler),
-                       # API
-                       (r"/api/planet/render", AdminApiPlanetRenderMarkupHandler)
-               ] + authentication_handlers)
+               # people.ipfire.org
+               self.add_handlers(r"people(\.dev)?\.ipfire\.org", [
+                       (r"/", people.IndexHandler),
+                       (r"/conferences", people.ConferencesHandler),
+                       (r"/search", people.SearchHandler),
+                       (r"/users", people.UsersHandler),
+                       (r"/users/(\w+)", people.UserHandler),
+                       (r"/users/(\w+)\.jpg", people.AvatarHandler),
+                       (r"/users/(\w+)/calls/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})", people.CallHandler),
+                       (r"/users/(\w+)/calls(?:/(\d{4}-\d{2}-\d{2}))?", people.CallsHandler),
+                       (r"/users/(\w+)/edit", people.UserEditHandler),
+                       (r"/users/(\w+)/passwd", people.UserPasswdHandler),
+                       (r"/users/(\w+)/ssh-keys", people.SSHKeysIndexHandler),
+                       (r"/users/(\w+)/ssh-keys/(SHA256\:.*)/delete", people.SSHKeysDeleteHandler),
+                       (r"/users/(\w+)/ssh-keys/(SHA256\:.*)", people.SSHKeysDownloadHandler),
+                       (r"/users/(\w+)/ssh-keys/upload", people.SSHKeysUploadHandler),
+                       (r"/users/(\w+)/sip", people.SIPHandler),
+               ]  + authentication_handlers)
 
                # ipfire.org
                self.add_handlers(r"ipfire\.org", [
@@ -323,6 +308,26 @@ class Application(tornado.web.Application):
 
                return month
 
+       def format_phone_number(self, handler, number):
+               if not isinstance(number, phonenumbers.PhoneNumber):
+                       try:
+                               number = phonenumbers.parse(number, None)
+                       except phonenumbers.phonenumberutil.NumberParseException:
+                               return number
+
+               return phonenumbers.format_number(number, phonenumbers.PhoneNumberFormat.INTERNATIONAL)
+
+       def format_phone_number_to_e164(self, handler, number):
+               return phonenumbers.format_number(number, phonenumbers.PhoneNumberFormat.E164)
+
+       def format_phone_number_location(self, handler, number):
+               s = [
+                       phonenumbers.geocoder.description_for_number(number, handler.locale.code),
+                       phonenumbers.region_code_for_number(number),
+               ]
+
+               return ", ".join((e for e in s if e))
+
 
 def grouper(handler, iterator, n):
        """