From 581f36abea6c07598bce05cf345e9760da49bdf4 Mon Sep 17 00:00:00 2001 From: Bastian Venthur Date: Thu, 14 Jan 2021 16:28:41 +0100 Subject: [PATCH] small template improvements --- sg/sg.py | 9 +++++---- templates/article.html | 8 +++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sg/sg.py b/sg/sg.py index 56c064f..baf46eb 100644 --- a/sg/sg.py +++ b/sg/sg.py @@ -11,9 +11,6 @@ __author__ = "Bastian Venthur " import argparse import os import shutil -import string -import codecs -import re import logging from datetime import datetime @@ -119,6 +116,10 @@ def convert_to_html(convertibles): value = value[0] meta[key] = value + # convert known metadata + if 'date' in meta: + meta['date'] = datetime.fromisoformat(meta['date']) + context = dict(content=content) context.update(meta) # for now, treat all pages as articles @@ -146,7 +147,7 @@ def convert_to_html(convertibles): link=dst, description=context['title'], content=context['content'], - pubdate=datetime.fromisoformat(context['date']), + pubdate=context['date'], ) with open('atom.xml', 'w') as fh: diff --git a/templates/article.html b/templates/article.html index 9b8eff1..eff93a5 100644 --- a/templates/article.html +++ b/templates/article.html @@ -9,7 +9,13 @@ {% block content %} -

Written on {{ date }}.

+ {% if title %} +

{{ title }}

+ {% endif %} + + {% if date %} +

Written on {{ date.date() }}.

+ {% endif %} {{ content }}