Skip to content

Commit 1945f2e

Browse files
committed
feature: pasted pictures now use relative paths by default
1 parent 3170c64 commit 1945f2e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

otterwiki/wiki.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,7 @@ def render_attachments(self):
983983
def upload_attachments(
984984
self, files, message, filename, author, inline=False
985985
):
986+
last_uploaded_filename = None
986987
if not has_permission("UPLOAD"):
987988
abort(403)
988989
# attachments to commit in the second step
@@ -1000,6 +1001,7 @@ def upload_attachments(
10001001
os.makedirs(attachment.absdirectory, mode=0o775, exist_ok=True)
10011002
upload.save(attachment.abspath)
10021003
to_commit.append(attachment)
1004+
last_uploaded_filename = fn
10031005
if len(to_commit) > 0:
10041006
if filename is None:
10051007
toastmsg = "Added attachment(s): {}.".format(
@@ -1018,12 +1020,9 @@ def upload_attachments(
10181020
if not inline:
10191021
toast(toastmsg)
10201022
if inline:
1021-
attachment_url = url_for(
1022-
"get_attachment",
1023-
pagepath=self.pagepath,
1024-
filename=fn, # pyright: ignore
1025-
)
1026-
return jsonify(filename=attachment_url)
1023+
if last_uploaded_filename is None:
1024+
abort(500)
1025+
return jsonify(filename=f"./{last_uploaded_filename}")
10271026
return redirect(url_for("attachments", pagepath=self.pagepath))
10281027

10291028
def get_attachment(self, filename, revision=None):

0 commit comments

Comments
 (0)