diff --git a/src/microcosm/__init__.py b/src/microcosm/__init__.py
index 183b77c..5d53fcb 100644
--- a/src/microcosm/__init__.py
+++ b/src/microcosm/__init__.py
@@ -161,6 +161,8 @@ def process_photo_upload(created_at: datetime, file: FileStorage, suffix: str=""
else:
return None
+
+
def init_frontmatter(created_at: datetime, post_type: str, name: Optional[str]=None):
@@ -187,7 +189,7 @@ def init_frontmatter(created_at: datetime, post_type: str, name: Optional[str]=N
frontmatter = {
"url": url,
- "type": post_type,
+ "type": ENTITY_TYPE_PLURAL_MAP.get(post_type, post_type + "s"),
"date": created_at.isoformat(sep='T'),
}
@@ -297,6 +299,9 @@ def process_multipart_post():
for i, photo in enumerate(photos):
photo_url = process_photo_upload(now, photo, suffix=i)
+ if 'thumbnail' not in frontmatter:
+ frontmatter['thumbnail'] = photo_url
+
frontmatter['photo'].append(photo_url)
docstr += f"\n\n"
@@ -307,10 +312,15 @@ def process_multipart_post():
if 'photo' in doc:
photo_objects = process_photo_url(now, doc)
+
+
else:
photo_objects = [ (process_photo_upload(now, request.files['photo']), "") ]
frontmatter['photo'] = [ {"value": photo[0], "alt": photo[1]} for photo in photo_objects]
+ frontmatter['thumbnail'] = photo_objects[0][0]
+
+
docstr = ""
for photo in photo_objects:
docstr += f" \n\n {doc['content']}"
@@ -386,6 +396,7 @@ def process_json_post():
frontmatter['photo'] = [ {"value": photo[0], "alt": photo[1]} for photo in photo_objects]
+ frontmatter['thumbnail'] = frontmatter['photo'][0]['value']
docstr = ""
for photo in photo_objects:
docstr += f" \n\n"
@@ -424,7 +435,7 @@ def req():
docstr, frontmatter, file_path = process_multipart_post()
frontmatter_str = yaml.dump(frontmatter)
- content = base64.encodestring(
+ content = base64.encodebytes(
f"---\n{frontmatter_str}\n---\n\n{docstr}".encode("utf8")).decode("utf8")
api = get_api_client()
diff --git a/src/microcosm/indieauth.py b/src/microcosm/indieauth.py
index 934489e..a5c5b8f 100644
--- a/src/microcosm/indieauth.py
+++ b/src/microcosm/indieauth.py
@@ -37,13 +37,13 @@ def authform():
@auth_bp.route('/authenticate')
def authenticate():
return micropub.authenticate(
- request.args.get('me'), next_url=url_for('index'))
+ request.args.get('me'), next_url=url_for('token.indieauth_callback'))
@auth_bp.route('/authorize')
def authorize():
return micropub.authorize(
- request.args.get('me'), next_url=url_for('index'),
+ request.args.get('me'), next_url=url_for('token.indieauth_callback'),
scope=request.args.get('scope'))
diff --git a/src/microcosm/wsgi.py b/src/microcosm/wsgi.py
new file mode 100644
index 0000000..4bedec8
--- /dev/null
+++ b/src/microcosm/wsgi.py
@@ -0,0 +1,4 @@
+from . import create_app
+
+
+app = create_app()
\ No newline at end of file