Mercurial > kallithea
changeset 5894:74f0df038ccd
helpers: introduce gravatar_div returning div around gravatar
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Wed, 04 May 2016 01:18:25 +0200 |
parents | 8d01c8a72bb5 |
children | f287754980cc |
files | kallithea/lib/helpers.py |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/helpers.py Wed May 04 01:18:25 2016 +0200 +++ b/kallithea/lib/helpers.py Wed May 04 01:18:25 2016 +0200 @@ -839,6 +839,21 @@ #============================================================================== # GRAVATAR URL #============================================================================== +def gravatar_div(email_address, cls='', size=30, **div_attributes): + """Return an html literal with a div around a gravatar. + Extra keyword parameters starting with 'div_' will get the prefix removed + and be used as attributes on the div. The default class is 'gravatar'. + """ + if 'div_class' not in div_attributes: + div_attributes['div_class'] = "gravatar" + attributes = [] + for k, v in sorted(div_attributes.items()): + assert k.startswith('div_'), k + attributes.append(' %s="%s"' % (k[4:], escape(v))) + return literal("""<div%s>%s</div>""" % + (''.join(attributes), + gravatar(email_address, cls=cls, size=size))) + def gravatar(email_address, cls='', size=30): """return html element of the gravatar