from django import template
register = template.Library()

@register.filter
def mult(value, arg):
	if value is None:
		return arg
	return value * arg

@@ -139,12 +139,885 @@
 value * arg%0A
+%0Aimport urllib, hashlib%0Afrom django.utils.translation import ugettext as _%0Afrom random import choice%0A%0Aclass Gravatar(template.Node):%0A%09def __init__(self, email_from_template):%0A%09%09self.email = template.Variable(email_from_template)%0A%09def render(self, context):%0A%09%09default = choice((%22identicon%22, %22monsterid%22, %22wavatar%22))%0A%09%09size = 55%0A%09%09gravatar_url = %22http://www.gravatar.com/avatar/%22%0A%09%09try:%0A%09%09%09gravatar_url += hashlib.md5(self.email.resolve(context)).hexdigest() + %22?%22%0A%09%09except:%0A%09%09%09gravatar_url += %22?%22%0A%09%09gravatar_url += urllib.urlencode(%7B'd':default, 'size':str(size)%7D)%0A%09%09return gravatar_url%09%09%0A%0Adef get_gravatar_url(parser, token):%0A%09try:%0A%09%09tag_name, email_from_template = token.split_contents()%0A%09except ValueError:%0A%09%09raise TemplateSyntaxError(%0A%09%09%09_('tag requires exactly two arguments'))%0A%09return Gravatar(email_from_template)%0A%09%0Aregister.tag('get_gravatar_url', get_gravatar_url)%0A

Add Gravatar support