From 00154e84cae53eaf55863eaf682b0b1e68c98da1 Mon Sep 17 00:00:00 2001 From: OndraRehounek <ondra.rehounek@seznam.cz> Date: Thu, 17 Mar 2022 16:47:15 +0100 Subject: [PATCH] WIP --- district/jekyll_import.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/district/jekyll_import.py b/district/jekyll_import.py index 743524f2..f3697003 100644 --- a/district/jekyll_import.py +++ b/district/jekyll_import.py @@ -3,6 +3,7 @@ import re import urllib import xml.etree.ElementTree as ET import zipfile +from datetime import date from io import StringIO from shutil import rmtree from sys import stdout @@ -104,9 +105,15 @@ def import_post(path, file_path, parent, title_suffix, dry_run): article.text = html article.perex = get_perex(md) - article.date = meta["date"].split()[0] + + meta_date = meta["date"] + if isinstance(meta_date, date): + article.date = meta_date + else: + article.date = meta["date"].split()[0] + article.title = meta["title"] - article.author = meta["author"] + article.author = meta.get("author", "Česká pirátská strana") article.seo_title = article.title + title_suffix article.search_description = meta.get("description", "") @@ -217,7 +224,7 @@ def perform_import( site_config = get_site_config(path) title_suffix = get_title_from_site_config(site_config) - articlepath = site_config["articlepath"] + articlepath = site_config.get("articlepath", "aktuality") for fn in os.listdir(os.path.join(path, POSTS_DIR)): fname = os.path.join(POSTS_DIR, fn) -- GitLab