diff --git a/base/templates/base/root.html b/base/templates/base/root.html index 0066226..1834a28 100644 --- a/base/templates/base/root.html +++ b/base/templates/base/root.html @@ -8,7 +8,19 @@ my name is {{ hostname|capfirst }} and I am your server right now.
- By the way, my clock says {{ time|time:'TIME_FORMAT'|default:'nothing' }}.
+ Did I say now?
+ My clock says {{ time|time:'TIME_FORMAT'|default:'nothing' }},
+ {% if time %}
+ and we are talking about the {{ time|time:'e' }} timezone.
+ {% else %}
+ and this is no good.
+ {% endif %}
+
+ {% with color_hex=color_hex|default:'47825b' %} + By the way, this is my favorite color: + #{{ color_hex }} + {% endwith %}
diff --git a/base/views.py b/base/views.py index e388ad2..3b0c7a3 100644 --- a/base/views.py +++ b/base/views.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +import re import socket from django.utils import timezone from django.views import generic @@ -11,6 +12,12 @@ class RootView(generic.TemplateView): def get_context_data(self, **kwargs): if 'hostname' not in kwargs: kwargs['hostname'] = socket.gethostname() + if 'color_hex' not in kwargs: + buf = kwargs['hostname'] + buf = re.sub('[-.]', '', buf) + buf = buf[:6].lower() + if re.match('[0-9a-f]{6}', buf): + kwargs['color_hex'] = buf if 'time' not in kwargs: kwargs['time'] = timezone.now() return super(RootView, self).get_context_data(**kwargs)