diff --git a/src/accounts/templatetags/__init__.py b/src/accounts/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/accounts/templatetags/__init__.py diff --git a/src/accounts/templatetags/gravatar.py b/src/accounts/templatetags/gravatar.py new file mode 100644 index 0000000..bc57069 --- /dev/null +++ b/src/accounts/templatetags/gravatar.py @@ -0,0 +1,20 @@ + +from django import template + +from super_archives.models import EmailAddress + + +register = template.Library() + + +@register.simple_tag +def gravatar(email, size=80): + if isinstance(email, basestring): + try: + email = EmailAddress.objects.get(address=email) + except EmailAddress.DoesNotExist: + pass + + email_md5 = getattr(email, 'md5', 'anonymous') + + return u''.format(email_md5, size, size, size) diff --git a/src/super_archives/templates/message-thread.html b/src/super_archives/templates/message-thread.html index c8eb5ee..d4a1cf6 100644 --- a/src/super_archives/templates/message-thread.html +++ b/src/super_archives/templates/message-thread.html @@ -1,6 +1,7 @@ {% extends "base.html" %} {% load i18n %} {% load append_to_get %} +{% load gravatar %} {% block main-content %}
@@ -47,8 +48,7 @@