# HG changeset patch # User Mads Kiilerich # Date 1462317505 -7200 # Node ID 74f0df038ccd12c261437d9d3833034323996805 # Parent 8d01c8a72bb58095cc692160167d7832a89f15e7 helpers: introduce gravatar_div returning div around gravatar diff -r 8d01c8a72bb5 -r 74f0df038ccd kallithea/lib/helpers.py --- 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("""%s""" % + (''.join(attributes), + gravatar(email_address, cls=cls, size=size))) + def gravatar(email_address, cls='', size=30): """return html element of the gravatar