Switch avatars to be built out of CSS and only overlayed with the gravatar when a non-default exists
This commit is contained in:
parent
2d8d0c6fd3
commit
27a9b84587
94 changed files with 663 additions and 303 deletions
|
@ -9,25 +9,29 @@ def icon_path(icon_name):
|
|||
def icon_image(icon_name):
|
||||
return '<img src="%s" alt="%s">' % (icon_path(icon_name), icon_name)
|
||||
|
||||
def team_reference(teamname):
|
||||
avatar_html = avatar.get_mail_html(teamname, teamname, 24, 'team')
|
||||
return "<span>%s <b>%s</b></span>" % (avatar_html, teamname)
|
||||
|
||||
def user_reference(username):
|
||||
user = model.get_namespace_user(username)
|
||||
if not user:
|
||||
return username
|
||||
|
||||
is_robot = False
|
||||
if user.robot:
|
||||
parts = parse_robot_username(username)
|
||||
user = model.get_namespace_user(parts[0])
|
||||
|
||||
return """<span><img src="%s" alt="Robot"> <b>%s</b></span>""" % (icon_path('wrench'), username)
|
||||
|
||||
alt = 'Organization' if user.organization else 'User'
|
||||
avatar_html = avatar.get_mail_html(user.username, user.email, 24,
|
||||
'org' if user.organization else 'user')
|
||||
|
||||
return """
|
||||
<span>
|
||||
<img src="%s"
|
||||
style="vertical-align: middle; margin-left: 6px; margin-right: 4px;" alt="%s">
|
||||
%s
|
||||
<b>%s</b>
|
||||
</span>""" % (avatar.get_url(user.email, 16), alt, username)
|
||||
</span>""" % (avatar_html, username)
|
||||
|
||||
|
||||
def repository_tag_reference(repository_path_and_tag):
|
||||
|
@ -52,12 +56,15 @@ def repository_reference(pair):
|
|||
if not owner:
|
||||
return "%s/%s" % (namespace, repository)
|
||||
|
||||
avatar_html = avatar.get_mail_html(owner.username, owner.email, 16,
|
||||
'org' if owner.organization else 'user')
|
||||
|
||||
return """
|
||||
<span style="white-space: nowrap;">
|
||||
<img src="%s" style="vertical-align: middle; margin-left: 6px; margin-right: 4px;">
|
||||
%s
|
||||
<a href="%s/repository/%s/%s">%s/%s</a>
|
||||
</span>
|
||||
""" % (avatar.get_url(owner.email, 16), get_app_url(), namespace, repository, namespace, repository)
|
||||
""" % (avatar_html, get_app_url(), namespace, repository, namespace, repository)
|
||||
|
||||
|
||||
def admin_reference(username):
|
||||
|
@ -84,6 +91,7 @@ def get_template_env(searchpath):
|
|||
|
||||
def add_filters(template_env):
|
||||
template_env.filters['icon_image'] = icon_image
|
||||
template_env.filters['team_reference'] = team_reference
|
||||
template_env.filters['user_reference'] = user_reference
|
||||
template_env.filters['admin_reference'] = admin_reference
|
||||
template_env.filters['repository_reference'] = repository_reference
|
||||
|
|
Reference in a new issue