From 841fd9ec43dfeaf61234a38358dd6dc51f5a2b8b Mon Sep 17 00:00:00 2001 From: Hendrik L Date: Mon, 8 Jul 2024 17:13:01 +0200 Subject: [PATCH] combine add_..._post templates into one add_post --- app/community/routes.py | 10 +- app/templates/community/add_image_post.html | 93 ------------- app/templates/community/add_link_post.html | 92 ------------- app/templates/community/add_poll_post.html | 128 ------------------ ...add_discussion_post.html => add_post.html} | 51 +++++++ app/templates/community/add_video_post.html | 93 ------------- 6 files changed, 56 insertions(+), 411 deletions(-) delete mode 100644 app/templates/community/add_image_post.html delete mode 100644 app/templates/community/add_link_post.html delete mode 100644 app/templates/community/add_poll_post.html rename app/templates/community/{add_discussion_post.html => add_post.html} (58%) delete mode 100644 app/templates/community/add_video_post.html diff --git a/app/community/routes.py b/app/community/routes.py index 0866da08..a46f8a1a 100644 --- a/app/community/routes.py +++ b/app/community/routes.py @@ -553,7 +553,7 @@ def add_discussion_post(actor): if community.posting_warning: flash(community.posting_warning) - return render_template('community/add_discussion_post.html', title=_('Add post to community'), form=form, community=community, + return render_template('community/add_post.html', title=_('Add post to community'), form=form, community=community, markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.id), @@ -633,7 +633,7 @@ def add_image_post(actor): form.communities.data = community.id form.notify_author.data = True - return render_template('community/add_image_post.html', title=_('Add post to community'), form=form, community=community, + return render_template('community/add_post.html', title=_('Add post to community'), form=form, community=community, markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.id), @@ -713,7 +713,7 @@ def add_link_post(actor): form.communities.data = community.id form.notify_author.data = True - return render_template('community/add_link_post.html', title=_('Add post to community'), form=form, community=community, + return render_template('community/add_post.html', title=_('Add post to community'), form=form, community=community, markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.id), @@ -793,7 +793,7 @@ def add_video_post(actor): form.communities.data = community.id form.notify_author.data = True - return render_template('community/add_video_post.html', title=_('Add post to community'), form=form, community=community, + return render_template('community/add_post.html', title=_('Add post to community'), form=form, community=community, markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.id), @@ -862,7 +862,7 @@ def add_poll_post(actor): if community.posting_warning: flash(community.posting_warning) - return render_template('community/add_poll_post.html', title=_('Add poll to community'), form=form, community=community, + return render_template('community/add_post.html', title=_('Add poll to community'), form=form, community=community, markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.id), diff --git a/app/templates/community/add_image_post.html b/app/templates/community/add_image_post.html deleted file mode 100644 index 2bb1d212..00000000 --- a/app/templates/community/add_image_post.html +++ /dev/null @@ -1,93 +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_field %} - -{% block app_content %} -
-
-

{{ _('Create post') }}

-
- {{ form.csrf_token() }} -
- - {% include 'community/_add_post_types.html' %} -
- {{ render_field(form.communities) }} - {{ render_field(form.title) }} - {{ render_field(form.image_file) }} - {{ render_field(form.image_alt_text) }} - {{ _('Describe the image, to help visually impaired people.') }} - {{ render_field(form.body) }} - {% if not low_bandwidth %} - {% if markdown_editor %} - - {% else %} - - {% endif %} - {% endif %} - {{ render_field(form.tags) }} - {{ _('Separate each tag with a comma.') }} - -
-
- {{ render_field(form.notify_author) }} -
-
- {{ render_field(form.sticky) }} -
-
- {{ render_field(form.nsfw) }} -
-
- {{ render_field(form.nsfl) }} -
-
- {{ render_field(form.language_id) }} -
-
- - {{ render_field(form.submit) }} -
-
- - -
-{% endblock %} diff --git a/app/templates/community/add_link_post.html b/app/templates/community/add_link_post.html deleted file mode 100644 index 67bd9c22..00000000 --- a/app/templates/community/add_link_post.html +++ /dev/null @@ -1,92 +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_field %} - -{% block app_content %} -
-
-

{{ _('Create post') }}

-
- {{ form.csrf_token() }} -
- - {% include 'community/_add_post_types.html' %} -
- {{ render_field(form.communities) }} - - {{ render_field(form.title) }} - {{ render_field(form.link_url) }} - {{ render_field(form.body) }} - {% if not low_bandwidth %} - {% if markdown_editor %} - - {% else %} - - {% endif %} - {% endif %} - {{ render_field(form.tags) }} - {{ _('Separate each tag with a comma.') }} - -
-
- {{ render_field(form.notify_author) }} -
-
- {{ render_field(form.sticky) }} -
-
- {{ render_field(form.nsfw) }} -
-
- {{ render_field(form.nsfl) }} -
-
- {{ render_field(form.language_id) }} -
-
- - {{ render_field(form.submit) }} -
-
- - -
-{% endblock %} diff --git a/app/templates/community/add_poll_post.html b/app/templates/community/add_poll_post.html deleted file mode 100644 index 6536314c..00000000 --- a/app/templates/community/add_poll_post.html +++ /dev/null @@ -1,128 +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_field %} - -{% block app_content %} -
-
-

{{ _('Create post') }}

-
- {{ form.csrf_token() }} -
- - {% include 'community/_add_post_types.html' %} -
- - {{ render_field(form.communities) }} - {{ render_field(form.title) }} - {{ render_field(form.body) }} - {% if not low_bandwidth %} - {% if markdown_editor %} - - {% else %} - - {% endif %} - {% endif %} -
- {{ _('Poll choices') }} -
- {{ form.choice_1(class_="form-control", **{"placeholder": "First choice"}) }} -
-
- {{ form.choice_2(class_="form-control", **{"placeholder": "Second choice"}) }} -
- - - - - - - - - -
- {{ render_field(form.mode) }} - {{ render_field(form.finish_in) }} - {{ render_field(form.local_only) }} - {{ render_field(form.tags) }} - {{ _('Separate each tag with a comma.') }} - -
-
- {{ render_field(form.notify_author) }} -
-
- {{ render_field(form.sticky) }} -
-
- {{ render_field(form.nsfw) }} -
-
- {{ render_field(form.nsfl) }} -
-
- {{ render_field(form.language_id) }} -
-
- - {{ render_field(form.submit) }} -
-
- - -
-{% endblock %} diff --git a/app/templates/community/add_discussion_post.html b/app/templates/community/add_post.html similarity index 58% rename from app/templates/community/add_discussion_post.html rename to app/templates/community/add_post.html index 8f2708a9..85376430 100644 --- a/app/templates/community/add_discussion_post.html +++ b/app/templates/community/add_post.html @@ -20,6 +20,16 @@ {{ render_field(form.communities) }} {{ 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) }} + {{ _('Describe the image, to help visually impaired people.') }} + {% elif post.type == POST_TYPE_VIDEO %} + {{ render_field(form.video_url) }} +

{{ _('Provide a URL ending with .mp4 or .webm.') }}

+ {% endif %} {{ render_field(form.body) }} {% if not low_bandwidth %} {% if markdown_editor %} @@ -37,6 +47,47 @@ {% endif %} {% endif %} + + {% if post.type == POST_TYPE_POLL %} +
+ {{ _('Poll choices') }} +
+ {{ form.choice_1(class_="form-control", **{"placeholder": "First choice"}) }} +
+
+ {{ form.choice_2(class_="form-control", **{"placeholder": "Second choice"}) }} +
+ + + + + + + + + +
+ {{ render_field(form.mode) }} + {{ render_field(form.finish_in) }} + {{ render_field(form.local_only) }} + {% endif %} + {{ render_field(form.tags) }} {{ _('Separate each tag with a comma.') }} diff --git a/app/templates/community/add_video_post.html b/app/templates/community/add_video_post.html deleted file mode 100644 index 23c899c8..00000000 --- a/app/templates/community/add_video_post.html +++ /dev/null @@ -1,93 +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_field %} - -{% block app_content %} -
-
-

{{ _('Create post') }}

-
- {{ form.csrf_token() }} -
- - {% include 'community/_add_post_types.html' %} -
- {{ render_field(form.communities) }} - - {{ render_field(form.title) }} - {{ render_field(form.video_url) }} -

{{ _('Provide a URL ending with .mp4 or .webm.') }}

- {{ render_field(form.body) }} - {% if not low_bandwidth %} - {% if markdown_editor %} - - {% else %} - - {% endif %} - {% endif %} - {{ render_field(form.tags) }} - {{ _('Separate each tag with a comma.') }} - -
-
- {{ render_field(form.notify_author) }} -
-
- {{ render_field(form.sticky) }} -
-
- {{ render_field(form.nsfw) }} -
-
- {{ render_field(form.nsfl) }} -
-
- {{ render_field(form.language_id) }} -
-
- - {{ render_field(form.submit) }} -
-
- - -
-{% endblock %}