diff options
author | Jesús <heckyel@hyperbola.info> | 2019-11-18 23:52:13 -0500 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2019-11-18 23:52:13 -0500 |
commit | a6be1e73b8802abd7d90895fea09be8c667b92d9 (patch) | |
tree | 80de3ebb4994d58e16dba45ec09b2fe22b568655 /plugins | |
parent | cb435f9750f14fbb84b4a5d25b7551b36ac86c6b (diff) | |
download | cl-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.py | 19 |
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() |