mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
and body text fields to link and image posts
This commit is contained in:
parent
c8f837a52e
commit
afa93df35c
6 changed files with 17 additions and 2 deletions
|
@ -40,8 +40,12 @@ class CreatePostForm(FlaskForm):
|
|||
discussion_title = StringField(_l('Title'), validators={Optional(), Length(min=3, max=255)})
|
||||
discussion_body = TextAreaField(_l('Body'), validators={Optional(), Length(min=3, max=5000)}, render_kw={'placeholder': 'Text (optional)'})
|
||||
link_title = StringField(_l('Title'), validators={Optional(), Length(min=3, max=255)})
|
||||
link_body = TextAreaField(_l('Body'), validators={Optional(), Length(min=3, max=5000)},
|
||||
render_kw={'placeholder': 'Text (optional)'})
|
||||
link_url = StringField(_l('URL'), render_kw={'placeholder': 'https://...'})
|
||||
image_title = StringField(_l('Title'), validators={Optional(), Length(min=3, max=255)})
|
||||
image_body = TextAreaField(_l('Body'), validators={Optional(), Length(min=3, max=5000)},
|
||||
render_kw={'placeholder': 'Text (optional)'})
|
||||
image_file = FileField(_('Image'))
|
||||
# flair = SelectField(_l('Flair'), coerce=int)
|
||||
nsfw = BooleanField(_l('NSFW'))
|
||||
|
|
|
@ -352,7 +352,7 @@ def add_post(actor):
|
|||
],
|
||||
'name': post.title,
|
||||
'cc': [],
|
||||
'content': post.body_html,
|
||||
'content': post.body_html if post.body_html else '',
|
||||
'mediaType': 'text/html',
|
||||
'source': {
|
||||
'content': post.body if post.body else '',
|
||||
|
|
|
@ -169,6 +169,8 @@ def save_post(form, post: Post):
|
|||
post.type = POST_TYPE_ARTICLE
|
||||
elif form.type.data == 'link':
|
||||
post.title = form.link_title.data
|
||||
post.body = form.link_body.data
|
||||
post.body_html = markdown_to_html(post.body)
|
||||
url_changed = post.id is None or form.link_url.data != post.url
|
||||
post.url = form.link_url.data
|
||||
post.type = POST_TYPE_LINK
|
||||
|
@ -204,6 +206,8 @@ def save_post(form, post: Post):
|
|||
|
||||
elif form.type.data == 'image':
|
||||
post.title = form.image_title.data
|
||||
post.body = form.image_body.data
|
||||
post.body_html = markdown_to_html(post.body)
|
||||
post.type = POST_TYPE_IMAGE
|
||||
uploaded_file = request.files['image_file']
|
||||
if uploaded_file and uploaded_file.filename != '':
|
||||
|
|
|
@ -565,10 +565,12 @@ def post_edit(post_id: int):
|
|||
elif post.type == constants.POST_TYPE_LINK:
|
||||
form.type.data = 'link'
|
||||
form.link_title.data = post.title
|
||||
form.link_body.data = post.body
|
||||
form.link_url.data = post.url
|
||||
elif post.type == constants.POST_TYPE_IMAGE:
|
||||
form.type.data = 'image'
|
||||
form.image_title.data = post.title
|
||||
form.image_body.data = post.body
|
||||
form.notify_author.data = post.notify_author
|
||||
return render_template('post/post_edit.html', title=_('Edit post'), form=form, post=post,
|
||||
images_disabled=images_disabled, markdown_editor=True)
|
||||
|
|
|
@ -38,12 +38,14 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
<div class="tab-pane fade" id="link-tab-pane" role="tabpanel" aria-labelledby="profile-tab" tabindex="0">
|
||||
{{ render_field(form.link_url) }}
|
||||
{{ render_field(form.link_title) }}
|
||||
{{ render_field(form.link_url) }}
|
||||
{{ render_field(form.link_body) }}
|
||||
</div>
|
||||
<div class="tab-pane fade" id="image-tab-pane" role="tabpanel" aria-labelledby="contact-tab" tabindex="0">
|
||||
{{ render_field(form.image_title) }}
|
||||
{{ render_field(form.image_file) }}
|
||||
{{ render_field(form.image_body) }}
|
||||
</div>
|
||||
<div class="tab-pane fade" id="poll-tab-pane" role="tabpanel" aria-labelledby="disabled-tab" tabindex="0">
|
||||
Poll
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
<a href="{{ post.url }}" rel="nofollow ugc" target="_blank"><img src="{{ post.url }}" style="max-width: 100%; height: auto;" /></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="post_body mt-2">
|
||||
{{ post.body_html|safe if post.body_html else '' }}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="col post_col post_type_normal">
|
||||
|
|
Loading…
Reference in a new issue