aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2019-11-18 23:52:13 -0500
committerJesús <heckyel@hyperbola.info>2019-11-18 23:52:13 -0500
commita6be1e73b8802abd7d90895fea09be8c667b92d9 (patch)
tree80de3ebb4994d58e16dba45ec09b2fe22b568655 /plugins
parentcb435f9750f14fbb84b4a5d25b7551b36ac86c6b (diff)
downloadcl-a6be1e73b8802abd7d90895fea09be8c667b92d9.tar.lz
cl-a6be1e73b8802abd7d90895fea09be8c667b92d9.tar.xz
cl-a6be1e73b8802abd7d90895fea09be8c667b92d9.zip
Check the presence of the Email header
Diffstat (limited to 'plugins')
-rw-r--r--plugins/pelican_comments/pelican_comments.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/plugins/pelican_comments/pelican_comments.py b/plugins/pelican_comments/pelican_comments.py
index 3a75ba2..c1c1cc8 100644
--- a/plugins/pelican_comments/pelican_comments.py
+++ b/plugins/pelican_comments/pelican_comments.py
@@ -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
- """
- email = comment.metadata['email'].encode('utf-8')
- ahash = hashlib.md5(email.strip().lower()).hexdigest()
- comment.avatar = "https://cdn.libravatar.org/avatar/%s" % (ahash)
+ # Libravatar
+ # 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)
+ else:
+ raise Exception("comment %s does not have a email" %
+ (comment_filename))
for slug, comments in self._comments.items():
comments.sort()