Show More
@@ -16,7 +16,7 import textwrap | |||||
16 | from datetime import datetime |
|
16 | from datetime import datetime | |
17 | from pygments.formatters.html import HtmlFormatter |
|
17 | from pygments.formatters.html import HtmlFormatter | |
18 | from pygments import highlight as code_highlight |
|
18 | from pygments import highlight as code_highlight | |
19 |
from pylons import url |
|
19 | from pylons import url | |
20 | from pylons.i18n.translation import _, ungettext |
|
20 | from pylons.i18n.translation import _, ungettext | |
21 | from hashlib import md5 |
|
21 | from hashlib import md5 | |
22 |
|
22 | |||
@@ -778,17 +778,20 HasReposGroupPermissionAny | |||||
778 | # GRAVATAR URL |
|
778 | # GRAVATAR URL | |
779 | #============================================================================== |
|
779 | #============================================================================== | |
780 |
|
780 | |||
781 | def gravatar_url(email_address, size=30): |
|
781 | def gravatar_url(email_address, size=30, ssl_enabled=True): | |
782 | from pylons import url # doh, we need to re-import url to mock it later |
|
782 | from pylons import url # doh, we need to re-import url to mock it later | |
783 | _def = 'anonymous@rhodecode.org' |
|
783 | from rhodecode import CONFIG | |
784 | use_gravatar = str2bool(config['app_conf'].get('use_gravatar')) |
|
784 | ||
|
785 | _def = 'anonymous@rhodecode.org' # default gravatar | |||
|
786 | use_gravatar = str2bool(CONFIG.get('use_gravatar')) | |||
|
787 | alternative_gravatar_url = CONFIG.get('alternative_gravatar_url', '') | |||
785 | email_address = email_address or _def |
|
788 | email_address = email_address or _def | |
786 |
if |
|
789 | if not use_gravatar or not email_address or email_address == _def: | |
787 | f = lambda a, l: min(l, key=lambda x: abs(x - a)) |
|
790 | f = lambda a, l: min(l, key=lambda x: abs(x - a)) | |
788 | return url("/images/user%s.png" % f(size, [14, 16, 20, 24, 30])) |
|
791 | return url("/images/user%s.png" % f(size, [14, 16, 20, 24, 30])) | |
789 |
|
792 | |||
790 |
if use_gravatar and |
|
793 | if use_gravatar and alternative_gravatar_url: | |
791 |
tmpl = |
|
794 | tmpl = alternative_gravatar_url | |
792 | parsed_url = urlparse.urlparse(url.current(qualified=True)) |
|
795 | parsed_url = urlparse.urlparse(url.current(qualified=True)) | |
793 | tmpl = tmpl.replace('{email}', email_address)\ |
|
796 | tmpl = tmpl.replace('{email}', email_address)\ | |
794 | .replace('{md5email}', hashlib.md5(email_address.lower()).hexdigest()) \ |
|
797 | .replace('{md5email}', hashlib.md5(email_address.lower()).hexdigest()) \ | |
@@ -797,7 +800,6 def gravatar_url(email_address, size=30) | |||||
797 | .replace('{size}', str(size)) |
|
800 | .replace('{size}', str(size)) | |
798 | return tmpl |
|
801 | return tmpl | |
799 |
|
802 | |||
800 | ssl_enabled = 'https' == request.environ.get('wsgi.url_scheme') |
|
|||
801 | default = 'identicon' |
|
803 | default = 'identicon' | |
802 | baseurl_nossl = "http://www.gravatar.com/avatar/" |
|
804 | baseurl_nossl = "http://www.gravatar.com/avatar/" | |
803 | baseurl_ssl = "https://secure.gravatar.com/avatar/" |
|
805 | baseurl_ssl = "https://secure.gravatar.com/avatar/" |
General Comments 0
You need to be logged in to leave comments.
Login now