commit 6f2ccfcab6bba6fd242dca819d532fad240e58d8
parent 92bc1b5da2c0ba4a358b5fb8abd64c92b4d3da96
Author: lash <dev@holbrook.no>
Date: Thu, 24 Nov 2022 06:41:18 +0000
Add file download links, dated separators between messages
Diffstat:
1 file changed, 8 insertions(+), 0 deletions(-)
diff --git a/piknik/render/html.py b/piknik/render/html.py
@@ -19,6 +19,7 @@ class Renderer(BaseRenderer):
self.state_buf = []
self.message_buf = []
self.outdir = outdir
+ self.last_message_id = None
def apply_state_post(self, state, w=sys.stdout):
@@ -108,6 +109,10 @@ class Renderer(BaseRenderer):
m = parse_mime_type(message.get_content_type())
filename = message.get_filename()
+ if message_id != self.last_message_id:
+ self.message_buf.append(div('--- ' + str(message_date), _id=issue.id))
+ self.last_message_id = message_id
+
r = div(_id=issue.id + '.' + message_id)
if filename == None:
v = message.get_payload()
@@ -121,6 +126,9 @@ class Renderer(BaseRenderer):
img_src = 'data:{}/{};base64,'.format(m[0], m[1])
img_src += v
r.add(p(img(src=img_src)))
+ else:
+ data_src = 'data:application/octet-stream;base64,' + v
+ r.add(a(filename, download=filename, href=data_src))
self.message_buf.append(r)