Changeset - e291f25ea87f
[Not reviewed]
beta
0 4 0
Marcin Kuzminski - 13 years ago 2012-08-28 09:05:27
marcin@python-works.com
fixes issue #543, un-broken alternative gravatar option
- also now formatting is similar as other parts `{}`
4 files changed with 21 insertions and 18 deletions:
0 comments (0 inline, 0 general)
development.ini
Show inline comments
 
@@ -63,17 +63,17 @@ cut_off_limit = 256000
 
force_https = false
 
commit_parse_limit = 25
 
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
 
default_encoding = utf8
 

	
 
## overwrite schema of clone url
production.ini
Show inline comments
 
@@ -63,17 +63,17 @@ cut_off_limit = 256000
 
force_https = false
 
commit_parse_limit = 50
 
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
 
default_encoding = utf8
 

	
 
## overwrite schema of clone url
rhodecode/config/deployment.ini_tmpl
Show inline comments
 
@@ -63,17 +63,17 @@ cut_off_limit = 256000
 
force_https = false
 
commit_parse_limit = 50
 
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
 
default_encoding = utf8
 

	
 
## overwrite schema of clone url
rhodecode/lib/helpers.py
Show inline comments
 
@@ -710,15 +710,18 @@ HasRepoPermissionAny, HasRepoPermissionA
 
# GRAVATAR URL
 
#==============================================================================
 

	
 
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))
 
        return url("/images/user%s.png" % f(size, [14, 16, 20, 24, 30]))
 

	
 
    ssl_enabled = 'https' == request.environ.get('wsgi.url_scheme')
0 comments (0 inline, 0 general)