Check the presence of the Email header

This commit is contained in:
Jesús 2019-11-18 23:52:13 -05:00
parent cb435f9750
commit a6be1e73b8
No known key found for this signature in database
GPG Key ID: F6EE7BC59A315766

View File

@ -76,16 +76,19 @@ class CommentReader(object):
context=generator.context)
if 'post_id' not in comment.metadata:
raise Exception("comment %s does not have a post_id" % (
comment_filename, ))
raise Exception("comment %s does not have a post_id" %
(comment_filename, ))
self._comments[comment.metadata['post_id']].append(comment)
"""
libravatar
"""
# Libravatar
# Check the presence of the Email header
if 'email' in comment.metadata:
email = comment.metadata['email'].encode('utf-8')
ahash = hashlib.md5(email.strip().lower()).hexdigest()
comment.avatar = "https://cdn.libravatar.org/avatar/%s" % (ahash)
ehash = hashlib.md5(email.strip().lower()).hexdigest()
comment.avatar = "https://cdn.libravatar.org/avatar/%s" % (ehash)
else:
raise Exception("comment %s does not have a email" %
(comment_filename))
for slug, comments in self._comments.items():
comments.sort()