mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-02 16:21:32 -08:00
rational discourse toolbox
This commit is contained in:
parent
28db316e77
commit
c3e16ab171
15 changed files with 228 additions and 9 deletions
|
@ -1,3 +1,5 @@
|
|||
from random import randint
|
||||
|
||||
from flask import redirect, url_for, flash, request, make_response, session, Markup, current_app, abort, g, json
|
||||
from flask_login import current_user, login_required
|
||||
from flask_babel import _
|
||||
|
@ -12,6 +14,7 @@ from app.community.util import search_for_community, community_url_exists, actor
|
|||
opengraph_parse, url_to_thumbnail_file, save_post, save_icon_file, save_banner_file, send_to_remote_instance
|
||||
from app.constants import SUBSCRIPTION_MEMBER, SUBSCRIPTION_OWNER, POST_TYPE_LINK, POST_TYPE_ARTICLE, POST_TYPE_IMAGE, \
|
||||
SUBSCRIPTION_PENDING, SUBSCRIPTION_MODERATOR
|
||||
from app.inoculation import inoculation
|
||||
from app.models import User, Community, CommunityMember, CommunityJoinRequest, CommunityBan, Post, \
|
||||
File, PostVote, utcnow, Report, Notification, InstanceBlock, ActivityPubLog
|
||||
from app.community import bp
|
||||
|
@ -159,7 +162,8 @@ def show_community(community: Community):
|
|||
next_url=next_url, prev_url=prev_url, low_bandwidth=request.cookies.get('low_bandwidth', '0') == '1',
|
||||
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)
|
||||
joined_communities=joined_communities(current_user.get_id()), sort=sort,
|
||||
inoculation=inoculation[randint(0, len(inoculation) - 1)])
|
||||
|
||||
|
||||
# RSS feed of the community
|
||||
|
@ -448,8 +452,9 @@ def add_post(actor):
|
|||
|
||||
return render_template('community/add_post.html', title=_('Add post to community'), form=form, community=community,
|
||||
images_disabled=images_disabled, markdown_editor=True, low_bandwidth=request.cookies.get('low_bandwidth', '0') == '1',
|
||||
moderating_communities=moderating_communities(current_user.get_id()),
|
||||
joined_communities = joined_communities(current_user.id)
|
||||
moderating_communities=moderating_communities(current_user.get_id()),
|
||||
joined_communities = joined_communities(current_user.id,
|
||||
inoculation=inoculation[randint(0, len(inoculation) - 1)])
|
||||
)
|
||||
|
||||
|
||||
|
|
167
app/inoculation.py
Normal file
167
app/inoculation.py
Normal file
|
@ -0,0 +1,167 @@
|
|||
inoculation = [
|
||||
{
|
||||
'id': 'anti-cult',
|
||||
'title': 'Cults',
|
||||
'description': '',
|
||||
'links': [
|
||||
{
|
||||
'title': 'What is groupthink?',
|
||||
'href': 'https://rationalwiki.org/wiki/Groupthink'
|
||||
},
|
||||
{
|
||||
'title': 'Cult recovery resources',
|
||||
'href': 'https://culteducation.com/directory-of-cult-recovery-resources.html'
|
||||
},
|
||||
{
|
||||
'title': 'Leaving and Recovering from Cultic Groups',
|
||||
'href': 'https://www.youtube.com/watch?v=UzFjuqJ6Ngk'
|
||||
},
|
||||
{
|
||||
'title': 'Cult recovery resources',
|
||||
'href': 'https://culteducation.com/directory-of-cult-recovery-resources.html'
|
||||
},
|
||||
{
|
||||
'title': 'The dark side of upvotes',
|
||||
'href': 'https://gnet-research.org/2020/11/25/upvoting-extremism-collective-identity-formation-and-the-extreme-right-on-reddit/'
|
||||
},
|
||||
{
|
||||
'title': 'Signs of high-control groups',
|
||||
'href': 'https://secularliturgies.wordpress.com/2020/02/24/the-25-signs-youre-in-a-high-control-group-or-cult-by-anastasia-somerville-wong/'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'id': 'alt-right-pipeline',
|
||||
'title': 'Alt-right pipeline',
|
||||
'description': '',
|
||||
'links': [
|
||||
{
|
||||
'title': 'How to Radicalize a Normie',
|
||||
'href': 'https://www.youtube.com/watch?v=P55t6eryY3g'
|
||||
},
|
||||
{
|
||||
'title': 'How Fascism Works',
|
||||
'href': 'https://www.youtube.com/watch?v=CpCKkWMbmXU'
|
||||
},
|
||||
{
|
||||
'title': 'The brainwashing of my dad',
|
||||
'href': 'https://www.youtube.com/watch?v=pNTsTOcRO-k'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
'id': 'media-literacy',
|
||||
'title': 'Media literacy',
|
||||
'description': '',
|
||||
'links': [
|
||||
{
|
||||
'title': 'Media Literacy series',
|
||||
'href': 'https://www.youtube.com/watch?v=oXf0F4GYzWQ&list=PL8dPuuaLjXtM6jSpzb5gMNsx9kdmqBfmY&index=4'
|
||||
},
|
||||
{
|
||||
'title': 'News Literacy Project: be a smart, active consumer of information',
|
||||
'href': 'https://newslit.org/for-everyone/'
|
||||
},
|
||||
{
|
||||
'title': 'Framing',
|
||||
'href': 'https://rationalwiki.org/wiki/Framing'
|
||||
},
|
||||
{
|
||||
'title': 'Media bias',
|
||||
'href': 'https://rationalwiki.org/wiki/Media#Media_bias'
|
||||
},
|
||||
{
|
||||
'title': 'Confirmation bias',
|
||||
'href': 'https://rationalwiki.org/wiki/Confirmation_bias'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
'id': 'deradicalisation',
|
||||
'title': 'Deredicalisation',
|
||||
'description': '',
|
||||
'links': [
|
||||
{
|
||||
'title': 'Getting out of QAnon',
|
||||
'href': 'https://www.dailykos.com/stories/2020/10/18/1987473/-QAnon-is-a-Nazi-Cult-Helping-Friends-Get-Out'
|
||||
},
|
||||
{
|
||||
'title': 'Life After Hate',
|
||||
'href': 'https://www.lifeafterhate.org/'
|
||||
},
|
||||
{
|
||||
'title': 'QAnon Casualties wiki',
|
||||
'href': 'https://www.reddit.com/r/QAnonCasualties/wiki/resources/'
|
||||
},
|
||||
{
|
||||
'title': 'Escaping the rabbit hole',
|
||||
'href': 'https://skepticalinquirer.org/2019/01/a-skeptical-guide-through-the-conspiracy-rabbit-hole/'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
'id': 'cognitive-biases',
|
||||
'title': 'Cognitive biases',
|
||||
'description': '',
|
||||
'links': [
|
||||
{
|
||||
'title': 'List of cognitive biases',
|
||||
'href': 'https://rationalwiki.org/wiki/List_of_cognitive_biases'
|
||||
},
|
||||
{
|
||||
'title': 'Logical fallacies',
|
||||
'href': 'https://rationalwiki.org/wiki/Logical_fallacy'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
'id': 'fact-check',
|
||||
'title': 'How to fact-check',
|
||||
'description': '',
|
||||
'links': [
|
||||
{
|
||||
'title': 'https://utopia.ut.edu/FakeNews/factcheck',
|
||||
'href': 'https://utopia.ut.edu/FakeNews/factcheck'
|
||||
},
|
||||
{
|
||||
'title': 'https://toolbox.google.com/factcheck/explorer',
|
||||
'href': 'https://toolbox.google.com/factcheck/explorer'
|
||||
},
|
||||
{
|
||||
'title': 'https://www.factcheck.org/',
|
||||
'href': 'https://www.factcheck.org/'
|
||||
},
|
||||
{
|
||||
'title': 'https://newslit.org/educators/resources/is-it-legit/',
|
||||
'href': 'https://newslit.org/educators/resources/is-it-legit/'
|
||||
},
|
||||
{
|
||||
'title': 'Spot fake news',
|
||||
'href': 'https://www.searchenginejournal.com/fake-news-vs-real-news/459719/'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
'id': 'misinformation',
|
||||
'title': 'Misinformation & disinformation',
|
||||
'description': '',
|
||||
'links': [
|
||||
{
|
||||
'title': 'Covid-19 misinfo',
|
||||
'href': 'https://namle.net/slowing-the-infodemic-how-to-spot-covid-19-misinformation/'
|
||||
},
|
||||
{
|
||||
'title': 'Conspiracy theory handbook',
|
||||
'href': 'https://skepticalscience.com/docs/ConspiracyTheoryHandbook.pdf'
|
||||
},
|
||||
{
|
||||
'title': 'Psychology of conspiracy beliefs',
|
||||
'href': 'https://conspiracypsychology.com/'
|
||||
},
|
||||
{
|
||||
'title': 'Firehose of falsehood',
|
||||
'href': 'https://en.wikipedia.org/wiki/Firehose_of_falsehood'
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
|
@ -1,5 +1,6 @@
|
|||
from datetime import datetime, timedelta
|
||||
from math import log
|
||||
from random import randint
|
||||
|
||||
from sqlalchemy.sql.operators import or_
|
||||
|
||||
|
@ -7,6 +8,7 @@ from app import db, cache
|
|||
from app.activitypub.util import default_context, make_image_sizes_async, refresh_user_profile
|
||||
from app.constants import SUBSCRIPTION_PENDING, SUBSCRIPTION_MEMBER, POST_TYPE_IMAGE, POST_TYPE_LINK, \
|
||||
SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR
|
||||
from app.inoculation import inoculation
|
||||
from app.main import bp
|
||||
from flask import g, session, flash, request, current_app, url_for, redirect, make_response, jsonify
|
||||
from flask_moment import moment
|
||||
|
@ -123,7 +125,8 @@ def home_page(type, sort):
|
|||
description=shorten_string(markdown_to_text(g.site.sidebar), 150),
|
||||
content_filters=content_filters, type=type, sort=sort,
|
||||
moderating_communities=moderating_communities(current_user.get_id()),
|
||||
joined_communities=joined_communities(current_user.get_id()))
|
||||
joined_communities=joined_communities(current_user.get_id()),
|
||||
inoculation=inoculation[randint(0, len(inoculation) - 1)])
|
||||
|
||||
|
||||
@bp.route('/topics', methods=['GET'])
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from datetime import datetime
|
||||
from random import randint
|
||||
|
||||
from flask import redirect, url_for, flash, current_app, abort, request, g, make_response
|
||||
from flask_login import login_user, logout_user, current_user, login_required
|
||||
|
@ -9,6 +10,7 @@ from app import db, constants
|
|||
from app.activitypub.signature import HttpSignature, post_request
|
||||
from app.activitypub.util import default_context
|
||||
from app.community.util import save_post, send_to_remote_instance
|
||||
from app.inoculation import inoculation
|
||||
from app.post.forms import NewReplyForm, ReportPostForm, MeaCulpaForm
|
||||
from app.community.forms import CreatePostForm
|
||||
from app.post.util import post_replies, get_comment_branch, post_reply_count
|
||||
|
@ -174,7 +176,8 @@ def show_post(post_id: int):
|
|||
etag=f"{post.id}{sort}_{hash(post.last_active)}", markdown_editor=True,
|
||||
low_bandwidth=request.cookies.get('low_bandwidth', '0') == '1', SUBSCRIPTION_MEMBER=SUBSCRIPTION_MEMBER,
|
||||
moderating_communities=moderating_communities(current_user.get_id()),
|
||||
joined_communities=joined_communities(current_user.get_id())
|
||||
joined_communities=joined_communities(current_user.get_id()),
|
||||
inoculation=inoculation[randint(0, len(inoculation) - 1)]
|
||||
)
|
||||
|
||||
|
||||
|
@ -360,7 +363,8 @@ def continue_discussion(post_id, comment_id):
|
|||
|
||||
return render_template('post/continue_discussion.html', title=_('Discussing %(title)s', title=post.title), post=post,
|
||||
is_moderator=is_moderator, comment=comment, replies=replies, markdown_editor=True, moderating_communities=moderating_communities(current_user.get_id()),
|
||||
joined_communities=joined_communities(current_user.get_id()), community=post.community)
|
||||
joined_communities=joined_communities(current_user.get_id()), community=post.community,
|
||||
inoculation=inoculation[randint(0, len(inoculation) - 1)])
|
||||
|
||||
|
||||
@bp.route('/post/<int:post_id>/comment/<int:comment_id>/reply', methods=['GET', 'POST'])
|
||||
|
@ -518,7 +522,8 @@ def add_reply(post_id: int, comment_id: int):
|
|||
return render_template('post/add_reply.html', title=_('Discussing %(title)s', title=post.title), post=post,
|
||||
is_moderator=is_moderator, form=form, comment=in_reply_to, markdown_editor=True,
|
||||
moderating_communities=moderating_communities(current_user.get_id()),
|
||||
joined_communities = joined_communities(current_user.id))
|
||||
joined_communities = joined_communities(current_user.id),
|
||||
inoculation=inoculation[randint(0, len(inoculation) - 1)])
|
||||
|
||||
|
||||
@bp.route('/post/<int:post_id>/options', methods=['GET'])
|
||||
|
@ -654,7 +659,8 @@ def post_edit(post_id: int):
|
|||
return render_template('post/post_edit.html', title=_('Edit post'), form=form, post=post,
|
||||
images_disabled=images_disabled, markdown_editor=True,
|
||||
moderating_communities=moderating_communities(current_user.get_id()),
|
||||
joined_communities=joined_communities(current_user.get_id())
|
||||
joined_communities=joined_communities(current_user.get_id()),
|
||||
inoculation=inoculation[randint(0, len(inoculation) - 1)]
|
||||
)
|
||||
else:
|
||||
abort(401)
|
||||
|
@ -983,7 +989,8 @@ def post_reply_edit(post_id: int, comment_id: int):
|
|||
form.notify_author.data = post_reply.notify_author
|
||||
return render_template('post/post_reply_edit.html', title=_('Edit comment'), form=form, post=post, post_reply=post_reply,
|
||||
comment=comment, markdown_editor=True, moderating_communities=moderating_communities(current_user.get_id()),
|
||||
joined_communities=joined_communities(current_user.get_id()))
|
||||
joined_communities=joined_communities(current_user.get_id()),
|
||||
inoculation=inoculation[randint(0, len(inoculation) - 1)])
|
||||
else:
|
||||
abort(401)
|
||||
|
||||
|
|
|
@ -953,4 +953,8 @@ fieldset legend {
|
|||
font-style: italic;
|
||||
}
|
||||
|
||||
.list-group-item:first-child {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
/*# sourceMappingURL=structure.css.map */
|
||||
|
|
|
@ -621,3 +621,7 @@ fieldset {
|
|||
font-style: italic;
|
||||
}
|
||||
}
|
||||
|
||||
.list-group-item:first-child {
|
||||
padding-top: 0;
|
||||
}
|
20
app/templates/_inoculation_links.html
Normal file
20
app/templates/_inoculation_links.html
Normal file
|
@ -0,0 +1,20 @@
|
|||
{% if inoculation %}
|
||||
<div class="card mt-3">
|
||||
<div class="card-header">
|
||||
<h2 title="These links aim to encourage mindful and informed discussions rooted in awareness, critical thinking, and the well-being of the community.">{{ _('Rational Discourse Toolkit') }}</h2>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h4>{{ inoculation['title'] }}</h4>
|
||||
{% if inoculation['description'] %}<p>{{ inoculation['description'] }}</p>{% endif %}
|
||||
{% if inoculation['links'] %}
|
||||
<ul class="list-group list-group-flush">
|
||||
{% for link in inoculation['links'] %}
|
||||
<li class="list-group-item">
|
||||
<a href="{{ link['href'] }}">{{ link['title'] }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
|
@ -118,6 +118,7 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% include "_inoculation_links.html" %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -166,6 +166,7 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% include "_inoculation_links.html" %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
|
|
@ -67,6 +67,8 @@
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include "_inoculation_links.html" %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -79,6 +79,7 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% include "_inoculation_links.html" %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -131,6 +131,7 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% include "_inoculation_links.html" %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -198,6 +198,7 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% include "_inoculation_links.html" %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -127,5 +127,6 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% include "_inoculation_links.html" %}
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -79,6 +79,7 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% include "_inoculation_links.html" %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue