]> git.ipfire.org Git - ipfire.org.git/blobdiff - webapp/__init__.py
planet: Add yearly summary.
[ipfire.org.git] / webapp / __init__.py
index 95c034d783819f81c189588b7a679cbb84884c96..bae754765f2adeff24e0ac2e48800fd113bb2099 100644 (file)
@@ -28,6 +28,9 @@ class Application(tornado.web.Application):
                        gzip = True,
                        login_url = "/login",
                        template_path = os.path.join(BASEDIR, "templates"),
+                       ui_methods = {
+                               "format_month_name" : self.format_month_name,
+                       },
                        ui_modules = {
                                "Advertisement"  : AdvertisementModule,
                                "DonationBox"    : DonationBoxModule,
@@ -123,6 +126,7 @@ class Application(tornado.web.Application):
                        (r"/post/([A-Za-z0-9_-]+)", PlanetPostingHandler),
                        (r"/user/([a-z0-9_-]+)", PlanetUserHandler),
                        (r"/search", PlanetSearchHandler),
+                       (r"/year/(\d+)", PlanetYearHandler),
 
                        # RSS
                        (r"/rss", RSSPlanetAllHandler),
@@ -266,3 +270,33 @@ class Application(tornado.web.Application):
 
        def reload(self):
                logging.debug("Caught reload signal")
+
+       def format_month_name(self, handler, month):
+               _ = handler.locale.translate
+
+               if month == 1:
+                       return _("January")
+               elif month == 2:
+                       return _("February")
+               elif month == 3:
+                       return _("March")
+               elif month == 4:
+                       return _("April")
+               elif month == 5:
+                       return _("May")
+               elif month == 6:
+                       return _("June")
+               elif month == 7:
+                       return _("July")
+               elif month == 8:
+                       return _("August")
+               elif month == 9:
+                       return _("September")
+               elif month == 10:
+                       return _("October")
+               elif month == 11:
+                       return _("November")
+               elif month == 12:
+                       return _("December")
+
+               return month