forked from MarseyWorld/MarseyWorld
allow ppl to change attachment
parent
8035bcb6c3
commit
54489e903a
|
@ -1182,7 +1182,29 @@ def edit_post(pid, v):
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
url = request.values.get("url", "").strip()
|
url = request.values.get("url", "").strip()
|
||||||
if url != p.url:
|
if request.files.get('file-url') and not g.is_tor:
|
||||||
|
file = request.files['file-url']
|
||||||
|
|
||||||
|
if file.content_type.startswith('image/'):
|
||||||
|
name = f'/images/{time.time()}'.replace('.','') + '.webp'
|
||||||
|
file.save(name)
|
||||||
|
p.url = process_image(name, v)
|
||||||
|
|
||||||
|
name2 = name.replace('.webp', 'r.webp')
|
||||||
|
copyfile(name, name2)
|
||||||
|
p.thumburl = process_image(name2, v, resize=199)
|
||||||
|
elif file.content_type.startswith('video/'):
|
||||||
|
p.url, p.posterurl, name = process_video(file, v, post=p)
|
||||||
|
if p.posterurl:
|
||||||
|
name2 = name.replace('.webp', 'r.webp')
|
||||||
|
copyfile(name, name2)
|
||||||
|
p.thumburl = process_image(name2, v, resize=199)
|
||||||
|
elif file.content_type.startswith('audio/'):
|
||||||
|
p.url = process_audio(file, v)
|
||||||
|
else:
|
||||||
|
stop(415)
|
||||||
|
changed = True
|
||||||
|
elif url != p.url:
|
||||||
p.url = url
|
p.url = url
|
||||||
changed = True
|
changed = True
|
||||||
change_thumb = True
|
change_thumb = True
|
||||||
|
|
|
@ -220,7 +220,13 @@
|
||||||
<input hidden name="current_page" value="{{request.path}}">
|
<input hidden name="current_page" value="{{request.path}}">
|
||||||
<textarea id="post-edit-title" autocomplete="off" maxlength="500" name="title" class="comment-box form-control rounded" required placeholder="Title">{{p.title}}</textarea>
|
<textarea id="post-edit-title" autocomplete="off" maxlength="500" name="title" class="comment-box form-control rounded" required placeholder="Title">{{p.title}}</textarea>
|
||||||
{{macros.emoji_btn('post-edit-title')}}
|
{{macros.emoji_btn('post-edit-title')}}
|
||||||
|
|
||||||
<input id="post-edit-url" autocomplete="off" maxlength="2083" name="url" type="url" class="comment-box form-control rounded my-3" placeholder="URL" value="{% if p.url %}{% if p.url.startswith('/') %}{{SITE_FULL}}{% endif %}{{p.url}}{% endif %}">
|
<input id="post-edit-url" autocomplete="off" maxlength="2083" name="url" type="url" class="comment-box form-control rounded my-3" placeholder="URL" value="{% if p.url %}{% if p.url.startswith('/') %}{{SITE_FULL}}{% endif %}{{p.url}}{% endif %}">
|
||||||
|
<label class="btn btn-secondary m-0 mr-1 mb-3" for="file-upload">
|
||||||
|
<div>Select File</div>
|
||||||
|
<input autocomplete="off" id="file-upload" accept="image/*, video/*, audio/*" type="file" name="file-url" hidden="">
|
||||||
|
</label>
|
||||||
|
|
||||||
<textarea autocomplete="off" name="body" {% if v.longpost and not p.distinguished %}minlength="280"{% endif %} maxlength="{% if v.id == p.author_id and v.bird and not p.distinguished %}140{% else %}{{POST_BODY_LENGTH_LIMIT(v)}}{% endif %}" data-preview="post-edit-{{p.id}}" data-nonce="{{g.nonce}}" data-oninput="markdown(this);charLimit('post-edit-box-{{p.id}}','charcount-post-edit')" id="post-edit-box-{{p.id}}" form="post-edit-form-{{p.id}}" class="file-ta comment-box form-control rounded" placeholder="Add text to your post..." rows="10" data-id="{{p.id}}">{{p.body}}</textarea>
|
<textarea autocomplete="off" name="body" {% if v.longpost and not p.distinguished %}minlength="280"{% endif %} maxlength="{% if v.id == p.author_id and v.bird and not p.distinguished %}140{% else %}{{POST_BODY_LENGTH_LIMIT(v)}}{% endif %}" data-preview="post-edit-{{p.id}}" data-nonce="{{g.nonce}}" data-oninput="markdown(this);charLimit('post-edit-box-{{p.id}}','charcount-post-edit')" id="post-edit-box-{{p.id}}" form="post-edit-form-{{p.id}}" class="file-ta comment-box form-control rounded" placeholder="Add text to your post..." rows="10" data-id="{{p.id}}">{{p.body}}</textarea>
|
||||||
|
|
||||||
<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>
|
||||||
|
|
Loading…
Reference in New Issue