From 3f9d2e5599d8e298615ea13265fd99987aaeda1c Mon Sep 17 00:00:00 2001 From: Corentin Chary Date: Tue, 19 Apr 2011 11:32:48 +0200 Subject: [PATCH] euscanwww: better index Thanks to George Prowse for the idea. Signed-off-by: Corentin Chary --- euscanwww/euscan/templatetags/timedelta.py | 19 +++++++++++++++++++ euscanwww/templates/euscan/index.html | 6 ++++-- 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 euscanwww/euscan/templatetags/timedelta.py diff --git a/euscanwww/euscan/templatetags/timedelta.py b/euscanwww/euscan/templatetags/timedelta.py new file mode 100644 index 0000000..486ceeb --- /dev/null +++ b/euscanwww/euscan/templatetags/timedelta.py @@ -0,0 +1,19 @@ +from django import template +from django.utils.timesince import timesince +from datetime import datetime + +register = template.Library() + +def timedelta(value, arg=None): + if not value: + return '' + if arg: + cmp = arg + else: + cmp = datetime.now() + if value > cmp: + return "in %s" % timesince(cmp,value) + else: + return "%s ago" % timesince(value,cmp) + +register.filter('timedelta',timedelta) diff --git a/euscanwww/templates/euscan/index.html b/euscanwww/templates/euscan/index.html index cd6a613..0ed40c4 100644 --- a/euscanwww/templates/euscan/index.html +++ b/euscanwww/templates/euscan/index.html @@ -1,5 +1,7 @@ {% extends "_base.html" %} +{% load timedelta %} + {% block content %}

What's euscan ?

@@ -17,7 +19,7 @@ euscan code source is available at