From 4ca1a601af24094bd62a4103f7ef99914488bad4 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 17 Mar 2015 21:56:10 +0100 Subject: [PATCH] Replace hostname replacement function and make it better accessible --- webapp/handlers_base.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/webapp/handlers_base.py b/webapp/handlers_base.py index 4051ced0..b6ccdff5 100644 --- a/webapp/handlers_base.py +++ b/webapp/handlers_base.py @@ -22,23 +22,25 @@ class BaseHandler(tornado.web.RequestHandler): def get_user_locale(self): # The planet is always in english. - if self.request.host == "planet.ipfire.org": + if self.hostname == "planet.ipfire.org": return tornado.locale.get("en_US") # Otherwise take the browser locale. return self.get_browser_locale() + @property + def hostname(self): + # Remove the development prefix + return self.request.host.replace(".dev.", ".") + @property def render_args(self): today = datetime.date.today() - # Get the requested host and remove the development prefix - hostname = self.request.host.replace(".dev.", ".") - return { "format_size" : backend.util.format_size, "format_time" : backend.util.format_time, - "hostname" : hostname, + "hostname" : self.hostname, "lang" : self.locale.code[:2], "rss_url" : self.rss_url, "year" : today.year, -- 2.47.3