From: Drew Fisher Date: Sun, 2 Oct 2022 03:51:21 +0000 (-0700) Subject: Fix comment rendering X-Git-Url: http://git.zarvox.org/shortlog/2010?a=commitdiff_plain;h=cb8aa1d8755d240bd85d6d4fdf6e4d55abd7f550;p=shortlog.git Fix comment rendering --- 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 - +