From: Michael Tremer Date: Tue, 17 Mar 2015 20:56:10 +0000 (+0100) Subject: Replace hostname replacement function and make it better accessible X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4ca1a601af24094bd62a4103f7ef99914488bad4;p=ipfire.org.git Replace hostname replacement function and make it better accessible --- 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,