Changeset - 74f0df038ccd
[Not reviewed]
default
0 1 0
Mads Kiilerich - 10 years ago 2016-05-04 01:18:25
madski@unity3d.com
helpers: introduce gravatar_div returning div around gravatar
1 file changed with 15 insertions and 0 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/helpers.py
Show inline comments
 
@@ -836,12 +836,27 @@ HasRepoPermissionAny, HasRepoPermissionA
 
HasRepoGroupPermissionAny
 

	
 

	
 
#==============================================================================
 
# 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
 

	
 
    This method will return an <img> with the resolution double the size (for
 
    retina screens) of the image. If the url returned from gravatar_url is
 
    empty then we fallback to using an icon.
0 comments (0 inline, 0 general)