From cb8aa1d8755d240bd85d6d4fdf6e4d55abd7f550 Mon Sep 17 00:00:00 2001 From: Drew Fisher Date: Sat, 1 Oct 2022 20:51:21 -0700 Subject: [PATCH] Fix comment rendering --- shortlog.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/shortlog.py b/shortlog.py index 833fad3..8e3abe6 100755 --- a/shortlog.py +++ b/shortlog.py @@ -1,6 +1,7 @@ #!/usr/bin/python3 from collections import namedtuple import datetime +import hashlib import mimetypes import os import re @@ -90,7 +91,7 @@ def loadComment(filepath): timestamp = f.readline().strip() commentbody = makeParas(map(str.strip, f.readlines())) m = hashlib.md5() - m.update(emailline.lower()) + m.update(emailline.lower().encode('utf-8')) gravatar = "http://www.gravatar.com/avatar/%s?s=48&d=identicon" % str(m.hexdigest()) #timestamp = datetime.datetime.fromtimestamp(os.stat(filepath).st_mtime).isoformat() return (nameline, emailline, websiteline, commentbody, timestamp, gravatar) @@ -145,6 +146,8 @@ def render_no_entry(date): """ def render_comments(comments): + if len(comments) == 0: + return "" rendered_comments = [] for comment in comments: name = comment[0] @@ -163,8 +166,6 @@ def render_comments(comments): rendered_paras ]) rendered_comments.append(rendered_comment) - else: - return "" return "\n".join([ "

Comments:

", @@ -177,7 +178,7 @@ def render_page(content): Shortlog - a log of everyday things - + -- 2.39.2