bring develop branch up to date with master #7
|
@ -81,10 +81,10 @@ _api_client = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def process_photo_url(now: datetime, doc: Dict[str, List[str]], suffix: str = ""):
|
def process_photo_url(created_at: datetime, doc: Dict[str, List[str]], suffix: str = ""):
|
||||||
"""Process photo submitted via URL"""
|
"""Process photo submitted via URL"""
|
||||||
|
|
||||||
now_ts = int(time.mktime(now.timetuple()))
|
now_ts = int(time.mktime(created_at.timetuple()))
|
||||||
|
|
||||||
photo_urls = []
|
photo_urls = []
|
||||||
|
|
||||||
|
@ -103,9 +103,9 @@ def process_photo_url(now: datetime, doc: Dict[str, List[str]], suffix: str = ""
|
||||||
|
|
||||||
# generate local filename
|
# generate local filename
|
||||||
filename = os.path.join(os.environ.get(
|
filename = os.path.join(os.environ.get(
|
||||||
'MICROPUB_MEDIA_PATH'), now.strftime("%Y/%m/%d"), str(now_ts) + f"{now_ts}_{suffix}_{i}_{ext}")
|
'MICROPUB_MEDIA_PATH'), created_at.strftime("%Y/%m/%d"), str(now_ts) + f"{now_ts}_{suffix}_{i}_{ext}")
|
||||||
photo_url = os.path.join(os.environ.get(
|
photo_url = os.path.join(os.environ.get(
|
||||||
'MICROPUB_MEDIA_URL_PREFIX'), now.strftime("%Y/%m/%d"), str(now_ts) + f"{now_ts}_{suffix}_{i}_{ext}")
|
'MICROPUB_MEDIA_URL_PREFIX'), created_at.strftime("%Y/%m/%d"), str(now_ts) + f"{now_ts}_{suffix}_{i}_{ext}")
|
||||||
|
|
||||||
photo_urls.append(photo_url)
|
photo_urls.append(photo_url)
|
||||||
|
|
||||||
|
@ -123,10 +123,10 @@ def process_photo_url(now: datetime, doc: Dict[str, List[str]], suffix: str = ""
|
||||||
|
|
||||||
return photo_urls
|
return photo_urls
|
||||||
|
|
||||||
def process_photo_upload(now: datetime, file: FileStorage, suffix: str=""):
|
def process_photo_upload(created_at: datetime, file: FileStorage, suffix: str=""):
|
||||||
"""Process photo directly uploaded to micropub"""
|
"""Process photo directly uploaded to micropub"""
|
||||||
|
|
||||||
now_ts = int(time.mktime(now.timetuple()))
|
now_ts = int(time.mktime(created_at.timetuple()))
|
||||||
|
|
||||||
if os.environ.get('MICROPUB_IMAGE_STRATEGY') == 'copy':
|
if os.environ.get('MICROPUB_IMAGE_STRATEGY') == 'copy':
|
||||||
|
|
||||||
|
@ -134,9 +134,9 @@ def process_photo_upload(now: datetime, file: FileStorage, suffix: str=""):
|
||||||
|
|
||||||
# generate local filename
|
# generate local filename
|
||||||
filename = os.path.join(os.environ.get(
|
filename = os.path.join(os.environ.get(
|
||||||
'MICROPUB_MEDIA_PATH'), now.strftime("%Y/%m/%d"), f"{now_ts}_{suffix}{ext}")
|
'MICROPUB_MEDIA_PATH'), created_at.strftime("%Y/%m/%d"), f"{now_ts}_{suffix}{ext}")
|
||||||
photo_url = os.path.join(os.environ.get(
|
photo_url = os.path.join(os.environ.get(
|
||||||
'MICROPUB_MEDIA_URL_PREFIX'), now.strftime("%Y/%m/%d"), f"{now_ts}_{suffix}{ext}")
|
'MICROPUB_MEDIA_URL_PREFIX'), created_at.strftime("%Y/%m/%d"), f"{now_ts}_{suffix}{ext}")
|
||||||
|
|
||||||
# make directory if needed
|
# make directory if needed
|
||||||
if not os.path.exists(os.path.dirname(filename)):
|
if not os.path.exists(os.path.dirname(filename)):
|
||||||
|
@ -150,9 +150,9 @@ def process_photo_upload(now: datetime, file: FileStorage, suffix: str=""):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def init_frontmatter(now: datetime, post_type: str, name: Optional[str]=None):
|
def init_frontmatter(created_at: datetime, post_type: str, name: Optional[str]=None):
|
||||||
|
|
||||||
now_ts = int(time.mktime(now.timetuple()))
|
now_ts = int(time.mktime(created_at.timetuple()))
|
||||||
|
|
||||||
if name:
|
if name:
|
||||||
if isinstance(name, list):
|
if isinstance(name, list):
|
||||||
|
@ -164,18 +164,18 @@ def init_frontmatter(now: datetime, post_type: str, name: Optional[str]=None):
|
||||||
|
|
||||||
|
|
||||||
url = os.path.join("/", ENTITY_TYPE_PLURAL_MAP.get(post_type, post_type + "s"),
|
url = os.path.join("/", ENTITY_TYPE_PLURAL_MAP.get(post_type, post_type + "s"),
|
||||||
now.strftime("%Y/%m/%d"), slug)
|
created_at.strftime("%Y/%m/%d"), slug)
|
||||||
|
|
||||||
print(os.environ.get(
|
print(os.environ.get(
|
||||||
'CONTENT_PREFIX'))
|
'CONTENT_PREFIX'))
|
||||||
|
|
||||||
file_path = os.path.join(os.environ.get(
|
file_path = os.path.join(os.environ.get(
|
||||||
'CONTENT_PREFIX'), ENTITY_TYPE_PLURAL_MAP.get(post_type, post_type + "s"), now.strftime("%Y/%m/%d"), slug + ".md")
|
'CONTENT_PREFIX'), ENTITY_TYPE_PLURAL_MAP.get(post_type, post_type + "s"), created_at.strftime("%Y/%m/%d"), slug + ".md")
|
||||||
|
|
||||||
frontmatter = {
|
frontmatter = {
|
||||||
"url": url,
|
"url": url,
|
||||||
"type": post_type,
|
"type": post_type,
|
||||||
"date": now.isoformat(sep='T'),
|
"date": created_at.isoformat(sep='T'),
|
||||||
}
|
}
|
||||||
|
|
||||||
return frontmatter, file_path
|
return frontmatter, file_path
|
||||||
|
|
Loading…
Reference in New Issue