Fix various bugs and styling issues

This commit is contained in:
Joseph Schorr 2014-11-24 19:40:03 -05:00
parent 7bf96c506f
commit 0e13ef3ff8
6 changed files with 15 additions and 10 deletions

View file

@ -76,7 +76,7 @@ IMPLIED_SCOPES = {
def scopes_from_scope_string(scopes): def scopes_from_scope_string(scopes):
if not scopes: if not scopes:
return {} scopes = ''
return {ALL_SCOPES.get(scope, None) for scope in scopes.split(',')} return {ALL_SCOPES.get(scope, None) for scope in scopes.split(',')}

View file

@ -35,6 +35,7 @@ class BaseAvatar(object):
class GravatarAvatar(BaseAvatar): class GravatarAvatar(BaseAvatar):
""" Avatar system that uses gravatar for generating avatars. """ """ Avatar system that uses gravatar for generating avatars. """
def compute_hash(self, email, name=None): def compute_hash(self, email, name=None):
email = email or ""
return hashlib.md5(email.strip().lower()).hexdigest() return hashlib.md5(email.strip().lower()).hexdigest()
def get_url(self, email, size=16, name=None): def get_url(self, email, size=16, name=None):
@ -45,6 +46,7 @@ class GravatarAvatar(BaseAvatar):
class LocalAvatar(BaseAvatar): class LocalAvatar(BaseAvatar):
""" Avatar system that uses the local system for generating avatars. """ """ Avatar system that uses the local system for generating avatars. """
def compute_hash(self, email, name=None): def compute_hash(self, email, name=None):
email = email or ""
if not name and not email: if not name and not email:
return '' return ''

View file

@ -184,7 +184,7 @@ def status():
@app.route("/avatar/<avatar_hash>") @app.route("/avatar/<avatar_hash>")
def avatar(avatar_hash): def render_avatar(avatar_hash):
try: try:
size = int(request.args.get('size', 16)) size = int(request.args.get('size', 16))
except ValueError: except ValueError:
@ -424,10 +424,11 @@ def request_authorization_code():
'name': oauth_app.name, 'name': oauth_app.name,
'description': oauth_app.description, 'description': oauth_app.description,
'url': oauth_app.application_uri, 'url': oauth_app.application_uri,
'avatar': avatar.compute_hash(oauth_app.avatar_email, name=oauth_app.name),
'organization': { 'organization': {
'name': oauth_app.organization.username, 'name': oauth_app.organization.username,
'avatar': avatar.compute_hash(oauth_app.organization.email, 'avatar': avatar.compute_hash(oauth_app.organization.email,
name=oauth_app.organization.name) name=oauth_app.organization.username)
} }
} }

View file

@ -4256,9 +4256,10 @@ pre.command:before {
display: block !important; display: block !important;
} }
.auth-header > img { .auth-header > .avatar {
float: left; float: left;
margin-top: 8px; display: inline-block;
margin-top: 12px;
margin-right: 20px; margin-right: 20px;
} }

View file

@ -7,8 +7,8 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="auth-header"> <div class="auth-header">
<h2><span class="avatar" size="48" email="application.avatar_email" name="application.name"></span> <span class="avatar" size="48" email="application.avatar_email" name="application.name"></span>
{{ application.name || '(Untitled)' }}</h2> <h2>{{ application.name || '(Untitled)' }}</h2>
<h4> <h4>
<span class="avatar" size="24" hash="organization.avatar" style="vertical-align: middle; margin-right: 4px;"></span> <span class="avatar" size="24" hash="organization.avatar" style="vertical-align: middle; margin-right: 4px;"></span>
<span style="vertical-align: middle"><a href="/organization/{{ organization.name }}/admin">{{ organization.name }}</a></span> <span style="vertical-align: middle"><a href="/organization/{{ organization.name }}/admin">{{ organization.name }}</a></span>
@ -99,7 +99,8 @@
</div> </div>
<div style="margin-bottom: 20px"> <div style="margin-bottom: 20px">
<strong>Note:</strong> The generated token will act on behalf of user <img src="//www.gravatar.com/avatar/{{ user.gravatar }}?s=16&d=identicon" style="margin-left: 6px; margin-right: 4px;"> <strong>Note:</strong> The generated token will act on behalf of user
<span class="avatar" hash="user.avatar" size="16" style="margin-left: 6px; margin-right: 4px;"></span>
{{ user.username }} {{ user.username }}
</div> </div>

View file

@ -13,10 +13,10 @@
<div class="container auth-container" ng-if="!user.anonymous"> <div class="container auth-container" ng-if="!user.anonymous">
<div class="auth-header"> <div class="auth-header">
<span class="avatar" size="48" hash="{{ application.avatar }}"></span> <span class="avatar" size="48" hash="'{{ application.avatar }}'"></span>
<h2><a href="{{ application.url }}" target="_blank">{{ application.name }}</a></h2> <h2><a href="{{ application.url }}" target="_blank">{{ application.name }}</a></h2>
<h4> <h4>
<span class="avatar" size="24" hash="{{ application.organization.avatar }}" <span class="avatar" size="24" hash="'{{ application.organization.avatar }}'"
style="vertical-align: middle; margin-right: 4px;"></span> style="vertical-align: middle; margin-right: 4px;"></span>
<span style="vertical-align: middle">{{ application.organization.name }}</span> <span style="vertical-align: middle">{{ application.organization.name }}</span>
</h4> </h4>