scripts/wiki-lenny/local/macro/Gravatar.py
Antoine Durand-Gasselin 6b0022645d [wiki] on arrete de balancer du HTML
Ces macros sont appel'ees par getpagelinks. Si elles balancent n'importe
quoi lorsqu'on cherche a obtenir leurs liens, CategoriePagePublique
n'apparait pas...

darcs-hash:20090427142002-bd074-46977e63783af21b013023b46ee7e289020f28a7.gz
2009-04-27 16:20:02 +02:00

21 lines
731 B
Python

# -*- coding: iso-8859-1 -*-
"""
MoinMoin - Gravatar Macro
Gregoire Detrez, 2007
v 0.0.1
You can include a gravatar image by using this macro
[[Gravatar(name@exemple.com)]]
"""
def execute(macro, text):
import md5
parseargs = text.split(',')
if len(parseargs)<2:
return '<small><strong class="error">MailTo macro must have at least two arguments</strong></small>'
emailname, emailurl= parseargs[:2]
email = emailname.strip() + "@" + emailurl.strip()
user_id = md5.md5( email.strip() ).hexdigest()
url = 'http://www.gravatar.com/avatar.php?gravatar_id=%s&size=80' % user_id
html = "<img src=\"%s\" alt=\"Gravatar\" />" % url
return macro.formatter.rawHTML(html)