# Find the name of the author
return self.accounts.find(uid)
- def get_user_locale(self):
- # The planet is always in english.
- 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 ssl_params(self):
+ return {
+ "ssl_cipher" : self.request.headers.get("X-Https-Cipher", None),
+ "ssl_protocol" : self.request.headers.get("X-Https-Protocol", None),
+ }
+
@property
def render_args(self):
today = datetime.date.today()
- return {
+ ret = {
"format_size" : backend.util.format_size,
"format_time" : backend.util.format_time,
"hostname" : self.hostname,
- "lang" : self.locale.code[:2],
"rss_url" : self.rss_url,
"year" : today.year,
}
+ ret.update(self.ssl_params)
+
+ return ret
def render(self, *args, **_kwargs):
kwargs = self.render_args
if self.settings.get("debug", False):
return ret
- elif self.request.host == "admin.ipfire.org":
- return ret
-
- elif static:
- return "http://static.ipfire.org%s" % ret
+ if static:
+ return "//static.ipfire.org%s" % ret
return ret
def get_remote_ip(self):
# Fix for clients behind a proxy that sends "X-Forwarded-For".
remote_ips = self.request.remote_ip.split(", ")
+
for remote_ip in remote_ips:
try:
addr = ipaddr.IPAddress(remote_ip)
return remote_ip
+ # Return the last IP if nothing else worked
+ return remote_ips.pop()
+
def get_remote_location(self):
if not hasattr(self, "__remote_location"):
remote_ip = self.get_remote_ip()
def planet(self):
return self.backend.planet
- @property
- def wishlist(self):
- return self.backend.wishlist
-
class LoginHandler(BaseHandler):
def get(self):