Add Gravatar to display user's avatar

This commit is contained in:
Khanh Ngo
2016-07-13 21:33:21 +07:00
parent 70692a3d69
commit ee033f2198
4 changed files with 16 additions and 4 deletions

View File

@ -3,6 +3,8 @@ import sys
import json
import requests
import urlparse
import hashlib
from app import app
from distutils.version import StrictVersion
@ -145,3 +147,8 @@ def pdns_api_extended_uri(version):
return "/api/v1"
else:
return ""
def email_to_gravatar_url(email, size=100):
hash_string = hashlib.md5(email).hexdigest()
schema = 'https' if app.config['SSL'] else 'http'
return "%s://s.gravatar.com/avatar/%s?s=%s" % (schema, hash_string, size)