Commit eaeab2de authored by Michal Čihař's avatar Michal Čihař

Use libravatar instead of gravatar

It is free service, which allows delegation.
parent 966ebe4f
......@@ -37,7 +37,7 @@ import weblate
from trans.simplediff import html_diff
from trans.util import (
split_plural, gravatar_for_email, get_user_display
split_plural, avatar_for_email, get_user_display
)
from lang.models import Language
from trans.models import Project, SubProject, Dictionary
......@@ -242,8 +242,8 @@ def show_message(tags, message):
@register.simple_tag
def gravatar(user, size=80):
url = gravatar_for_email(user.email, size)
def avatar(user, size=80):
url = avatar_for_email(user.email, size)
alt = escape(_('Avatar for %s') % get_user_display(user, False))
return """<img src="%s" alt="Avatar for %s" height="%s" width="%s"/>""" % (
url, alt, size, size
......
......@@ -28,33 +28,33 @@ import urllib
import time
import random
GRAVATAR_URL_PREFIX = getattr(
AVATAR_URL_PREFIX = getattr(
settings,
'GRAVATAR_URL_PREFIX',
'https://secure.gravatar.com/'
'AVATAR_URL_PREFIX',
'https://seccdn.libravatar.org/'
)
# See http://cs.gravatar.com/site/implement/images/
# See http://wiki.libravatar.org/api/
# for available choices
GRAVATAR_DEFAULT_IMAGE = getattr(
AVATAR_DEFAULT_IMAGE = getattr(
settings,
'GRAVATAR_DEFAULT_IMAGE',
'AVATAR_DEFAULT_IMAGE',
'identicon'
)
PLURAL_SEPARATOR = '\x00\x00'
def gravatar_for_email(email, size=80):
def avatar_for_email(email, size=80):
'''
Generates url for gravatar.
Generates url for avatar.
'''
mail_hash = hashlib.md5(email.lower()).hexdigest()
url = "%savatar/%s/?" % (GRAVATAR_URL_PREFIX, mail_hash)
url = "%savatar/%s?" % (AVATAR_URL_PREFIX, mail_hash)
url += urllib.urlencode({
's': str(size),
'd': GRAVATAR_DEFAULT_IMAGE
'd': AVATAR_DEFAULT_IMAGE
})
return escape(url)
......@@ -86,12 +86,12 @@ def get_user_display(user, icon=True, link=False):
# Icon requested?
if icon:
# Get gravatar image
gravatar = gravatar_for_email(email, size=32)
# Get avatar image
avatar = avatar_for_email(email, size=32)
full_name = '<img src="%(gravatar)s" class="avatar" /> %(name)s' % {
full_name = '<img src="%(avatar)s" class="avatar" /> %(name)s' % {
'name': full_name,
'gravatar': gravatar
'avatar': avatar
}
if link and profile is not None:
......
......@@ -58,8 +58,8 @@
</p>
</div>
<div id="avatar">
<p>{% gravatar request.user 128 %}</p>
<p><a href="http://gravatar.com/emails/">{% trans "Change your avatar at gravatar.com" %}</a></p>
<p>{% avatar request.user 128 %}</p>
<p><a href="https://www.libravatar.org/">{% trans "Avatars are provided using libravatar." %}</a></p>
</div>
</div>
......
......@@ -11,7 +11,7 @@
<h2>{{ page_profile.get_user_name }}</h2>
{% gravatar page_user 160 %}
{% avatar page_user 160 %}
{% if user_projects %}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment