This commit is contained in:
Jesús 2020-04-21 15:53:20 -05:00
parent 5e87149877
commit 6ad5d4e6cb
No known key found for this signature in database
GPG Key ID: F6EE7BC59A315766

View File

@ -8,7 +8,7 @@ import collections
import hashlib # libravatar
import pelican.signals as signals
import pelican.generators as generators
# import pelican.generators as generators
import pelican.readers as readers
from pelican.contents import Content
@ -87,12 +87,13 @@ class CommentReader(object):
(comment_filename, ))
self._comments[comment.metadata['post_id']].append(comment)
# Libravatar
# LibreAvatar
librevatar_url = 'https://cdn.libravatar.org/avatar'
# Check the presence of the Email header
if 'email' in comment.metadata:
email = comment.metadata['email'].encode('utf-8')
ehash = hashlib.md5(email.strip().lower()).hexdigest()
comment.avatar = "https://cdn.libravatar.org/avatar/%s" % (ehash)
comment.avatar = "%s/%s" % (librevatar_url, ehash)
else:
raise Exception("comment %s does not have a email" %
(comment_filename))