<s> from django . template import Library <EOL> from django . conf import settings <EOL> from django_gravatar . settings import configure_default_settings <EOL> configure_default_settings ( ) <EOL> try : <EOL> from urllib . parse import urlencode <EOL> except ImportError : <EOL> from urllib import urlencode <EOL> import hashlib <EOL> register = Library ( ) <EOL> @ register . simple_tag <EOL> def gravatar_url ( email , size = <NUM_LIT> ) : <EOL> url = '<STR_LIT:http>' <EOL> if settings . GRAVATAR_SECURE : <EOL> url += '<STR_LIT:s>' <EOL> url += '<STR_LIT>' + hashlib . md5 ( email . lower ( ) . encode ( '<STR_LIT:utf-8>' ) ) . hexdigest ( ) + '<STR_LIT:?>' <EOL> url += urlencode ( [ <EOL> ( '<STR_LIT:s>' , str ( size ) ) , <EOL> ( '<STR_LIT:d>' , settings . GRAVATAR_DEFAULT_URL ) <EOL> ] ) <EOL> return url <EOL> @ register . simple_tag <EOL> def gravatar ( email , size = <NUM_LIT> , options = "<STR_LIT>" ) : <EOL> url = gravatar_url ( email , size ) <EOL> return '<STR_LIT>' % ( url , size , size , options ) </s>
