pyfedi/app/templates/post/post_edit.html
2025-01-02 16:30:58 +13:00

135 lines
6.9 KiB
HTML

{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %}
{% extends 'themes/' + theme() + '/base.html' %}
{% else %}
{% extends "base.html" %}
{% endif %}
{% from 'bootstrap/form.html' import render_form, render_field %}
{% block app_content %}
<script src="/static/js/coolfieldset.js"></script>
<div class="row">
<div class="col-12 col-md-8 position-relative main_pane">
{% block title %}<h1>{{ _('Edit post') }}</h1>{% endblock %}
<form method="post" enctype="multipart/form-data" role="form">
{{ form.csrf_token() }}
{% block post_type %}{% endblock %}
{{ render_field(form.title) }}
{% if post_type == POST_TYPE_LINK %}
{{ render_field(form.link_url) }}
<div id="urlUsed"></div>
{% elif post_type == POST_TYPE_IMAGE %}
{% if post.image_id -%}
<div class="post_image">
{% if low_bandwidth -%}
<a href="{{ post.image.view_url(resize=True) }}" rel="nofollow ugc"><img src="{{ post.image.medium_url() }}"
alt="{{ post.image.alt_text if post.image.alt_text else post.title }}" fetchpriority="high" referrerpolicy="same-origin"
width="{{ post.image.width }}" height="{{ post.image.height }}" /></a>
{% else -%}
<a href="{{ post.image.view_url() }}" rel="nofollow ugc">
<img src="{{ post.image.view_url(resize=True) }}" lowsrc="{{ post.image.medium_url() }}"
sizes="(max-width: 512px) 100vw, 854px" srcset="{{ post.image.medium_url() }} 512w, {{ post.image.view_url(resize=True) }} 1024w"
alt="{{ post.image.alt_text if post.image.alt_text else post.title }}"
fetchpriority="high" referrerpolicy="same-origin" >
</a>
{% endif -%}
</div>
{% endif %}
{{ render_field(form.image_file) }}
{{ render_field(form.image_alt_text) }}
<small class="field_hint">{{ _('Describe the image, to help visually impaired people.') }}</small>
{% elif post_type == POST_TYPE_VIDEO %}
{{ render_field(form.video_url) }}
<p class="small field_hint">{{ _('Provide a URL ending with .mp4 or .webm.') }}</p>
{% endif %}
{{ render_field(form.body) }}
{% if not low_bandwidth -%}
<div class="row">
<div class="col-6">
<a href="#" hx-post="{{ url_for('post.preview') }}" hx-target="#preview">{{ _('Preview') }}</a>
</div>
<div class="col-6 text-right">
{% if markdown_editor %}
<script nonce="{{ session['nonce'] }}">
window.addEventListener("load", function () {
var downarea = new DownArea({
elem: document.querySelector('#body'),
resize: DownArea.RESIZE_VERTICAL,
hide: ['heading', 'bold-italic'],
value: document.getElementById("body").value
});
setupAutoResize('body');
});
</script>
{% else %}
<a href="#" aria-hidden="true" class="markdown_editor_enabler create_post_markdown_editor_enabler" data-id="body">{{ _('Enable markdown editor') }}</a>
{% endif %}
</div>
</div>
<div class="row">
<div class="col">
<div id="preview"></div>
</div>
</div>
{% endif -%}
{% if post_type == POST_TYPE_POLL %}
<fieldset id="pollChoicesFieldset">
<legend>{{ _('Poll choices') }}</legend>
<div class="form-group">
{{ form.choice_1(class_="form-control", **{"placeholder": "First choice"}) }}
</div>
<div class="form-group">
{{ form.choice_2(class_="form-control", **{"placeholder": "Second choice"}) }}
</div>
<div class="form-group" style="{{ 'display: none;' if form.choice_3.data == none }}">
{{ form.choice_3(class_="form-control") }}
</div>
<div class="form-group" style="display: none;">
{{ form.choice_4(class_="form-control") }}
</div>
<div class="form-group" style="display: none;">
{{ form.choice_5(class_="form-control") }}
</div>
<div class="form-group" style="display: none;">
{{ form.choice_6(class_="form-control") }}
</div>
<div class="form-group" style="display: none;">
{{ form.choice_7(class_="form-control") }}
</div>
<div class="form-group" style="display: none;">
{{ form.choice_8(class_="form-control") }}
</div>
<div class="form-group" style="display: none;">
{{ form.choice_9(class_="form-control") }}
</div>
<div class="form-group" style="display: none;">
{{ form.choice_10(class_="form-control") }}
</div>
<button id="addPollChoice" type="button" class="btn btn-primary">{{ _('Add choice') }}</button>
</fieldset>
{{ render_field(form.mode) }}
{% if form.finish_in %}{{ render_field(form.finish_in) }}{% endif %}
{{ render_field(form.local_only) }}
{% endif %}
{{ render_field(form.tags) }}
<small class="field_hint">{{ _('Separate each tag with a comma.') }}</small>
<fieldset class="mt-4 mb-4 coolfieldset collapsed">
<legend class="w-auto">{{ _('More options') }}</legend>
{{ render_field(form.notify_author) }}
{{ render_field(form.sticky) }}
{{ render_field(form.nsfw) }}
{{ render_field(form.nsfl) }}
{{ render_field(form.language_id) }}
</fieldset>
{{ render_field(form.submit) }}
</form>
</div>
{% include "_side_pane.html" %}
</div>
{% endblock %}