use [file] instead of <file>

pull/135/head
Aevann 2023-02-27 07:24:26 +02:00
parent 78c941c7b5
commit 6e200d332e
3 changed files with 15 additions and 15 deletions

View File

@ -254,7 +254,7 @@ function changename(s1,s2,textarea) {
}
const ta = document.getElementById(textarea);
ta.value = ta.value.replace(/<file>\n/g, "")
ta.value = ta.value.replace(/[file]\n/g, "")
if (ta.value) {
ta.value += '\n'
}
@ -262,7 +262,7 @@ function changename(s1,s2,textarea) {
let filename = '';
for (const e of files) {
filename += e.name.substr(0, 22) + ', ';
ta.value += '<file>\n'
ta.value += '[file]\n'
}
document.getElementById(s1).innerHTML = escapeHTML(filename.slice(0, -2));

View File

@ -32,19 +32,19 @@ def process_files(files, v, body):
if files:
media_ratelimit(v)
while body.count('<file>') < len(files):
body += '\n<file>'
while body.count('[file]') < len(files):
body += '\n[file]'
for file in files:
if file.content_type.startswith('image/'):
name = f'/images/{time.time()}'.replace('.','') + '.webp'
file.save(name)
url = process_image(name, v)
body = body.replace('<file>', f"![]({url})", 1)
body = body.replace('[file]', f"![]({url})", 1)
elif file.content_type.startswith('video/'):
body = body.replace('<file>', f"{SITE_FULL}{process_video(file, v)}", 1)
body = body.replace('[file]', f"{SITE_FULL}{process_video(file, v)}", 1)
elif file.content_type.startswith('audio/'):
body = body.replace('<file>', f"{SITE_FULL}{process_audio(file, v)}", 1)
body = body.replace('[file]', f"{SITE_FULL}{process_audio(file, v)}", 1)
else:
abort(415)
return body
@ -237,8 +237,8 @@ def process_dm_images(v, user, body):
files = request.files.getlist('file')[:8]
while body.count('<file>') < len(files):
body += '\n<file>'
while body.count('[file]') < len(files):
body += '\n[file]'
for file in files:
if file.content_type.startswith('image/'):
@ -268,7 +268,7 @@ def process_dm_images(v, user, body):
try: url = req['files'][0]['url']
except: abort(400, req['description'])
body = body.replace('<file>', url, 1)
body = body.replace('[file]', url, 1)
with open(f"{LOG_DIRECTORY}/dm_images.log", "a+", encoding="utf-8") as f:
if user:

View File

@ -155,8 +155,8 @@ def comment(v:User):
if request.files.get("file") and not g.is_tor:
files = request.files.getlist('file')[:8]
while body.count('<file>') < len(files):
body += '\n<file>'
while body.count('[file]') < len(files):
body += '\n[file]'
if files:
media_ratelimit(v)
@ -204,11 +204,11 @@ def comment(v:User):
purge_files_in_cache(f"https://{SITE}/assets/images/badges/{badge.id}.webp")
except Exception as e:
abort(400, str(e))
body = body.replace('<file>', f"![]({image})", 1)
body = body.replace('[file]', f"![]({image})", 1)
elif file.content_type.startswith('video/'):
body = body.replace('<file>', f"{SITE_FULL}{process_video(file, v)}", 1)
body = body.replace('[file]', f"{SITE_FULL}{process_video(file, v)}", 1)
elif file.content_type.startswith('audio/'):
body = body.replace('<file>', f"{SITE_FULL}{process_audio(file, v)}", 1)
body = body.replace('[file]', f"{SITE_FULL}{process_audio(file, v)}", 1)
else:
abort(415)