# HG changeset patch # User Marcin Kuzminski # Date 1369754446 -7200 # Node ID f7bf0cebe391359cf07e84132a75a79c53040273 # Parent fe053a42c4ce62717893a6194058012f858f6176 Switch gravatar to always use ssl. - there's no reason why not to. - removed thread locals imports thanks to that - use internal RhodeCode config for alternative gravatar url diff -r fe053a42c4ce -r f7bf0cebe391 rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py Tue May 28 16:57:24 2013 +0200 +++ b/rhodecode/lib/helpers.py Tue May 28 17:20:46 2013 +0200 @@ -16,7 +16,7 @@ from datetime import datetime from pygments.formatters.html import HtmlFormatter from pygments import highlight as code_highlight -from pylons import url, request, config +from pylons import url from pylons.i18n.translation import _, ungettext from hashlib import md5 @@ -778,17 +778,20 @@ # GRAVATAR URL #============================================================================== -def gravatar_url(email_address, size=30): +def gravatar_url(email_address, size=30, ssl_enabled=True): from pylons import url # doh, we need to re-import url to mock it later - _def = 'anonymous@rhodecode.org' - use_gravatar = str2bool(config['app_conf'].get('use_gravatar')) + from rhodecode import CONFIG + + _def = 'anonymous@rhodecode.org' # default gravatar + use_gravatar = str2bool(CONFIG.get('use_gravatar')) + alternative_gravatar_url = CONFIG.get('alternative_gravatar_url', '') email_address = email_address or _def - if (not use_gravatar or not email_address or email_address == _def): + if not use_gravatar or not email_address or email_address == _def: 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])) - if use_gravatar and config['app_conf'].get('alternative_gravatar_url'): - tmpl = config['app_conf'].get('alternative_gravatar_url', '') + if use_gravatar and alternative_gravatar_url: + tmpl = alternative_gravatar_url parsed_url = urlparse.urlparse(url.current(qualified=True)) tmpl = tmpl.replace('{email}', email_address)\ .replace('{md5email}', hashlib.md5(email_address.lower()).hexdigest()) \ @@ -797,7 +800,6 @@ .replace('{size}', str(size)) return tmpl - ssl_enabled = 'https' == request.environ.get('wsgi.url_scheme') default = 'identicon' baseurl_nossl = "http://www.gravatar.com/avatar/" baseurl_ssl = "https://secure.gravatar.com/avatar/"