From dc40d4df692d81efa53699f0a99baf256a5c7242 Mon Sep 17 00:00:00 2001 From: James Ravenscroft Date: Sun, 30 Oct 2022 15:40:03 +0000 Subject: [PATCH] implement posting in the past with published flag --- src/microcosm/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/microcosm/__init__.py b/src/microcosm/__init__.py index 1ca83d9..52a1a94 100644 --- a/src/microcosm/__init__.py +++ b/src/microcosm/__init__.py @@ -7,6 +7,8 @@ import giteapy import giteapy.rest import time import base64 + + from werkzeug.datastructures import FileStorage import yaml @@ -27,7 +29,7 @@ PERMITTED_DOMAIN = os.environ.get( ENTITY_TYPE_PLURAL_MAP = { "reply": "replies", - "watch":"watches" + "watch": "watches" } core_bp = Blueprint("core", __name__) @@ -321,7 +323,13 @@ def process_json_post(): props = body['properties'] entry_type = detect_entry_type(props) - now = datetime.now() + if 'published' in props: + + from dateutil import parser + + now = parser.parse(props['published'][0]) + else: + now = datetime.now() frontmatter, file_path = init_frontmatter(now, entry_type, props.get('name'))