From 63049942ee4d70af823416b125fb862f7262f221 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Fri, 12 Jul 2024 19:56:57 +0800 Subject: [PATCH] Make 'rational discourse toolkit' optional fixes #202 --- app/admin/forms.py | 1 + app/admin/routes.py | 2 ++ app/community/routes.py | 13 +++++++------ app/domain/routes.py | 2 +- app/main/routes.py | 5 +++-- app/post/routes.py | 10 +++++----- app/tag/routes.py | 2 +- app/topic/routes.py | 2 +- docs/ARCHITECTURE.md | 40 ++++++++++++++++++++++++++++++++++++++++ 9 files changed, 61 insertions(+), 16 deletions(-) create mode 100644 docs/ARCHITECTURE.md diff --git a/app/admin/forms.py b/app/admin/forms.py index 1d61d6e1..003c3073 100644 --- a/app/admin/forms.py +++ b/app/admin/forms.py @@ -39,6 +39,7 @@ class SiteMiscForm(FlaskForm): default_theme = SelectField(_l('Default theme'), coerce=str, render_kw={'class': 'form-select'}) log_activitypub_json = BooleanField(_l('Log ActivityPub JSON for debugging')) public_modlog = BooleanField(_l('Show moderation actions publicly')) + show_inoculation_block = BooleanField(_l('Show Rational Discourse Toolkit in sidebar')) submit = SubmitField(_l('Save')) diff --git a/app/admin/routes.py b/app/admin/routes.py index 10326158..d11aaa42 100644 --- a/app/admin/routes.py +++ b/app/admin/routes.py @@ -149,6 +149,7 @@ def admin_misc(): site.application_question = form.application_question.data site.auto_decline_referrers = form.auto_decline_referrers.data site.log_activitypub_json = form.log_activitypub_json.data + site.show_inoculation_block = form.show_inoculation_block.data site.updated = utcnow() site.default_theme = form.default_theme.data if site.id is None: @@ -169,6 +170,7 @@ def admin_misc(): form.application_question.data = site.application_question form.auto_decline_referrers.data = site.auto_decline_referrers form.log_activitypub_json.data = site.log_activitypub_json + form.show_inoculation_block.data = site.show_inoculation_block form.default_theme.data = site.default_theme if site.default_theme is not None else '' form.public_modlog.data = get_setting('public_modlog', False) return render_template('admin/misc.html', title=_('Misc settings'), form=form, diff --git a/app/community/routes.py b/app/community/routes.py index fee12d5b..e9e944b9 100644 --- a/app/community/routes.py +++ b/app/community/routes.py @@ -303,7 +303,8 @@ def show_community(community: Community): content_filters=content_filters, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), menu_topics=menu_topics(), site=g.site, sort=sort, - inoculation=inoculation[randint(0, len(inoculation) - 1)], post_layout=post_layout, current_app=current_app) + inoculation=inoculation[randint(0, len(inoculation) - 1)] if g.site.show_inoculation_block else None, + post_layout=post_layout, current_app=current_app) # RSS feed of the community @@ -602,7 +603,7 @@ def add_post(actor, type): moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.id), menu_topics=menu_topics(), site=g.site, - inoculation=inoculation[randint(0, len(inoculation) - 1)] + inoculation=inoculation[randint(0, len(inoculation) - 1)] if g.site.show_inoculation_block else None ) @@ -1159,7 +1160,7 @@ def community_ban_user(community_id: int, user_id: int): moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), menu_topics=menu_topics(), site=g.site, - inoculation=inoculation[randint(0, len(inoculation) - 1)] + inoculation=inoculation[randint(0, len(inoculation) - 1)] if g.site.show_inoculation_block else None ) @@ -1266,7 +1267,7 @@ def community_moderate(actor): moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), menu_topics=menu_topics(), site=g.site, - inoculation=inoculation[randint(0, len(inoculation) - 1)] + inoculation=inoculation[randint(0, len(inoculation) - 1)] if g.site.show_inoculation_block else None ) else: abort(401) @@ -1301,7 +1302,7 @@ def community_moderate_subscribers(actor): moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), menu_topics=menu_topics(), site=g.site, - inoculation=inoculation[randint(0, len(inoculation) - 1)] + inoculation=inoculation[randint(0, len(inoculation) - 1)] if g.site.show_inoculation_block else None ) else: abort(401) @@ -1336,7 +1337,7 @@ def community_modlog(actor): moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), menu_topics=menu_topics(), site=g.site, - inoculation=inoculation[randint(0, len(inoculation) - 1)] + inoculation=inoculation[randint(0, len(inoculation) - 1)] if g.site.show_inoculation_block else None ) else: diff --git a/app/domain/routes.py b/app/domain/routes.py index b031adb0..cd5adade 100644 --- a/app/domain/routes.py +++ b/app/domain/routes.py @@ -50,7 +50,7 @@ def show_domain(domain_id): moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), menu_topics=menu_topics(), site=g.site, - inoculation=inoculation[randint(0, len(inoculation) - 1)] + inoculation=inoculation[randint(0, len(inoculation) - 1)] if g.site.show_inoculation_block else None ) else: abort(404) diff --git a/app/main/routes.py b/app/main/routes.py index f0e48b42..f46c4e1e 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -182,7 +182,8 @@ def home_page(type, sort): moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), menu_topics=menu_topics(), site=g.site, - inoculation=inoculation[randint(0, len(inoculation) - 1)]) + inoculation=inoculation[randint(0, len(inoculation) - 1)] if g.site.show_inoculation_block else None + ) @bp.route('/topics', methods=['GET']) @@ -378,7 +379,7 @@ def modlog(): moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), menu_topics=menu_topics(), site=g.site, - inoculation=inoculation[randint(0, len(inoculation) - 1)] + inoculation=inoculation[randint(0, len(inoculation) - 1)] if g.site.show_inoculation_block else None ) diff --git a/app/post/routes.py b/app/post/routes.py index e87433d7..10c5160b 100644 --- a/app/post/routes.py +++ b/app/post/routes.py @@ -328,7 +328,7 @@ def show_post(post_id: int): moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), menu_topics=menu_topics(), site=g.site, - inoculation=inoculation[randint(0, len(inoculation) - 1)] + inoculation=inoculation[randint(0, len(inoculation) - 1)] if g.site.show_inoculation_block else None ) response.headers.set('Vary', 'Accept, Cookie, Accept-Language') return response @@ -643,7 +643,7 @@ def continue_discussion(post_id, comment_id): menu_topics=menu_topics(), site=g.site, community=post.community, SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR, - inoculation=inoculation[randint(0, len(inoculation) - 1)]) + inoculation=inoculation[randint(0, len(inoculation) - 1)] if g.site.show_inoculation_block else None) response.headers.set('Vary', 'Accept, Cookie, Accept-Language') return response @@ -850,7 +850,7 @@ def add_reply(post_id: int, comment_id: int): moderating_communities=moderating_communities(current_user.get_id()), mods=mod_list, joined_communities = joined_communities(current_user.id), community=post.community, SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR, - inoculation=inoculation[randint(0, len(inoculation) - 1)]) + inoculation=inoculation[randint(0, len(inoculation) - 1)] if g.site.show_inoculation_block else None) @bp.route('/post//options', methods=['GET']) @@ -1001,7 +1001,7 @@ def post_edit(post_id: int): moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), menu_topics=menu_topics(), site=g.site, - inoculation=inoculation[randint(0, len(inoculation) - 1)] + inoculation=inoculation[randint(0, len(inoculation) - 1)] if g.site.show_inoculation_block else None ) else: abort(401) @@ -1750,7 +1750,7 @@ def post_reply_edit(post_id: int, comment_id: int): joined_communities=joined_communities(current_user.get_id()), menu_topics=menu_topics(), community=post.community, site=g.site, SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR, - inoculation=inoculation[randint(0, len(inoculation) - 1)]) + inoculation=inoculation[randint(0, len(inoculation) - 1)] if g.site.show_inoculation_block else None) else: abort(401) diff --git a/app/tag/routes.py b/app/tag/routes.py index 144af064..c3b1a57e 100644 --- a/app/tag/routes.py +++ b/app/tag/routes.py @@ -61,7 +61,7 @@ def show_tag(tag): moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), menu_topics=menu_topics(), - inoculation=inoculation[randint(0, len(inoculation) - 1)] + inoculation=inoculation[randint(0, len(inoculation) - 1)] if g.site.show_inoculation_block else None ) else: abort(404) diff --git a/app/topic/routes.py b/app/topic/routes.py index 5bd2ab51..fab41a44 100644 --- a/app/topic/routes.py +++ b/app/topic/routes.py @@ -120,7 +120,7 @@ def show_topic(topic_path): show_post_community=True, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), menu_topics=menu_topics(), - inoculation=inoculation[randint(0, len(inoculation) - 1)], + inoculation=inoculation[randint(0, len(inoculation) - 1)] if g.site.show_inoculation_block else None, POST_TYPE_LINK=POST_TYPE_LINK, POST_TYPE_IMAGE=POST_TYPE_IMAGE, POST_TYPE_VIDEO=POST_TYPE_VIDEO, SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR, diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md new file mode 100644 index 00000000..ca6817d8 --- /dev/null +++ b/docs/ARCHITECTURE.md @@ -0,0 +1,40 @@ +# PieFed software architecture + +This document is a work in progress. + +## Stakeholders + +Instance admins + +Moderators of communities + +Posters of content + +Lurkers + +Software developers + +## Desired quality attributes + +These attributes have been given a score out of 5 to indicate their importance. + +- Performance 4/5 +- Scalability 2/5 +- Agility 5/5 +- Reliability 1/5 +- Security 2/5 +- Testability 0/5 +- Modifiability 5/5 +- Affordability 5/5 +- Manageability 5/5 + +## Constraints + +FOSS, browser-based, run on a Linux server. + +## Architecturally significant requirements + +## Patterns used, diagrams + +## Risks, open questions, future work +