diff --git a/development.ini b/development.ini --- a/development.ini +++ b/development.ini @@ -66,11 +66,11 @@ use_gravatar = true ## alternative_gravatar_url allows you to use your own avatar server application ## the following parts of the URL will be replaced -## %(email)s user email -## %(md5email)s md5 hash of the user email (like at gravatar.com) -## %(size)s size of the image that is expected from the server application -#alternative_gravatar_url = http://myavatarserver.com/getbyemail/%(email)s/%(size)s -#alternative_gravatar_url = http://myavatarserver.com/getbymd5/%(md5email)s?s=%(size)s +## {email} user email +## {md5email} md5 hash of the user email (like at gravatar.com) +## {size} size of the image that is expected from the server application +#alternative_gravatar_url = http://myavatarserver.com/getbyemail/{email}/{size} +#alternative_gravatar_url = http://myavatarserver.com/getbymd5/{md5email}?s={size} container_auth_enabled = false proxypass_auth_enabled = false diff --git a/production.ini b/production.ini --- a/production.ini +++ b/production.ini @@ -66,11 +66,11 @@ use_gravatar = true ## alternative_gravatar_url allows you to use your own avatar server application ## the following parts of the URL will be replaced -## %(email)s user email -## %(md5email)s md5 hash of the user email (like at gravatar.com) -## %(size)s size of the image that is expected from the server application -#alternative_gravatar_url = http://myavatarserver.com/getbyemail/%(email)s/%(size)s -#alternative_gravatar_url = http://myavatarserver.com/getbymd5/%(md5email)s?s=%(size)s +## {email} user email +## {md5email} md5 hash of the user email (like at gravatar.com) +## {size} size of the image that is expected from the server application +#alternative_gravatar_url = http://myavatarserver.com/getbyemail/{email}/{size} +#alternative_gravatar_url = http://myavatarserver.com/getbymd5/{md5email}?s={size} container_auth_enabled = false proxypass_auth_enabled = false diff --git a/rhodecode/config/deployment.ini_tmpl b/rhodecode/config/deployment.ini_tmpl --- a/rhodecode/config/deployment.ini_tmpl +++ b/rhodecode/config/deployment.ini_tmpl @@ -66,11 +66,11 @@ use_gravatar = true ## alternative_gravatar_url allows you to use your own avatar server application ## the following parts of the URL will be replaced -## %(email)s user email -## %(md5email)s md5 hash of the user email (like at gravatar.com) -## %(size)s size of the image that is expected from the server application -#alternative_gravatar_url = http://myavatarserver.com/getbyemail/%(email)s/%(size)s -#alternative_gravatar_url = http://myavatarserver.com/getbymd5/%(md5email)s?s=%(size)s +## {email} user email +## {md5email} md5 hash of the user email (like at gravatar.com) +## {size} size of the image that is expected from the server application +#alternative_gravatar_url = http://myavatarserver.com/getbyemail/{email}/{size} +#alternative_gravatar_url = http://myavatarserver.com/getbymd5/{md5email}?s={size} container_auth_enabled = false proxypass_auth_enabled = false diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -713,9 +713,12 @@ HasRepoPermissionAny, HasRepoPermissionA def gravatar_url(email_address, size=30): if(str2bool(config['app_conf'].get('use_gravatar')) and config['app_conf'].get('alternative_gravatar_url')): - return config['app_conf'].get('alternative_gravatar_url') % {'email': email_address, - 'md5email': hashlib.md5(email_address.lower()).hexdigest(), - 'size': size} + tmpl = config['app_conf'].get('alternative_gravatar_url', '') + tmpl = tmpl.replace('{email}', email_address)\ + .replace('{md5email}', hashlib.md5(email_address.lower()).hexdigest())\ + .replace('{size}', str(size)) + return tmpl + if (not str2bool(config['app_conf'].get('use_gravatar')) or not email_address or email_address == 'anonymous@rhodecode.org'): f = lambda a, l: min(l, key=lambda x: abs(x - a))