Skip to content

Commit

Permalink
feature: pasted pictures now use relative paths by default
Browse files Browse the repository at this point in the history
  • Loading branch information
redimp committed Nov 16, 2024
1 parent 3170c64 commit 1945f2e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions otterwiki/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,7 @@ def render_attachments(self):
def upload_attachments(
self, files, message, filename, author, inline=False
):
last_uploaded_filename = None
if not has_permission("UPLOAD"):
abort(403)
# attachments to commit in the second step
Expand All @@ -1000,6 +1001,7 @@ def upload_attachments(
os.makedirs(attachment.absdirectory, mode=0o775, exist_ok=True)
upload.save(attachment.abspath)
to_commit.append(attachment)
last_uploaded_filename = fn
if len(to_commit) > 0:
if filename is None:
toastmsg = "Added attachment(s): {}.".format(
Expand All @@ -1018,12 +1020,9 @@ def upload_attachments(
if not inline:
toast(toastmsg)
if inline:
attachment_url = url_for(
"get_attachment",
pagepath=self.pagepath,
filename=fn, # pyright: ignore
)
return jsonify(filename=attachment_url)
if last_uploaded_filename is None:
abort(500)
return jsonify(filename=f"./{last_uploaded_filename}")
return redirect(url_for("attachments", pagepath=self.pagepath))

def get_attachment(self, filename, revision=None):
Expand Down

0 comments on commit 1945f2e

Please sign in to comment.