diff options
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() |