mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
move all post_edit templates into one
This commit is contained in:
parent
4c0eb87c25
commit
a1fa74d3ba
15 changed files with 191 additions and 534 deletions
|
@ -92,10 +92,10 @@ class BanUserCommunityForm(FlaskForm):
|
||||||
submit = SubmitField(_l('Ban'))
|
submit = SubmitField(_l('Ban'))
|
||||||
|
|
||||||
|
|
||||||
class CreateDiscussionForm(FlaskForm):
|
class CreatePostForm(FlaskForm):
|
||||||
communities = SelectField(_l('Community'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'})
|
communities = SelectField(_l('Community'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'})
|
||||||
discussion_title = StringField(_l('Title'), validators=[DataRequired(), Length(min=3, max=255)])
|
title = StringField(_l('Title'), validators=[DataRequired(), Length(min=3, max=255)])
|
||||||
discussion_body = TextAreaField(_l('Body'), validators=[Optional(), Length(min=3, max=5000)], render_kw={'rows': 5})
|
body = TextAreaField(_l('Body'), validators=[Optional(), Length(min=3, max=5000)], render_kw={'rows': 5})
|
||||||
tags = StringField(_l('Tags'), validators=[Optional(), Length(min=3, max=5000)])
|
tags = StringField(_l('Tags'), validators=[Optional(), Length(min=3, max=5000)])
|
||||||
sticky = BooleanField(_l('Sticky'))
|
sticky = BooleanField(_l('Sticky'))
|
||||||
nsfw = BooleanField(_l('NSFW'))
|
nsfw = BooleanField(_l('NSFW'))
|
||||||
|
@ -105,19 +105,13 @@ class CreateDiscussionForm(FlaskForm):
|
||||||
submit = SubmitField(_l('Save'))
|
submit = SubmitField(_l('Save'))
|
||||||
|
|
||||||
|
|
||||||
class CreateLinkForm(FlaskForm):
|
class CreateDiscussionForm(CreatePostForm):
|
||||||
communities = SelectField(_l('Community'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'})
|
pass
|
||||||
link_title = StringField(_l('Title'), validators=[DataRequired(), Length(min=3, max=255)])
|
|
||||||
link_body = TextAreaField(_l('Body'), validators=[Optional(), Length(min=3, max=5000)], render_kw={'rows': 5})
|
|
||||||
|
class CreateLinkForm(CreatePostForm):
|
||||||
link_url = StringField(_l('URL'), validators=[DataRequired(), Regexp(r'^https?://', message='Submitted links need to start with "http://"" or "https://"')],
|
link_url = StringField(_l('URL'), validators=[DataRequired(), Regexp(r'^https?://', message='Submitted links need to start with "http://"" or "https://"')],
|
||||||
render_kw={'placeholder': 'https://...'})
|
render_kw={'placeholder': 'https://...'})
|
||||||
tags = StringField(_l('Tags'), validators=[Optional(), Length(min=3, max=5000)])
|
|
||||||
sticky = BooleanField(_l('Sticky'))
|
|
||||||
nsfw = BooleanField(_l('NSFW'))
|
|
||||||
nsfl = BooleanField(_l('Gore/gross'))
|
|
||||||
notify_author = BooleanField(_l('Notify about replies'))
|
|
||||||
language_id = SelectField(_l('Language'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'})
|
|
||||||
submit = SubmitField(_l('Save'))
|
|
||||||
|
|
||||||
def validate(self, extra_validators=None) -> bool:
|
def validate(self, extra_validators=None) -> bool:
|
||||||
domain = domain_from_url(self.link_url.data, create=False)
|
domain = domain_from_url(self.link_url.data, create=False)
|
||||||
|
@ -127,19 +121,9 @@ class CreateLinkForm(FlaskForm):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class CreateVideoForm(FlaskForm):
|
class CreateVideoForm(CreatePostForm):
|
||||||
communities = SelectField(_l('Community'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'})
|
|
||||||
video_title = StringField(_l('Title'), validators=[DataRequired(), Length(min=3, max=255)])
|
|
||||||
video_body = TextAreaField(_l('Body'), validators=[Optional(), Length(min=3, max=5000)], render_kw={'rows': 5})
|
|
||||||
video_url = StringField(_l('URL'), validators=[DataRequired(), Regexp(r'^https?://', message='Submitted links need to start with "http://"" or "https://"')],
|
video_url = StringField(_l('URL'), validators=[DataRequired(), Regexp(r'^https?://', message='Submitted links need to start with "http://"" or "https://"')],
|
||||||
render_kw={'placeholder': 'https://...'})
|
render_kw={'placeholder': 'https://...'})
|
||||||
tags = StringField(_l('Tags'), validators=[Optional(), Length(min=3, max=5000)])
|
|
||||||
sticky = BooleanField(_l('Sticky'))
|
|
||||||
nsfw = BooleanField(_l('NSFW'))
|
|
||||||
nsfl = BooleanField(_l('Gore/gross'))
|
|
||||||
notify_author = BooleanField(_l('Notify about replies'))
|
|
||||||
language_id = SelectField(_l('Language'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'})
|
|
||||||
submit = SubmitField(_l('Save'))
|
|
||||||
|
|
||||||
def validate(self, extra_validators=None) -> bool:
|
def validate(self, extra_validators=None) -> bool:
|
||||||
domain = domain_from_url(self.video_url.data, create=False)
|
domain = domain_from_url(self.video_url.data, create=False)
|
||||||
|
@ -149,19 +133,9 @@ class CreateVideoForm(FlaskForm):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class CreateImageForm(FlaskForm):
|
class CreateImageForm(CreatePostForm):
|
||||||
communities = SelectField(_l('Community'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'})
|
|
||||||
image_title = StringField(_l('Title'), validators=[DataRequired(), Length(min=3, max=255)])
|
|
||||||
image_alt_text = StringField(_l('Alt text'), validators=[Optional(), Length(min=3, max=1500)])
|
image_alt_text = StringField(_l('Alt text'), validators=[Optional(), Length(min=3, max=1500)])
|
||||||
image_body = TextAreaField(_l('Body'), validators=[Optional(), Length(min=3, max=5000)], render_kw={'rows': 5})
|
|
||||||
image_file = FileField(_l('Image'), validators=[DataRequired()], render_kw={'accept': 'image/*'})
|
image_file = FileField(_l('Image'), validators=[DataRequired()], render_kw={'accept': 'image/*'})
|
||||||
tags = StringField(_l('Tags'), validators=[Optional(), Length(min=3, max=5000)])
|
|
||||||
sticky = BooleanField(_l('Sticky'))
|
|
||||||
nsfw = BooleanField(_l('NSFW'))
|
|
||||||
nsfl = BooleanField(_l('Gore/gross'))
|
|
||||||
notify_author = BooleanField(_l('Notify about replies'))
|
|
||||||
language_id = SelectField(_l('Language'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'})
|
|
||||||
submit = SubmitField(_l('Save'))
|
|
||||||
|
|
||||||
def validate(self, extra_validators=None) -> bool:
|
def validate(self, extra_validators=None) -> bool:
|
||||||
uploaded_file = request.files['image_file']
|
uploaded_file = request.files['image_file']
|
||||||
|
@ -187,10 +161,7 @@ class CreateImageForm(FlaskForm):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class CreatePollForm(FlaskForm):
|
class CreatePollForm(CreatePostForm):
|
||||||
communities = SelectField(_l('Community'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'})
|
|
||||||
poll_title = StringField(_l('Title'), validators=[DataRequired(), Length(min=3, max=255)])
|
|
||||||
poll_body = TextAreaField(_l('Body'), validators=[Optional(), Length(min=3, max=5000)], render_kw={'rows': 5})
|
|
||||||
mode = SelectField(_('Mode'), validators=[DataRequired()], choices=[('single', _l('Voters choose one option')), ('multiple', _l('Voters choose many options'))], render_kw={'class': 'form-select'})
|
mode = SelectField(_('Mode'), validators=[DataRequired()], choices=[('single', _l('Voters choose one option')), ('multiple', _l('Voters choose many options'))], render_kw={'class': 'form-select'})
|
||||||
finish_choices=[
|
finish_choices=[
|
||||||
('30m', _l('30 minutes')),
|
('30m', _l('30 minutes')),
|
||||||
|
@ -213,13 +184,6 @@ class CreatePollForm(FlaskForm):
|
||||||
choice_8 = StringField('Choice')
|
choice_8 = StringField('Choice')
|
||||||
choice_9 = StringField('Choice')
|
choice_9 = StringField('Choice')
|
||||||
choice_10 = StringField('Choice')
|
choice_10 = StringField('Choice')
|
||||||
tags = StringField(_l('Tags'), validators=[Optional(), Length(min=3, max=5000)])
|
|
||||||
sticky = BooleanField(_l('Sticky'))
|
|
||||||
nsfw = BooleanField(_l('NSFW'))
|
|
||||||
nsfl = BooleanField(_l('Gore/gross'))
|
|
||||||
notify_author = BooleanField(_l('Notify about replies'))
|
|
||||||
language_id = SelectField(_l('Language'), validators=[DataRequired()], coerce=int, render_kw={'class': 'form-select'})
|
|
||||||
submit = SubmitField(_l('Save'))
|
|
||||||
|
|
||||||
def validate(self, extra_validators=None) -> bool:
|
def validate(self, extra_validators=None) -> bool:
|
||||||
choices_made = 0
|
choices_made = 0
|
||||||
|
|
|
@ -250,15 +250,12 @@ def save_post(form, post: Post, type: str):
|
||||||
post.notify_author = form.notify_author.data
|
post.notify_author = form.notify_author.data
|
||||||
post.language_id = form.language_id.data
|
post.language_id = form.language_id.data
|
||||||
current_user.language_id = form.language_id.data
|
current_user.language_id = form.language_id.data
|
||||||
|
post.title = form.title.data
|
||||||
|
post.body = form.body.data
|
||||||
|
post.body_html = markdown_to_html(post.body)
|
||||||
if type == '' or type == 'discussion':
|
if type == '' or type == 'discussion':
|
||||||
post.title = form.discussion_title.data
|
|
||||||
post.body = form.discussion_body.data
|
|
||||||
post.body_html = markdown_to_html(post.body)
|
|
||||||
post.type = POST_TYPE_ARTICLE
|
post.type = POST_TYPE_ARTICLE
|
||||||
elif type == 'link':
|
elif type == '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
|
url_changed = post.id is None or form.link_url.data != post.url
|
||||||
post.url = remove_tracking_from_link(form.link_url.data.strip())
|
post.url = remove_tracking_from_link(form.link_url.data.strip())
|
||||||
post.type = POST_TYPE_LINK
|
post.type = POST_TYPE_LINK
|
||||||
|
@ -298,11 +295,8 @@ def save_post(form, post: Post, type: str):
|
||||||
db.session.add(file)
|
db.session.add(file)
|
||||||
|
|
||||||
elif type == 'image':
|
elif type == '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
|
post.type = POST_TYPE_IMAGE
|
||||||
alt_text = form.image_alt_text.data if form.image_alt_text.data else form.image_title.data
|
alt_text = form.image_alt_text.data if form.image_alt_text.data else form.title.data
|
||||||
uploaded_file = request.files['image_file']
|
uploaded_file = request.files['image_file']
|
||||||
if uploaded_file and uploaded_file.filename != '':
|
if uploaded_file and uploaded_file.filename != '':
|
||||||
if post.image_id:
|
if post.image_id:
|
||||||
|
@ -359,9 +353,6 @@ def save_post(form, post: Post, type: str):
|
||||||
post.image_id = file.id
|
post.image_id = file.id
|
||||||
elif type == 'video':
|
elif type == 'video':
|
||||||
form.video_url.data = form.video_url.data.strip()
|
form.video_url.data = form.video_url.data.strip()
|
||||||
post.title = form.video_title.data
|
|
||||||
post.body = form.video_body.data
|
|
||||||
post.body_html = markdown_to_html(post.body)
|
|
||||||
url_changed = post.id is None or form.video_url.data != post.url
|
url_changed = post.id is None or form.video_url.data != post.url
|
||||||
post.url = remove_tracking_from_link(form.video_url.data.strip())
|
post.url = remove_tracking_from_link(form.video_url.data.strip())
|
||||||
post.type = POST_TYPE_VIDEO
|
post.type = POST_TYPE_VIDEO
|
||||||
|
@ -390,8 +381,7 @@ def save_post(form, post: Post, type: str):
|
||||||
db.session.add(file)
|
db.session.add(file)
|
||||||
|
|
||||||
elif type == 'poll':
|
elif type == 'poll':
|
||||||
post.title = form.poll_title.data
|
post.body = form.title.data + '\n' + form.body.data if post.title not in form.body.data else form.body.data
|
||||||
post.body = form.poll_title.data + '\n' + form.poll_body.data if post.title not in form.poll_body.data else form.poll_body.data
|
|
||||||
post.body_html = markdown_to_html(post.body)
|
post.body_html = markdown_to_html(post.body)
|
||||||
post.type = POST_TYPE_POLL
|
post.type = POST_TYPE_POLL
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -950,8 +950,8 @@ def post_edit_discussion_post(post_id: int):
|
||||||
|
|
||||||
return redirect(url_for('activitypub.post_ap', post_id=post.id))
|
return redirect(url_for('activitypub.post_ap', post_id=post.id))
|
||||||
else:
|
else:
|
||||||
form.discussion_title.data = post.title
|
form.title.data = post.title
|
||||||
form.discussion_body.data = post.body
|
form.body.data = post.body
|
||||||
form.notify_author.data = post.notify_author
|
form.notify_author.data = post.notify_author
|
||||||
form.nsfw.data = post.nsfw
|
form.nsfw.data = post.nsfw
|
||||||
form.nsfl.data = post.nsfl
|
form.nsfl.data = post.nsfl
|
||||||
|
@ -960,7 +960,7 @@ def post_edit_discussion_post(post_id: int):
|
||||||
form.tags.data = tags_to_string(post)
|
form.tags.data = tags_to_string(post)
|
||||||
if not (post.community.is_moderator() or post.community.is_owner() or current_user.is_admin()):
|
if not (post.community.is_moderator() or post.community.is_owner() or current_user.is_admin()):
|
||||||
form.sticky.render_kw = {'disabled': True}
|
form.sticky.render_kw = {'disabled': True}
|
||||||
return render_template('post/post_edit_discussion.html', title=_('Edit post'), form=form, post=post,
|
return render_template('post/post_edit.html', title=_('Edit post'), form=form, post=post,
|
||||||
markdown_editor=current_user.markdown_editor, mods=mod_list,
|
markdown_editor=current_user.markdown_editor, mods=mod_list,
|
||||||
moderating_communities=moderating_communities(current_user.get_id()),
|
moderating_communities=moderating_communities(current_user.get_id()),
|
||||||
joined_communities=joined_communities(current_user.get_id()),
|
joined_communities=joined_communities(current_user.get_id()),
|
||||||
|
@ -1036,8 +1036,8 @@ def post_edit_image_post(post_id: int):
|
||||||
|
|
||||||
return redirect(url_for('activitypub.post_ap', post_id=post.id))
|
return redirect(url_for('activitypub.post_ap', post_id=post.id))
|
||||||
else:
|
else:
|
||||||
form.image_title.data = post.title
|
form.title.data = post.title
|
||||||
form.image_body.data = post.body
|
form.body.data = post.body
|
||||||
form.image_alt_text.data = post.image.alt_text
|
form.image_alt_text.data = post.image.alt_text
|
||||||
form.notify_author.data = post.notify_author
|
form.notify_author.data = post.notify_author
|
||||||
form.nsfw.data = post.nsfw
|
form.nsfw.data = post.nsfw
|
||||||
|
@ -1047,7 +1047,7 @@ def post_edit_image_post(post_id: int):
|
||||||
form.tags.data = tags_to_string(post)
|
form.tags.data = tags_to_string(post)
|
||||||
if not (post.community.is_moderator() or post.community.is_owner() or current_user.is_admin()):
|
if not (post.community.is_moderator() or post.community.is_owner() or current_user.is_admin()):
|
||||||
form.sticky.render_kw = {'disabled': True}
|
form.sticky.render_kw = {'disabled': True}
|
||||||
return render_template('post/post_edit_image.html', title=_('Edit post'), form=form, post=post,
|
return render_template('post/post_edit.html', title=_('Edit post'), form=form, post=post,
|
||||||
markdown_editor=current_user.markdown_editor, mods=mod_list,
|
markdown_editor=current_user.markdown_editor, mods=mod_list,
|
||||||
moderating_communities=moderating_communities(current_user.get_id()),
|
moderating_communities=moderating_communities(current_user.get_id()),
|
||||||
joined_communities=joined_communities(current_user.get_id()),
|
joined_communities=joined_communities(current_user.get_id()),
|
||||||
|
@ -1123,8 +1123,8 @@ def post_edit_link_post(post_id: int):
|
||||||
|
|
||||||
return redirect(url_for('activitypub.post_ap', post_id=post.id))
|
return redirect(url_for('activitypub.post_ap', post_id=post.id))
|
||||||
else:
|
else:
|
||||||
form.link_title.data = post.title
|
form.title.data = post.title
|
||||||
form.link_body.data = post.body
|
form.body.data = post.body
|
||||||
form.link_url.data = post.url
|
form.link_url.data = post.url
|
||||||
form.notify_author.data = post.notify_author
|
form.notify_author.data = post.notify_author
|
||||||
form.nsfw.data = post.nsfw
|
form.nsfw.data = post.nsfw
|
||||||
|
@ -1134,7 +1134,7 @@ def post_edit_link_post(post_id: int):
|
||||||
form.tags.data = tags_to_string(post)
|
form.tags.data = tags_to_string(post)
|
||||||
if not (post.community.is_moderator() or post.community.is_owner() or current_user.is_admin()):
|
if not (post.community.is_moderator() or post.community.is_owner() or current_user.is_admin()):
|
||||||
form.sticky.render_kw = {'disabled': True}
|
form.sticky.render_kw = {'disabled': True}
|
||||||
return render_template('post/post_edit_link.html', title=_('Edit post'), form=form, post=post,
|
return render_template('post/post_edit.html', title=_('Edit post'), form=form, post=post,
|
||||||
markdown_editor=current_user.markdown_editor, mods=mod_list,
|
markdown_editor=current_user.markdown_editor, mods=mod_list,
|
||||||
moderating_communities=moderating_communities(current_user.get_id()),
|
moderating_communities=moderating_communities(current_user.get_id()),
|
||||||
joined_communities=joined_communities(current_user.get_id()),
|
joined_communities=joined_communities(current_user.get_id()),
|
||||||
|
@ -1210,8 +1210,8 @@ def post_edit_video_post(post_id: int):
|
||||||
|
|
||||||
return redirect(url_for('activitypub.post_ap', post_id=post.id))
|
return redirect(url_for('activitypub.post_ap', post_id=post.id))
|
||||||
else:
|
else:
|
||||||
form.video_title.data = post.title
|
form.title.data = post.title
|
||||||
form.video_body.data = post.body
|
form.body.data = post.body
|
||||||
form.video_url.data = post.url
|
form.video_url.data = post.url
|
||||||
form.notify_author.data = post.notify_author
|
form.notify_author.data = post.notify_author
|
||||||
form.nsfw.data = post.nsfw
|
form.nsfw.data = post.nsfw
|
||||||
|
@ -1221,7 +1221,7 @@ def post_edit_video_post(post_id: int):
|
||||||
form.tags.data = tags_to_string(post)
|
form.tags.data = tags_to_string(post)
|
||||||
if not (post.community.is_moderator() or post.community.is_owner() or current_user.is_admin()):
|
if not (post.community.is_moderator() or post.community.is_owner() or current_user.is_admin()):
|
||||||
form.sticky.render_kw = {'disabled': True}
|
form.sticky.render_kw = {'disabled': True}
|
||||||
return render_template('post/post_edit_video.html', title=_('Edit post'), form=form, post=post,
|
return render_template('post/post_edit.html', title=_('Edit post'), form=form, post=post,
|
||||||
markdown_editor=current_user.markdown_editor, mods=mod_list,
|
markdown_editor=current_user.markdown_editor, mods=mod_list,
|
||||||
moderating_communities=moderating_communities(current_user.get_id()),
|
moderating_communities=moderating_communities(current_user.get_id()),
|
||||||
joined_communities=joined_communities(current_user.get_id()),
|
joined_communities=joined_communities(current_user.get_id()),
|
||||||
|
@ -1275,8 +1275,8 @@ def post_edit_poll_post(post_id: int):
|
||||||
|
|
||||||
return redirect(url_for('activitypub.post_ap', post_id=post.id))
|
return redirect(url_for('activitypub.post_ap', post_id=post.id))
|
||||||
else:
|
else:
|
||||||
form.poll_title.data = post.title
|
form.title.data = post.title
|
||||||
form.poll_body.data = post.body
|
form.body.data = post.body
|
||||||
form.notify_author.data = post.notify_author
|
form.notify_author.data = post.notify_author
|
||||||
form.nsfw.data = post.nsfw
|
form.nsfw.data = post.nsfw
|
||||||
form.nsfl.data = post.nsfl
|
form.nsfl.data = post.nsfl
|
||||||
|
@ -1293,7 +1293,7 @@ def post_edit_poll_post(post_id: int):
|
||||||
form.tags.data = tags_to_string(post)
|
form.tags.data = tags_to_string(post)
|
||||||
if not (post.community.is_moderator() or post.community.is_owner() or current_user.is_admin()):
|
if not (post.community.is_moderator() or post.community.is_owner() or current_user.is_admin()):
|
||||||
form.sticky.render_kw = {'disabled': True}
|
form.sticky.render_kw = {'disabled': True}
|
||||||
return render_template('post/post_edit_poll.html', title=_('Edit post'), form=form, post=post,
|
return render_template('post/post_edit.html', title=_('Edit post'), form=form, post=post,
|
||||||
markdown_editor=current_user.markdown_editor, mods=mod_list,
|
markdown_editor=current_user.markdown_editor, mods=mod_list,
|
||||||
moderating_communities=moderating_communities(current_user.get_id()),
|
moderating_communities=moderating_communities(current_user.get_id()),
|
||||||
joined_communities=joined_communities(current_user.get_id()),
|
joined_communities=joined_communities(current_user.get_id()),
|
||||||
|
|
|
@ -19,22 +19,22 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ render_field(form.communities) }}
|
{{ render_field(form.communities) }}
|
||||||
{{ render_field(form.discussion_title) }}
|
{{ render_field(form.title) }}
|
||||||
{{ render_field(form.discussion_body) }}
|
{{ render_field(form.body) }}
|
||||||
{% if not low_bandwidth %}
|
{% if not low_bandwidth %}
|
||||||
{% if markdown_editor %}
|
{% if markdown_editor %}
|
||||||
<script nonce="{{ session['nonce'] }}">
|
<script nonce="{{ session['nonce'] }}">
|
||||||
window.addEventListener("load", function () {
|
window.addEventListener("load", function () {
|
||||||
var downarea = new DownArea({
|
var downarea = new DownArea({
|
||||||
elem: document.querySelector('#discussion_body'),
|
elem: document.querySelector('#body'),
|
||||||
resize: DownArea.RESIZE_VERTICAL,
|
resize: DownArea.RESIZE_VERTICAL,
|
||||||
hide: ['heading', 'bold-italic'],
|
hide: ['heading', 'bold-italic'],
|
||||||
});
|
});
|
||||||
setupAutoResize('discussion_body');
|
setupAutoResize('body');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="#" aria-hidden="true" class="markdown_editor_enabler create_post_markdown_editor_enabler" data-id="discussion_body">{{ _('Enable markdown editor') }}</a>
|
<a href="#" aria-hidden="true" class="markdown_editor_enabler create_post_markdown_editor_enabler" data-id="body">{{ _('Enable markdown editor') }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ render_field(form.tags) }}
|
{{ render_field(form.tags) }}
|
||||||
|
@ -88,4 +88,4 @@
|
||||||
{% include "_inoculation_links.html" %}
|
{% include "_inoculation_links.html" %}
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -18,25 +18,25 @@
|
||||||
{% include 'community/_add_post_types.html' %}
|
{% include 'community/_add_post_types.html' %}
|
||||||
</div>
|
</div>
|
||||||
{{ render_field(form.communities) }}
|
{{ render_field(form.communities) }}
|
||||||
{{ render_field(form.image_title) }}
|
{{ render_field(form.title) }}
|
||||||
{{ render_field(form.image_file) }}
|
{{ render_field(form.image_file) }}
|
||||||
{{ render_field(form.image_alt_text) }}
|
{{ render_field(form.image_alt_text) }}
|
||||||
<small class="field_hint">{{ _('Describe the image, to help visually impaired people.') }}</small>
|
<small class="field_hint">{{ _('Describe the image, to help visually impaired people.') }}</small>
|
||||||
{{ render_field(form.image_body) }}
|
{{ render_field(form.body) }}
|
||||||
{% if not low_bandwidth %}
|
{% if not low_bandwidth %}
|
||||||
{% if markdown_editor %}
|
{% if markdown_editor %}
|
||||||
<script nonce="{{ session['nonce'] }}">
|
<script nonce="{{ session['nonce'] }}">
|
||||||
window.addEventListener("load", function () {
|
window.addEventListener("load", function () {
|
||||||
var downarea = new DownArea({
|
var downarea = new DownArea({
|
||||||
elem: document.querySelector('#image_body'),
|
elem: document.querySelector('#body'),
|
||||||
resize: DownArea.RESIZE_VERTICAL,
|
resize: DownArea.RESIZE_VERTICAL,
|
||||||
hide: ['heading', 'bold-italic'],
|
hide: ['heading', 'bold-italic'],
|
||||||
});
|
});
|
||||||
setupAutoResize('image_body');
|
setupAutoResize('body');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="#" aria-hidden="true" class="markdown_editor_enabler create_post_markdown_editor_enabler" data-id="image_body">{{ _('Enable markdown editor') }}</a>
|
<a href="#" aria-hidden="true" class="markdown_editor_enabler create_post_markdown_editor_enabler" data-id="body">{{ _('Enable markdown editor') }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ render_field(form.tags) }}
|
{{ render_field(form.tags) }}
|
||||||
|
@ -90,4 +90,4 @@
|
||||||
{% include "_inoculation_links.html" %}
|
{% include "_inoculation_links.html" %}
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -19,23 +19,23 @@
|
||||||
</div>
|
</div>
|
||||||
{{ render_field(form.communities) }}
|
{{ render_field(form.communities) }}
|
||||||
|
|
||||||
{{ render_field(form.link_title) }}
|
{{ render_field(form.title) }}
|
||||||
{{ render_field(form.link_url) }}
|
{{ render_field(form.link_url) }}
|
||||||
{{ render_field(form.link_body) }}
|
{{ render_field(form.body) }}
|
||||||
{% if not low_bandwidth %}
|
{% if not low_bandwidth %}
|
||||||
{% if markdown_editor %}
|
{% if markdown_editor %}
|
||||||
<script nonce="{{ session['nonce'] }}">
|
<script nonce="{{ session['nonce'] }}">
|
||||||
window.addEventListener("load", function () {
|
window.addEventListener("load", function () {
|
||||||
var downarea = new DownArea({
|
var downarea = new DownArea({
|
||||||
elem: document.querySelector('#link_body'),
|
elem: document.querySelector('#body'),
|
||||||
resize: DownArea.RESIZE_VERTICAL,
|
resize: DownArea.RESIZE_VERTICAL,
|
||||||
hide: ['heading', 'bold-italic'],
|
hide: ['heading', 'bold-italic'],
|
||||||
});
|
});
|
||||||
setupAutoResize('link_body');
|
setupAutoResize('body');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="#" aria-hidden="true" class="markdown_editor_enabler create_post_markdown_editor_enabler" data-id="link_body">{{ _('Enable markdown editor') }}</a>
|
<a href="#" aria-hidden="true" class="markdown_editor_enabler create_post_markdown_editor_enabler" data-id="body">{{ _('Enable markdown editor') }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ render_field(form.tags) }}
|
{{ render_field(form.tags) }}
|
||||||
|
@ -89,4 +89,4 @@
|
||||||
{% include "_inoculation_links.html" %}
|
{% include "_inoculation_links.html" %}
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -19,22 +19,22 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ render_field(form.communities) }}
|
{{ render_field(form.communities) }}
|
||||||
{{ render_field(form.poll_title) }}
|
{{ render_field(form.title) }}
|
||||||
{{ render_field(form.poll_body) }}
|
{{ render_field(form.body) }}
|
||||||
{% if not low_bandwidth %}
|
{% if not low_bandwidth %}
|
||||||
{% if markdown_editor %}
|
{% if markdown_editor %}
|
||||||
<script nonce="{{ session['nonce'] }}">
|
<script nonce="{{ session['nonce'] }}">
|
||||||
window.addEventListener("load", function () {
|
window.addEventListener("load", function () {
|
||||||
var downarea = new DownArea({
|
var downarea = new DownArea({
|
||||||
elem: document.querySelector('#poll_body'),
|
elem: document.querySelector('#body'),
|
||||||
resize: DownArea.RESIZE_VERTICAL,
|
resize: DownArea.RESIZE_VERTICAL,
|
||||||
hide: ['heading', 'bold-italic'],
|
hide: ['heading', 'bold-italic'],
|
||||||
});
|
});
|
||||||
setupAutoResize('discussion_body');
|
setupAutoResize('body');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="#" aria-hidden="true" class="markdown_editor_enabler create_post_markdown_editor_enabler" data-id="discussion_body">{{ _('Enable markdown editor') }}</a>
|
<a href="#" aria-hidden="true" class="markdown_editor_enabler create_post_markdown_editor_enabler" data-id="body">{{ _('Enable markdown editor') }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<fieldset id="pollChoicesFieldset">
|
<fieldset id="pollChoicesFieldset">
|
||||||
|
@ -125,4 +125,4 @@
|
||||||
{% include "_inoculation_links.html" %}
|
{% include "_inoculation_links.html" %}
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -19,24 +19,24 @@
|
||||||
</div>
|
</div>
|
||||||
{{ render_field(form.communities) }}
|
{{ render_field(form.communities) }}
|
||||||
|
|
||||||
{{ render_field(form.video_title) }}
|
{{ render_field(form.title) }}
|
||||||
{{ render_field(form.video_url) }}
|
{{ render_field(form.video_url) }}
|
||||||
<p class="small field_hint">{{ _('Provide a URL ending with .mp4 or .webm.') }}</p>
|
<p class="small field_hint">{{ _('Provide a URL ending with .mp4 or .webm.') }}</p>
|
||||||
{{ render_field(form.video_body) }}
|
{{ render_field(form.body) }}
|
||||||
{% if not low_bandwidth %}
|
{% if not low_bandwidth %}
|
||||||
{% if markdown_editor %}
|
{% if markdown_editor %}
|
||||||
<script nonce="{{ session['nonce'] }}">
|
<script nonce="{{ session['nonce'] }}">
|
||||||
window.addEventListener("load", function () {
|
window.addEventListener("load", function () {
|
||||||
var downarea = new DownArea({
|
var downarea = new DownArea({
|
||||||
elem: document.querySelector('#video_body'),
|
elem: document.querySelector('#body'),
|
||||||
resize: DownArea.RESIZE_VERTICAL,
|
resize: DownArea.RESIZE_VERTICAL,
|
||||||
hide: ['heading', 'bold-italic'],
|
hide: ['heading', 'bold-italic'],
|
||||||
});
|
});
|
||||||
setupAutoResize('video_body');
|
setupAutoResize('body');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="#" aria-hidden="true" class="markdown_editor_enabler create_post_markdown_editor_enabler" data-id="link_body">{{ _('Enable markdown editor') }}</a>
|
<a href="#" aria-hidden="true" class="markdown_editor_enabler create_post_markdown_editor_enabler" data-id="body">{{ _('Enable markdown editor') }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ render_field(form.tags) }}
|
{{ render_field(form.tags) }}
|
||||||
|
@ -90,4 +90,4 @@
|
||||||
{% include "_inoculation_links.html" %}
|
{% include "_inoculation_links.html" %}
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
127
app/templates/post/post_edit.html
Normal file
127
app/templates/post/post_edit.html
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
{% 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 %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 col-md-8 position-relative main_pane">
|
||||||
|
<h1>{{ _('Edit post') }}</h1>
|
||||||
|
<form method="post" enctype="multipart/form-data" role="form">
|
||||||
|
{{ form.csrf_token() }}
|
||||||
|
{{ render_field(form.title) }}
|
||||||
|
{% if post.type == POST_TYPE_LINK %}
|
||||||
|
{{ render_field(form.link_url) }}
|
||||||
|
{% elif post.type == POST_TYPE_IMAGE %}
|
||||||
|
{{ 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) }}
|
||||||
|
{% endif %}
|
||||||
|
{{ render_field(form.body) }}
|
||||||
|
|
||||||
|
{% 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: {{ form.body.data | tojson | safe }},
|
||||||
|
});
|
||||||
|
setupAutoResize('body');
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% 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) }}
|
||||||
|
{{ render_field(form.local_only) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{{ render_field(form.tags) }}
|
||||||
|
<small class="field_hint">{{ _('Separate each tag with a comma.') }}</small>
|
||||||
|
|
||||||
|
<div class="row mt-4">
|
||||||
|
<div class="col-md-3">
|
||||||
|
{{ render_field(form.notify_author) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-1">
|
||||||
|
{{ render_field(form.sticky) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-1">
|
||||||
|
{{ render_field(form.nsfw) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-1">
|
||||||
|
{{ render_field(form.nsfl) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col post_language_chooser">
|
||||||
|
{{ render_field(form.language_id) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{ render_field(form.submit) }}
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<aside id="side_pane" class="col-12 col-md-4 side_pane" role="complementary">
|
||||||
|
<div class="card mt-3">
|
||||||
|
<div class="card-header">
|
||||||
|
<h2>{{ post.community.title }}</h2>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<p>{{ post.community.description_html|safe if post.community.description_html else '' }}</p>
|
||||||
|
<p>{{ post.community.rules_html|safe if post.community.rules_html else '' }}</p>
|
||||||
|
{% if len(mods) > 0 and not post.community.private_mods %}
|
||||||
|
<h3>Moderators</h3>
|
||||||
|
<ul class="moderator_list">
|
||||||
|
{% for mod in mods %}
|
||||||
|
<li><a href="/u/{{ mod.link() }}">{{ mod.display_name() }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% include "_inoculation_links.html" %}
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
|
@ -1,77 +0,0 @@
|
||||||
{% 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 %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12 col-md-8 position-relative main_pane">
|
|
||||||
<h1>{{ _('Edit post') }}</h1>
|
|
||||||
<form method="post" role="form">
|
|
||||||
{{ form.csrf_token() }}
|
|
||||||
{{ render_field(form.discussion_title) }}
|
|
||||||
{{ render_field(form.discussion_body) }}
|
|
||||||
{% if markdown_editor %}
|
|
||||||
<script nonce="{{ session['nonce'] }}">
|
|
||||||
window.addEventListener("load", function () {
|
|
||||||
var downarea = new DownArea({
|
|
||||||
elem: document.querySelector('#discussion_body'),
|
|
||||||
resize: DownArea.RESIZE_VERTICAL,
|
|
||||||
hide: ['heading', 'bold-italic'],
|
|
||||||
value: {{ form.discussion_body.data | tojson | safe }},
|
|
||||||
});
|
|
||||||
setupAutoResize('discussion_body');
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
{{ render_field(form.tags) }}
|
|
||||||
<small class="field_hint">{{ _('Separate each tag with a comma.') }}</small>
|
|
||||||
|
|
||||||
<div class="row mt-4">
|
|
||||||
<div class="col-md-3">
|
|
||||||
{{ render_field(form.notify_author) }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-1">
|
|
||||||
{{ render_field(form.sticky) }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-1">
|
|
||||||
{{ render_field(form.nsfw) }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-1">
|
|
||||||
{{ render_field(form.nsfl) }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col post_language_chooser">
|
|
||||||
{{ render_field(form.language_id) }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{ render_field(form.submit) }}
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<aside id="side_pane" class="col-12 col-md-4 side_pane" role="complementary">
|
|
||||||
<div class="card mt-3">
|
|
||||||
<div class="card-header">
|
|
||||||
<h2>{{ post.community.title }}</h2>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<p>{{ post.community.description_html|safe if post.community.description_html else '' }}</p>
|
|
||||||
<p>{{ post.community.rules_html|safe if post.community.rules_html else '' }}</p>
|
|
||||||
{% if len(mods) > 0 and not post.community.private_mods %}
|
|
||||||
<h3>Moderators</h3>
|
|
||||||
<ul class="moderator_list">
|
|
||||||
{% for mod in mods %}
|
|
||||||
<li><a href="/u/{{ mod.link() }}">{{ mod.display_name() }}</a></li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% include "_inoculation_links.html" %}
|
|
||||||
</aside>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
|
@ -1,80 +0,0 @@
|
||||||
{% 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 %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12 col-md-8 position-relative main_pane">
|
|
||||||
<h1>{{ _('Edit post') }}</h1>
|
|
||||||
<form method="post" enctype="multipart/form-data" role="form">
|
|
||||||
{{ form.csrf_token() }}
|
|
||||||
{{ render_field(form.image_title) }}
|
|
||||||
{{ render_field(form.image_file) }}
|
|
||||||
{{ render_field(form.image_alt_text) }}
|
|
||||||
<small class="field_hint">{{ _('Describe the image, to help visually impaired people.') }}</small>
|
|
||||||
{{ render_field(form.image_body) }}
|
|
||||||
{% if markdown_editor %}
|
|
||||||
<script nonce="{{ session['nonce'] }}">
|
|
||||||
window.addEventListener("load", function () {
|
|
||||||
var downarea = new DownArea({
|
|
||||||
elem: document.querySelector('#image_body'),
|
|
||||||
resize: DownArea.RESIZE_VERTICAL,
|
|
||||||
hide: ['heading', 'bold-italic'],
|
|
||||||
value: {{ form.image_body.data | tojson | safe }},
|
|
||||||
});
|
|
||||||
setupAutoResize('image_body');
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
{{ render_field(form.tags) }}
|
|
||||||
<small class="field_hint">{{ _('Separate each tag with a comma.') }}</small>
|
|
||||||
|
|
||||||
<div class="row mt-4">
|
|
||||||
<div class="col-md-3">
|
|
||||||
{{ render_field(form.notify_author) }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-1">
|
|
||||||
{{ render_field(form.sticky) }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-1">
|
|
||||||
{{ render_field(form.nsfw) }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-1">
|
|
||||||
{{ render_field(form.nsfl) }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col post_language_chooser">
|
|
||||||
{{ render_field(form.language_id) }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{ render_field(form.submit) }}
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<aside id="side_pane" class="col-12 col-md-4 side_pane" role="complementary">
|
|
||||||
<div class="card mt-3">
|
|
||||||
<div class="card-header">
|
|
||||||
<h2>{{ post.community.title }}</h2>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<p>{{ post.community.description_html|safe if post.community.description_html else '' }}</p>
|
|
||||||
<p>{{ post.community.rules_html|safe if post.community.rules_html else '' }}</p>
|
|
||||||
{% if len(mods) > 0 and not post.community.private_mods %}
|
|
||||||
<h3>Moderators</h3>
|
|
||||||
<ul class="moderator_list">
|
|
||||||
{% for mod in mods %}
|
|
||||||
<li><a href="/u/{{ mod.link() }}">{{ mod.display_name() }}</a></li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% include "_inoculation_links.html" %}
|
|
||||||
</aside>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
|
@ -1,77 +0,0 @@
|
||||||
{% 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 %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12 col-md-8 position-relative main_pane">
|
|
||||||
<h1>{{ _('Edit post') }}</h1>
|
|
||||||
<form method="post" enctype="multipart/form-data" role="form">
|
|
||||||
{{ form.csrf_token() }}
|
|
||||||
{{ render_field(form.link_title) }}
|
|
||||||
{{ render_field(form.link_url) }}
|
|
||||||
{{ render_field(form.link_body) }}
|
|
||||||
{% if markdown_editor %}
|
|
||||||
<script nonce="{{ session['nonce'] }}">
|
|
||||||
window.addEventListener("load", function () {
|
|
||||||
var downarea = new DownArea({
|
|
||||||
elem: document.querySelector('#link_body'),
|
|
||||||
resize: DownArea.RESIZE_VERTICAL,
|
|
||||||
hide: ['heading', 'bold-italic'],
|
|
||||||
value: {{ form.link_body.data | tojson | safe }},
|
|
||||||
});
|
|
||||||
setupAutoResize('link_body');
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
{{ render_field(form.tags) }}
|
|
||||||
<small class="field_hint">{{ _('Separate each tag with a comma.') }}</small>
|
|
||||||
<div class="row mt-4">
|
|
||||||
<div class="col-md-3">
|
|
||||||
{{ render_field(form.notify_author) }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-1">
|
|
||||||
{{ render_field(form.sticky) }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-1">
|
|
||||||
{{ render_field(form.nsfw) }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-1">
|
|
||||||
{{ render_field(form.nsfl) }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col post_language_chooser">
|
|
||||||
{{ render_field(form.language_id) }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{ render_field(form.submit) }}
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<aside id="side_pane" class="col-12 col-md-4 side_pane" role="complementary">
|
|
||||||
<div class="card mt-3">
|
|
||||||
<div class="card-header">
|
|
||||||
<h2>{{ post.community.title }}</h2>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<p>{{ post.community.description_html|safe if post.community.description_html else '' }}</p>
|
|
||||||
<p>{{ post.community.rules_html|safe if post.community.rules_html else '' }}</p>
|
|
||||||
{% if len(mods) > 0 and not post.community.private_mods %}
|
|
||||||
<h3>Moderators</h3>
|
|
||||||
<ul class="moderator_list">
|
|
||||||
{% for mod in mods %}
|
|
||||||
<li><a href="/u/{{ mod.link() }}">{{ mod.display_name() }}</a></li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% include "_inoculation_links.html" %}
|
|
||||||
</aside>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
|
@ -1,113 +0,0 @@
|
||||||
{% 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 %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12 col-md-8 position-relative main_pane">
|
|
||||||
<h1>{{ _('Edit post') }}</h1>
|
|
||||||
<form method="post" role="form">
|
|
||||||
{{ form.csrf_token() }}
|
|
||||||
{{ render_field(form.poll_title) }}
|
|
||||||
{{ render_field(form.poll_body) }}
|
|
||||||
{% if markdown_editor %}
|
|
||||||
<script nonce="{{ session['nonce'] }}">
|
|
||||||
window.addEventListener("load", function () {
|
|
||||||
var downarea = new DownArea({
|
|
||||||
elem: document.querySelector('#discussion_body'),
|
|
||||||
resize: DownArea.RESIZE_VERTICAL,
|
|
||||||
hide: ['heading', 'bold-italic'],
|
|
||||||
value: {{ form.discussion_body.data | tojson | safe }},
|
|
||||||
});
|
|
||||||
setupAutoResize('discussion_body');
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
<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) }}
|
|
||||||
{{ render_field(form.local_only) }}
|
|
||||||
{{ render_field(form.tags) }}
|
|
||||||
<small class="field_hint">{{ _('Separate each tag with a comma.') }}</small>
|
|
||||||
|
|
||||||
<div class="row mt-4">
|
|
||||||
<div class="col-md-3">
|
|
||||||
{{ render_field(form.notify_author) }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-1">
|
|
||||||
{{ render_field(form.sticky) }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-1">
|
|
||||||
{{ render_field(form.nsfw) }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-1">
|
|
||||||
{{ render_field(form.nsfl) }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col post_language_chooser">
|
|
||||||
{{ render_field(form.language_id) }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{ render_field(form.submit) }}
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<aside id="side_pane" class="col-12 col-md-4 side_pane" role="complementary">
|
|
||||||
<div class="card mt-3">
|
|
||||||
<div class="card-header">
|
|
||||||
<h2>{{ post.community.title }}</h2>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<p>{{ post.community.description_html|safe if post.community.description_html else '' }}</p>
|
|
||||||
<p>{{ post.community.rules_html|safe if post.community.rules_html else '' }}</p>
|
|
||||||
{% if len(mods) > 0 and not post.community.private_mods %}
|
|
||||||
<h3>Moderators</h3>
|
|
||||||
<ul class="moderator_list">
|
|
||||||
{% for mod in mods %}
|
|
||||||
<li><a href="/u/{{ mod.link() }}">{{ mod.display_name() }}</a></li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% include "_inoculation_links.html" %}
|
|
||||||
</aside>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
|
@ -1,77 +0,0 @@
|
||||||
{% 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 %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12 col-md-8 position-relative main_pane">
|
|
||||||
<h1>{{ _('Edit post') }}</h1>
|
|
||||||
<form method="post" enctype="multipart/form-data" role="form">
|
|
||||||
{{ form.csrf_token() }}
|
|
||||||
{{ render_field(form.video_title) }}
|
|
||||||
{{ render_field(form.video_url) }}
|
|
||||||
{{ render_field(form.video_body) }}
|
|
||||||
{% if markdown_editor %}
|
|
||||||
<script nonce="{{ session['nonce'] }}">
|
|
||||||
window.addEventListener("load", function () {
|
|
||||||
var downarea = new DownArea({
|
|
||||||
elem: document.querySelector('#video_body'),
|
|
||||||
resize: DownArea.RESIZE_VERTICAL,
|
|
||||||
hide: ['heading', 'bold-italic'],
|
|
||||||
value: {{ form.link_body.data | tojson | safe }},
|
|
||||||
});
|
|
||||||
setupAutoResize('video_body');
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
{{ render_field(form.tags) }}
|
|
||||||
<small class="field_hint">{{ _('Separate each tag with a comma.') }}</small>
|
|
||||||
<div class="row mt-4">
|
|
||||||
<div class="col-md-3">
|
|
||||||
{{ render_field(form.notify_author) }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-1">
|
|
||||||
{{ render_field(form.sticky) }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-1">
|
|
||||||
{{ render_field(form.nsfw) }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-1">
|
|
||||||
{{ render_field(form.nsfl) }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col post_language_chooser">
|
|
||||||
{{ render_field(form.language_id) }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{ render_field(form.submit) }}
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<aside id="side_pane" class="col-12 col-md-4 side_pane" role="complementary">
|
|
||||||
<div class="card mt-3">
|
|
||||||
<div class="card-header">
|
|
||||||
<h2>{{ post.community.title }}</h2>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<p>{{ post.community.description_html|safe if post.community.description_html else '' }}</p>
|
|
||||||
<p>{{ post.community.rules_html|safe if post.community.rules_html else '' }}</p>
|
|
||||||
{% if len(mods) > 0 and not post.community.private_mods %}
|
|
||||||
<h3>Moderators</h3>
|
|
||||||
<ul class="moderator_list">
|
|
||||||
{% for mod in mods %}
|
|
||||||
<li><a href="/u/{{ mod.link() }}">{{ mod.display_name() }}</a></li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% include "_inoculation_links.html" %}
|
|
||||||
</aside>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
|
@ -8,7 +8,7 @@ from flask_login import current_user
|
||||||
from app import create_app, db, cli
|
from app import create_app, db, cli
|
||||||
import os, click
|
import os, click
|
||||||
from flask import session, g, json, request, current_app
|
from flask import session, g, json, request, current_app
|
||||||
from app.constants import POST_TYPE_LINK, POST_TYPE_IMAGE, POST_TYPE_ARTICLE, POST_TYPE_VIDEO
|
from app.constants import POST_TYPE_LINK, POST_TYPE_IMAGE, POST_TYPE_ARTICLE, POST_TYPE_VIDEO, POST_TYPE_POLL
|
||||||
from app.models import Site
|
from app.models import Site
|
||||||
from app.utils import getmtime, gibberish, shorten_string, shorten_url, digits, user_access, community_membership, \
|
from app.utils import getmtime, gibberish, shorten_string, shorten_url, digits, user_access, community_membership, \
|
||||||
can_create_post, can_upvote, can_downvote, shorten_number, ap_datetime, current_theme, community_link_to_href, \
|
can_create_post, can_upvote, can_downvote, shorten_number, ap_datetime, current_theme, community_link_to_href, \
|
||||||
|
@ -22,8 +22,8 @@ cli.register(app)
|
||||||
def app_context_processor():
|
def app_context_processor():
|
||||||
def getmtime(filename):
|
def getmtime(filename):
|
||||||
return os.path.getmtime('app/static/' + filename)
|
return os.path.getmtime('app/static/' + filename)
|
||||||
return dict(getmtime=getmtime, post_type_link=POST_TYPE_LINK, post_type_image=POST_TYPE_IMAGE,
|
return dict(getmtime=getmtime, POST_TYPE_LINK=POST_TYPE_LINK, POST_TYPE_IMAGE=POST_TYPE_IMAGE,
|
||||||
post_type_article=POST_TYPE_ARTICLE, post_type_video=POST_TYPE_VIDEO)
|
POST_TYPE_ARTICLE=POST_TYPE_ARTICLE, POST_TYPE_VIDEO=POST_TYPE_VIDEO, POST_TYPE_POLL=POST_TYPE_POLL)
|
||||||
|
|
||||||
|
|
||||||
@app.shell_context_processor
|
@app.shell_context_processor
|
||||||
|
|
Loading…
Reference in a new issue