forked from rDrama/rDrama
sfdsfd
parent
1dc45f2373
commit
b2cd037ac6
|
@ -221,6 +221,9 @@ def post_id(pid, anything=None, v=None):
|
||||||
@auth_required
|
@auth_required
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def edit_post(pid, v):
|
def edit_post(pid, v):
|
||||||
|
if v and v.patron:
|
||||||
|
if request.content_length > 8 * 1024 * 1024: return "Max file size is 8 MB.", 413
|
||||||
|
elif request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413
|
||||||
|
|
||||||
p = get_post(pid)
|
p = get_post(pid)
|
||||||
|
|
||||||
|
@ -264,6 +267,16 @@ def edit_post(pid, v):
|
||||||
p.title = title
|
p.title = title
|
||||||
p.title_html = title_html
|
p.title_html = title_html
|
||||||
|
|
||||||
|
if request.files.get("file") and request.headers.get("cf-ipcountry") != "T1":
|
||||||
|
file=request.files["file"]
|
||||||
|
if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400
|
||||||
|
|
||||||
|
name = f'/images/{int(time.time())}{secrets.token_urlsafe(2)}.webp'
|
||||||
|
file.save(name)
|
||||||
|
url = request.host_url[:-1] + process_image(name)
|
||||||
|
|
||||||
|
body += f"\n\n![]({url})"
|
||||||
|
|
||||||
if body != p.body:
|
if body != p.body:
|
||||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
|
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
|
||||||
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})')
|
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})')
|
||||||
|
|
|
@ -483,11 +483,17 @@
|
||||||
<div class="text-small font-weight-bold mt-1" id="charcount-post-edit" style="right: 1rem; bottom: 0.5rem; z-index: 3;"></div>
|
<div class="text-small font-weight-bold mt-1" id="charcount-post-edit" style="right: 1rem; bottom: 0.5rem; z-index: 3;"></div>
|
||||||
|
|
||||||
<div class="comment-format">
|
<div class="comment-format">
|
||||||
<small class="format pl-0"><i class="fas fa-bold" aria-hidden="true" onclick="makeBold('post-edit-box-{{p.id}}')" data-bs-toggle="tooltip" data-bs-placement="bottom" title="" data-bs-original-title="Bold"></i></small>
|
<small class="format pl-0 btn btn-secondary"><i class="fas fa-bold" aria-hidden="true" onclick="makeBold('post-edit-box-{{p.id}}')" data-bs-toggle="tooltip" data-bs-placement="bottom" title="" data-bs-original-title="Bold"></i></small>
|
||||||
<a class="format" href="javascript:void(0)"><i class="fas fa-italic" aria-hidden="true" onclick="makeItalics('post-edit-box-{{p.id}}')" data-bs-toggle="tooltip" data-bs-placement="bottom" title="" data-bs-original-title="Italicize"></i></a>
|
<a class="format btn btn-secondary" href="javascript:void(0)"><i class="fas fa-italic" aria-hidden="true" onclick="makeItalics('post-edit-box-{{p.id}}')" data-bs-toggle="tooltip" data-bs-placement="bottom" title="" data-bs-original-title="Italicize"></i></a>
|
||||||
<a class="format" href="javascript:void(0)"><i class="fas fa-quote-right" aria-hidden="true" onclick="makeQuote('post-edit-box-{{p.id}}')" data-bs-toggle="tooltip" data-bs-placement="bottom" title="" data-bs-original-title="Quote"></i></a>
|
<a class="format btn btn-secondary" href="javascript:void(0)"><i class="fas fa-quote-right" aria-hidden="true" onclick="makeQuote('post-edit-box-{{p.id}}')" data-bs-toggle="tooltip" data-bs-placement="bottom" title="" data-bs-original-title="Quote"></i></a>
|
||||||
<a class="format" href="javascript:void(0)"><span class="font-weight-bolder text-uppercase" onclick="commentForm('post-edit-box-{{p.id}}');getGif()" aria-hidden="true" data-bs-toggle="modal" data-bs-target="#gifModal" data-bs-toggle="tooltip" data-bs-placement="bottom" title="" data-bs-original-title="Add GIF">GIF</span></a>
|
<a class="format btn btn-secondary" href="javascript:void(0)"><span class="font-weight-bolder text-uppercase" onclick="commentForm('post-edit-box-{{p.id}}');getGif()" aria-hidden="true" data-bs-toggle="modal" data-bs-target="#gifModal" data-bs-toggle="tooltip" data-bs-placement="bottom" title="" data-bs-original-title="Add GIF">GIF</span></a>
|
||||||
<a class="format" href="javascript:void(0)"><i class="fas fa-smile-beam" onclick="loadEmojis('post-edit-box-{{p.id}}')" aria-hidden="true" data-bs-toggle="modal" data-bs-target="#emojiModal" data-bs-toggle="tooltip" data-bs-placement="bottom" title="" data-bs-original-title="Add Emoji"></i></a>
|
<a class="format btn btn-secondary" href="javascript:void(0)"><i class="fas fa-smile-beam" onclick="loadEmojis('post-edit-box-{{p.id}}')" aria-hidden="true" data-bs-toggle="modal" data-bs-target="#emojiModal" data-bs-toggle="tooltip" data-bs-placement="bottom" title="" data-bs-original-title="Add Emoji"></i></a>
|
||||||
|
|
||||||
|
<label class="format btn btn-secondary m-0 ml-1 {% if v %}d-inline-block{% else %}d-none{% endif %}" for="file-upload-edit-{{p.fullname}}">
|
||||||
|
<div id="filename-show-edit-{{p.fullname}}"><i class="far fa-image"></i></div>
|
||||||
|
<input id="file-upload-edit-{{p.fullname}}" type="file" name="file" accept="image/*" {% if request.headers.get('cf-ipcountry')=="T1" %}disabled{% endif %} onchange="document.getElementById('filename-show-edit-{{p.fullname}}').innerHTML='image';" hidden>
|
||||||
|
</label>
|
||||||
|
|
||||||
<small class="format d-none"><i class="fas fa-link" aria-hidden="true"></i></small>
|
<small class="format d-none"><i class="fas fa-link" aria-hidden="true"></i></small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue