From 5b66fea4fe2fca23c826f41958401a67623c5521 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Sat, 27 Jan 2024 11:19:23 +1300 Subject: [PATCH] local only communities --- app/community/forms.py | 1 + app/community/routes.py | 6 +++--- app/templates/community/add_local.html | 2 ++ app/templates/community/community.html | 3 +++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/community/forms.py b/app/community/forms.py index f3b7f8e3..b00a78fe 100644 --- a/app/community/forms.py +++ b/app/community/forms.py @@ -20,6 +20,7 @@ class AddLocalCommunity(FlaskForm): banner_file = FileField(_('Banner image')) rules = TextAreaField(_l('Rules')) nsfw = BooleanField('NSFW') + local_only = BooleanField('Local only') submit = SubmitField(_l('Create')) def validate(self, extra_validators=None): diff --git a/app/community/routes.py b/app/community/routes.py index b5cf1d88..a6ee643a 100644 --- a/app/community/routes.py +++ b/app/community/routes.py @@ -43,7 +43,7 @@ def add_local(): community = Community(title=form.community_name.data, name=form.url.data, description=form.description.data, rules=form.rules.data, nsfw=form.nsfw.data, private_key=private_key, public_key=public_key, description_html=markdown_to_html(form.description.data), - rules_html=markdown_to_html(form.rules.data), + rules_html=markdown_to_html(form.rules.data), local_only=form.local_only.data, ap_profile_id='https://' + current_app.config['SERVER_NAME'] + '/c/' + form.url.data, ap_followers_url='https://' + current_app.config['SERVER_NAME'] + '/c/' + form.url.data + '/followers', subscriptions_count=1, instance_id=1, low_quality='memes' in form.url.data) @@ -70,7 +70,7 @@ def add_local(): return redirect('/c/' + community.name) return render_template('community/add_local.html', title=_('Create community'), form=form, moderating_communities=moderating_communities(current_user.get_id()), - joined_communities=joined_communities(current_user.get_id())) + joined_communities=joined_communities(current_user.get_id()), current_app=current_app) @bp.route('/add_remote', methods=['GET', 'POST']) @@ -176,7 +176,7 @@ def show_community(community: Community): rss_feed=f"https://{current_app.config['SERVER_NAME']}/community/{community.link()}/feed", rss_feed_name=f"{community.title} posts on PieFed", content_filters=content_filters, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), sort=sort, - inoculation=inoculation[randint(0, len(inoculation) - 1)], post_layout=post_layout) + inoculation=inoculation[randint(0, len(inoculation) - 1)], post_layout=post_layout, current_app=current_app) # RSS feed of the community diff --git a/app/templates/community/add_local.html b/app/templates/community/add_local.html index be1a703c..eafbc744 100644 --- a/app/templates/community/add_local.html +++ b/app/templates/community/add_local.html @@ -23,6 +23,8 @@ Provide a wide image - letterbox orientation. {{ render_field(form.rules) }} {{ render_field(form.nsfw) }} + {{ render_field(form.local_only) }} + {{ _('Only people using %(name)s can post or reply', name=current_app.config['SERVER_NAME']) }}. {{ render_field(form.submit) }} diff --git a/app/templates/community/community.html b/app/templates/community/community.html index 238e26d4..c2743af9 100644 --- a/app/templates/community/community.html +++ b/app/templates/community/community.html @@ -138,6 +138,9 @@ View community on original server

{% endif %} + {% if community.local_only %} +

{{ _('Only people on %(instance_name)s can post or reply in this community.', instance_name=current_app.config['SERVER_NAME']) }}

+ {% endif %}

RSS feed