Add a configurable avatar system and add an internal avatar system for enterprise

This commit is contained in:
Joseph Schorr 2014-11-24 19:25:13 -05:00
parent f6dd8b0a4d
commit e9cac407df
36 changed files with 241 additions and 92 deletions

View file

@ -1,5 +0,0 @@
import hashlib
def compute_hash(email_address):
return hashlib.md5(email_address.strip().lower()).hexdigest()

View file

@ -1,6 +1,5 @@
from app import get_app_url
from app import get_app_url, avatar
from data import model
from util.gravatar import compute_hash
from util.names import parse_robot_username
from jinja2 import Template, Environment, FileSystemLoader, contextfilter
@ -25,10 +24,10 @@ def user_reference(username):
alt = 'Organization' if user.organization else 'User'
return """
<span>
<img src="http://www.gravatar.com/avatar/%s?s=16&amp;d=identicon"
<img src="%s"
style="vertical-align: middle; margin-left: 6px; margin-right: 4px;" alt="%s">
<b>%s</b>
</span>""" % (compute_hash(user.email), alt, username)
</span>""" % (avatar.get_url(user.email, 16), alt, username)
def repository_tag_reference(repository_path_and_tag):
@ -55,10 +54,10 @@ def repository_reference(pair):
return """
<span style="white-space: nowrap;">
<img src="http://www.gravatar.com/avatar/%s?s=16&amp;d=identicon" style="vertical-align: middle; margin-left: 6px; margin-right: 4px;">
<img src="%s" style="vertical-align: middle; margin-left: 6px; margin-right: 4px;">
<a href="%s/repository/%s/%s">%s/%s</a>
</span>
""" % (compute_hash(owner.email), get_app_url(), namespace, repository, namespace, repository)
""" % (avatar.get_url(owner.email, 16), get_app_url(), namespace, repository, namespace, repository)
def admin_reference(username):

View file

@ -5,7 +5,6 @@ from flask.ext.mail import Message
from app import mail, app, get_app_url
from data import model
from util.gravatar import compute_hash
from util.jinjautil import get_template_env
logger = logging.getLogger(__name__)