# HG changeset patch # User Marcin Kuzminski # Date 1346137527 -7200 # Node ID e291f25ea87f888504f9109b22ee24d0e3049134 # Parent 30cafecb26307543b542f850ef5f083cb6313c3e fixes issue #543, un-broken alternative gravatar option - also now formatting is similar as other parts `{}` diff -r 30cafecb2630 -r e291f25ea87f development.ini --- a/development.ini Tue Aug 28 09:04:02 2012 +0200 +++ b/development.ini Tue Aug 28 09:05:27 2012 +0200 @@ -66,11 +66,11 @@ ## 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 -r 30cafecb2630 -r e291f25ea87f production.ini --- a/production.ini Tue Aug 28 09:04:02 2012 +0200 +++ b/production.ini Tue Aug 28 09:05:27 2012 +0200 @@ -66,11 +66,11 @@ ## 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 -r 30cafecb2630 -r e291f25ea87f rhodecode/config/deployment.ini_tmpl --- a/rhodecode/config/deployment.ini_tmpl Tue Aug 28 09:04:02 2012 +0200 +++ b/rhodecode/config/deployment.ini_tmpl Tue Aug 28 09:05:27 2012 +0200 @@ -66,11 +66,11 @@ ## 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 -r 30cafecb2630 -r e291f25ea87f rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py Tue Aug 28 09:04:02 2012 +0200 +++ b/rhodecode/lib/helpers.py Tue Aug 28 09:05:27 2012 +0200 @@ -713,9 +713,12 @@ 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))