]> git.zarvox.org Git - shortlog.git/commitdiff
Fix comment rendering
authorDrew Fisher <drew.m.fisher@gmail.com>
Sun, 2 Oct 2022 03:51:21 +0000 (20:51 -0700)
committerDrew Fisher <drew.m.fisher@gmail.com>
Sun, 2 Oct 2022 03:51:21 +0000 (20:51 -0700)
shortlog.py

index 833fad33844a607e179f24768f2fb008ccc6eb89..8e3abe62096f256765671618f64860f3d7b59663 100755 (executable)
@@ -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([
                "<hr><h3>Comments:</h3>",
@@ -177,7 +178,7 @@ def render_page(content):
 <head>
 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
 <title>Shortlog - a log of everyday things</title>
-<link rel="stylesheet" type="text/css" href="/static/style.css">
+<link rel="stylesheet" type="text/css" href="/shortlog/static/style.css">
 <link rel="alternate" type="application/atom+xml" href="/shortlog/feed">
 </head>
 <body>