add topics to main menu and reduce size of output html

This commit is contained in:
rimu 2024-05-30 21:54:25 +12:00
parent 92affc3064
commit a08e0ce6e7
20 changed files with 495 additions and 400 deletions

View file

@ -21,7 +21,7 @@ from app.models import AllowedInstances, BannedInstances, ActivityPubLog, utcnow
User, Instance, File, Report, Topic, UserRegistration, Role, Post, PostReply, Language User, Instance, File, Report, Topic, UserRegistration, Role, Post, PostReply, Language
from app.utils import render_template, permission_required, set_setting, get_setting, gibberish, markdown_to_html, \ from app.utils import render_template, permission_required, set_setting, get_setting, gibberish, markdown_to_html, \
moderating_communities, joined_communities, finalize_user_setup, theme_list, blocked_phrases, blocked_referrers, \ moderating_communities, joined_communities, finalize_user_setup, theme_list, blocked_phrases, blocked_referrers, \
topic_tree, languages_for_form topic_tree, languages_for_form, menu_topics
from app.admin import bp from app.admin import bp
@ -31,6 +31,7 @@ from app.admin import bp
def admin_home(): def admin_home():
return render_template('admin/home.html', title=_('Admin'), moderating_communities=moderating_communities(current_user.get_id()), return render_template('admin/home.html', title=_('Admin'), moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()),
menu_topics=menu_topics(),
site=g.site) site=g.site)
@ -64,6 +65,7 @@ def admin_site():
return render_template('admin/site.html', title=_('Site profile'), form=form, return render_template('admin/site.html', title=_('Site profile'), form=form,
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()),
menu_topics=menu_topics(),
site=g.site site=g.site
) )
@ -112,6 +114,7 @@ def admin_misc():
return render_template('admin/misc.html', title=_('Misc settings'), form=form, return render_template('admin/misc.html', title=_('Misc settings'), form=form,
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()),
menu_topics=menu_topics(),
site=g.site site=g.site
) )
@ -162,6 +165,7 @@ def admin_federation():
return render_template('admin/federation.html', title=_('Federation settings'), form=form, return render_template('admin/federation.html', title=_('Federation settings'), form=form,
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()),
menu_topics=menu_topics(),
site=g.site site=g.site
) )
@ -229,6 +233,7 @@ def admin_communities():
return render_template('admin/communities.html', title=_('Communities'), next_url=next_url, prev_url=prev_url, return render_template('admin/communities.html', title=_('Communities'), next_url=next_url, prev_url=prev_url,
communities=communities, moderating_communities=moderating_communities(current_user.get_id()), communities=communities, moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()),
menu_topics=menu_topics(),
site=g.site) site=g.site)
@ -251,6 +256,7 @@ def admin_communities_no_topic():
return render_template('admin/communities.html', title=_('Communities with no topic'), next_url=next_url, prev_url=prev_url, return render_template('admin/communities.html', title=_('Communities with no topic'), next_url=next_url, prev_url=prev_url,
communities=communities, moderating_communities=moderating_communities(current_user.get_id()), communities=communities, moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()),
menu_topics=menu_topics(),
site=g.site) site=g.site)
@ -338,6 +344,7 @@ def admin_community_edit(community_id):
return render_template('admin/edit_community.html', title=_('Edit community'), form=form, community=community, return render_template('admin/edit_community.html', title=_('Edit community'), form=form, community=community,
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()),
menu_topics=menu_topics(),
site=g.site site=g.site
) )
@ -391,6 +398,7 @@ def admin_topics():
return render_template('admin/topics.html', title=_('Topics'), topics=topics, return render_template('admin/topics.html', title=_('Topics'), topics=topics,
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()),
menu_topics=menu_topics(),
site=g.site site=g.site
) )
@ -416,6 +424,7 @@ def admin_topic_add():
return render_template('admin/edit_topic.html', title=_('Add topic'), form=form, return render_template('admin/edit_topic.html', title=_('Add topic'), form=form,
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()),
menu_topics=menu_topics(),
site=g.site site=g.site
) )
@ -444,6 +453,7 @@ def admin_topic_edit(topic_id):
return render_template('admin/edit_topic.html', title=_('Edit topic'), form=form, topic=topic, return render_template('admin/edit_topic.html', title=_('Edit topic'), form=form, topic=topic,
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()),
menu_topics=menu_topics(),
site=g.site site=g.site
) )
@ -489,6 +499,7 @@ def admin_users():
local_remote=local_remote, search=search, local_remote=local_remote, search=search,
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()),
menu_topics=menu_topics(),
site=g.site site=g.site
) )
@ -525,6 +536,7 @@ def admin_users_trash():
local_remote=local_remote, search=search, type=type, local_remote=local_remote, search=search, type=type,
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()),
menu_topics=menu_topics(),
site=g.site site=g.site
) )
@ -545,6 +557,7 @@ def admin_content_trash():
return render_template('admin/posts.html', title=_('Bad posts'), next_url=next_url, prev_url=prev_url, posts=posts, return render_template('admin/posts.html', title=_('Bad posts'), next_url=next_url, prev_url=prev_url, posts=posts,
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()),
menu_topics=menu_topics(),
site=g.site site=g.site
) )
@ -580,6 +593,7 @@ def admin_content_spam():
posts=posts, post_replies=post_replies, posts=posts, post_replies=post_replies,
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()),
menu_topics=menu_topics(),
site=g.site site=g.site
) )
@ -659,6 +673,7 @@ def admin_user_edit(user_id):
return render_template('admin/edit_user.html', title=_('Edit user'), form=form, user=user, return render_template('admin/edit_user.html', title=_('Edit user'), form=form, user=user,
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()),
menu_topics=menu_topics(),
site=g.site site=g.site
) )
@ -728,6 +743,7 @@ def admin_users_add():
return render_template('admin/add_user.html', title=_('Add user'), form=form, user=user, return render_template('admin/add_user.html', title=_('Add user'), form=form, user=user,
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()),
menu_topics=menu_topics(),
site=g.site site=g.site
) )
@ -776,6 +792,7 @@ def admin_reports():
local_remote=local_remote, search=search, local_remote=local_remote, search=search,
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()),
menu_topics=menu_topics(),
site=g.site site=g.site
) )
@ -793,5 +810,6 @@ def newsletter():
return render_template("admin/newsletter.html", form=form, title=_('Send newsletter'), return render_template("admin/newsletter.html", form=form, title=_('Send newsletter'),
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()),
menu_topics=menu_topics(),
site=g.site site=g.site
) )

View file

@ -8,7 +8,7 @@ from app.chat.forms import AddReply, ReportConversationForm
from app.chat.util import send_message from app.chat.util import send_message
from app.models import Site, User, Report, ChatMessage, Notification, InstanceBlock, Conversation, conversation_member from app.models import Site, User, Report, ChatMessage, Notification, InstanceBlock, Conversation, conversation_member
from app.user.forms import ReportUserForm from app.user.forms import ReportUserForm
from app.utils import render_template, moderating_communities, joined_communities from app.utils import render_template, moderating_communities, joined_communities, menu_topics
from app.chat import bp from app.chat import bp
@ -51,6 +51,7 @@ def chat_home(conversation_id=None):
current_conversation=conversation_id, conversation=conversation, current_conversation=conversation_id, conversation=conversation,
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()),
menu_topics=menu_topics(),
site=g.site) site=g.site)
@ -80,6 +81,7 @@ def new_message(to):
recipient=recipient, recipient=recipient,
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()),
menu_topics=menu_topics(),
site=g.site) site=g.site)
@ -109,6 +111,7 @@ def chat_options(conversation_id):
return render_template('chat/chat_options.html', conversation=conversation, return render_template('chat/chat_options.html', conversation=conversation,
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()),
menu_topics=menu_topics(),
site=g.site site=g.site
) )
@ -169,5 +172,7 @@ def chat_report(conversation_id):
return render_template('chat/report.html', title=_('Report conversation'), form=form, conversation=conversation, return render_template('chat/report.html', title=_('Report conversation'), form=form, conversation=conversation,
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()),
menu_topics=menu_topics(),
site=g.site
) )

View file

@ -33,7 +33,7 @@ from app.utils import get_setting, render_template, allowlist_html, markdown_to_
request_etag_matches, return_304, instance_banned, can_create_post, can_upvote, can_downvote, user_filters_posts, \ request_etag_matches, return_304, instance_banned, can_create_post, can_upvote, can_downvote, user_filters_posts, \
joined_communities, moderating_communities, blocked_domains, mimetype_from_url, blocked_instances, \ joined_communities, moderating_communities, blocked_domains, mimetype_from_url, blocked_instances, \
community_moderators, communities_banned_from, show_ban_message, recently_upvoted_posts, recently_downvoted_posts, \ community_moderators, communities_banned_from, show_ban_message, recently_upvoted_posts, recently_downvoted_posts, \
blocked_users, post_ranking, languages_for_form, english_language_id blocked_users, post_ranking, languages_for_form, english_language_id, menu_topics
from feedgen.feed import FeedGenerator from feedgen.feed import FeedGenerator
from datetime import timezone, timedelta from datetime import timezone, timedelta
@ -91,7 +91,10 @@ def add_local():
return redirect('/c/' + community.name) 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()), 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()), current_app=current_app) joined_communities=joined_communities(current_user.get_id()),
current_app=current_app,
menu_topics=menu_topics(),
site=g.site)
@bp.route('/add_remote', methods=['GET', 'POST']) @bp.route('/add_remote', methods=['GET', 'POST'])
@ -126,7 +129,9 @@ def add_remote():
return render_template('community/add_remote.html', return render_template('community/add_remote.html',
title=_('Add remote community'), form=form, new_community=new_community, title=_('Add remote community'), form=form, new_community=new_community,
subscribed=community_membership(current_user, new_community) >= SUBSCRIPTION_MEMBER, moderating_communities=moderating_communities(current_user.get_id()), subscribed=community_membership(current_user, new_community) >= 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()),
menu_topics=menu_topics(),
site=g.site)
@bp.route('/retrieve_remote_post/<int:community_id>', methods=['GET', 'POST']) @bp.route('/retrieve_remote_post/<int:community_id>', methods=['GET', 'POST'])
@ -294,7 +299,8 @@ def show_community(community: Community):
recently_upvoted=recently_upvoted, recently_downvoted=recently_downvoted, recently_upvoted=recently_upvoted, recently_downvoted=recently_downvoted,
rss_feed=f"https://{current_app.config['SERVER_NAME']}/community/{community.link()}/feed", rss_feed_name=f"{community.title} on PieFed", rss_feed=f"https://{current_app.config['SERVER_NAME']}/community/{community.link()}/feed", rss_feed_name=f"{community.title} on PieFed",
content_filters=content_filters, moderating_communities=moderating_communities(current_user.get_id()), 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()),
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)], post_layout=post_layout, current_app=current_app)
@ -550,6 +556,7 @@ def add_discussion_post(actor):
markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor, markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor,
moderating_communities=moderating_communities(current_user.get_id()), moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.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)]
) )
@ -630,6 +637,7 @@ def add_image_post(actor):
markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor, markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor,
moderating_communities=moderating_communities(current_user.get_id()), moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.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)]
) )
@ -710,6 +718,7 @@ def add_link_post(actor):
markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor, markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor,
moderating_communities=moderating_communities(current_user.get_id()), moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.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)]
) )
@ -790,6 +799,7 @@ def add_video_post(actor):
markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor, markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor,
moderating_communities=moderating_communities(current_user.get_id()), moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.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)]
) )
@ -858,6 +868,7 @@ def add_poll_post(actor):
markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor, markdown_editor=current_user.markdown_editor, low_bandwidth=False, actor=actor,
moderating_communities=moderating_communities(current_user.get_id()), moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.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)]
) )
@ -1155,7 +1166,8 @@ def community_edit(community_id: int):
return render_template('community/community_edit.html', title=_('Edit community'), form=form, return render_template('community/community_edit.html', title=_('Edit community'), form=form,
current_app=current_app, current="edit_settings", current_app=current_app, current="edit_settings",
community=community, moderating_communities=moderating_communities(current_user.get_id()), community=community, moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.get_id())) joined_communities=joined_communities(current_user.get_id()),
menu_topics=menu_topics(), site=g.site)
else: else:
abort(401) abort(401)
@ -1212,7 +1224,8 @@ def community_delete(community_id: int):
return render_template('community/community_delete.html', title=_('Delete community'), form=form, return render_template('community/community_delete.html', title=_('Delete community'), form=form,
community=community, moderating_communities=moderating_communities(current_user.get_id()), community=community, moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.get_id())) joined_communities=joined_communities(current_user.get_id()),
menu_topics=menu_topics(), site=g.site)
else: else:
abort(401) abort(401)
@ -1231,7 +1244,8 @@ def community_mod_list(community_id: int):
return render_template('community/community_mod_list.html', title=_('Moderators for %(community)s', community=community.display_name()), return render_template('community/community_mod_list.html', title=_('Moderators for %(community)s', community=community.display_name()),
moderators=moderators, community=community, current="moderators", moderators=moderators, community=community, current="moderators",
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()),
menu_topics=menu_topics(), site=g.site
) )
@ -1287,7 +1301,8 @@ def community_add_moderator(community_id: int):
return render_template('community/community_add_moderator.html', title=_('Add moderator to %(community)s', community=community.display_name()), return render_template('community/community_add_moderator.html', title=_('Add moderator to %(community)s', community=community.display_name()),
community=community, form=form, community=community, form=form,
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()),
menu_topics=menu_topics(), site=g.site
) )
@ -1393,6 +1408,7 @@ def community_ban_user(community_id: int, user_id: int):
user=user, user=user,
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()),
menu_topics=menu_topics(), site=g.site,
inoculation=inoculation[randint(0, len(inoculation) - 1)] inoculation=inoculation[randint(0, len(inoculation) - 1)]
) )
@ -1497,6 +1513,7 @@ def community_moderate(actor):
next_url=next_url, prev_url=prev_url, next_url=next_url, prev_url=prev_url,
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()),
menu_topics=menu_topics(), site=g.site,
inoculation=inoculation[randint(0, len(inoculation) - 1)] inoculation=inoculation[randint(0, len(inoculation) - 1)]
) )
else: else:
@ -1531,6 +1548,7 @@ def community_moderate_subscribers(actor):
next_url=next_url, prev_url=prev_url, low_bandwidth=low_bandwidth, next_url=next_url, prev_url=prev_url, low_bandwidth=low_bandwidth,
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()),
menu_topics=menu_topics(), site=g.site,
inoculation=inoculation[randint(0, len(inoculation) - 1)] inoculation=inoculation[randint(0, len(inoculation) - 1)]
) )
else: else:

View file

@ -1,6 +1,6 @@
from random import randint from random import randint
from flask import redirect, url_for, flash, request, make_response, session, Markup, current_app, abort from flask import redirect, url_for, flash, request, make_response, session, Markup, current_app, abort, g
from flask_login import login_user, logout_user, current_user, login_required from flask_login import login_user, logout_user, current_user, login_required
from flask_babel import _ from flask_babel import _
@ -9,7 +9,7 @@ from app.inoculation import inoculation
from app.models import Post, Domain, Community, DomainBlock from app.models import Post, Domain, Community, DomainBlock
from app.domain import bp from app.domain import bp
from app.utils import render_template, permission_required, joined_communities, moderating_communities, \ from app.utils import render_template, permission_required, joined_communities, moderating_communities, \
user_filters_posts, blocked_domains, blocked_instances user_filters_posts, blocked_domains, blocked_instances, menu_topics
from sqlalchemy import desc, or_ from sqlalchemy import desc, or_
@ -49,6 +49,7 @@ def show_domain(domain_id):
content_filters=content_filters, content_filters=content_filters,
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()),
menu_topics=menu_topics(), site=g.site,
inoculation=inoculation[randint(0, len(inoculation) - 1)] inoculation=inoculation[randint(0, len(inoculation) - 1)]
) )
else: else:

View file

@ -28,7 +28,7 @@ from app.utils import render_template, get_setting, gibberish, request_etag_matc
ap_datetime, ip_address, retrieve_block_list, shorten_string, markdown_to_text, user_filters_home, \ ap_datetime, ip_address, retrieve_block_list, shorten_string, markdown_to_text, user_filters_home, \
joined_communities, moderating_communities, parse_page, theme_list, get_request, markdown_to_html, allowlist_html, \ joined_communities, moderating_communities, parse_page, theme_list, get_request, markdown_to_html, allowlist_html, \
blocked_instances, communities_banned_from, topic_tree, recently_upvoted_posts, recently_downvoted_posts, \ blocked_instances, communities_banned_from, topic_tree, recently_upvoted_posts, recently_downvoted_posts, \
generate_image_from_video_url, blocked_users, microblog_content_to_title generate_image_from_video_url, blocked_users, microblog_content_to_title, menu_topics
from app.models import Community, CommunityMember, Post, Site, User, utcnow, Domain, Topic, File, Instance, \ from app.models import Community, CommunityMember, Post, Site, User, utcnow, Domain, Topic, File, Instance, \
InstanceRole, Notification, Language, community_language InstanceRole, Notification, Language, community_language
from PIL import Image from PIL import Image
@ -167,6 +167,7 @@ def home_page(type, sort):
content_filters=content_filters, type=type, sort=sort, content_filters=content_filters, type=type, sort=sort,
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()),
menu_topics=menu_topics(), site=g.site,
inoculation=inoculation[randint(0, len(inoculation) - 1)]) inoculation=inoculation[randint(0, len(inoculation) - 1)])
@ -178,7 +179,8 @@ def list_topics():
return render_template('list_topics.html', topics=topics, title=_('Browse by topic'), return render_template('list_topics.html', topics=topics, title=_('Browse by topic'),
low_bandwidth=request.cookies.get('low_bandwidth', '0') == '1', low_bandwidth=request.cookies.get('low_bandwidth', '0') == '1',
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()),
menu_topics=menu_topics(), site=g.site)
@bp.route('/communities', methods=['GET']) @bp.route('/communities', methods=['GET'])
@ -223,7 +225,8 @@ def list_communities():
next_url=next_url, prev_url=prev_url, next_url=next_url, prev_url=prev_url,
topics=topics, languages=languages, topic_id=topic_id, language_id=language_id, sort_by=sort_by, topics=topics, languages=languages, topic_id=topic_id, language_id=language_id, sort_by=sort_by,
low_bandwidth=low_bandwidth, moderating_communities=moderating_communities(current_user.get_id()), low_bandwidth=low_bandwidth, moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.get_id())) joined_communities=joined_communities(current_user.get_id()),
menu_topics=menu_topics(), site=g.site)
@bp.route('/communities/local', methods=['GET']) @bp.route('/communities/local', methods=['GET'])
@ -268,7 +271,8 @@ def list_local_communities():
next_url=next_url, prev_url=prev_url, next_url=next_url, prev_url=prev_url,
topics=topics, languages=languages, topic_id=topic_id, language_id=language_id, sort_by=sort_by, topics=topics, languages=languages, topic_id=topic_id, language_id=language_id, sort_by=sort_by,
low_bandwidth=low_bandwidth, moderating_communities=moderating_communities(current_user.get_id()), low_bandwidth=low_bandwidth, moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.get_id())) joined_communities=joined_communities(current_user.get_id()),
menu_topics=menu_topics(), site=g.site)
@bp.route('/communities/subscribed', methods=['GET']) @bp.route('/communities/subscribed', methods=['GET'])
@ -319,7 +323,8 @@ def list_subscribed_communities():
next_url=next_url, prev_url=prev_url, next_url=next_url, prev_url=prev_url,
topics=topics, languages=languages, topic_id=topic_id, language_id=language_id, sort_by=sort_by, topics=topics, languages=languages, topic_id=topic_id, language_id=language_id, sort_by=sort_by,
low_bandwidth=low_bandwidth, moderating_communities=moderating_communities(current_user.get_id()), low_bandwidth=low_bandwidth, moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.get_id())) joined_communities=joined_communities(current_user.get_id()),
menu_topics=menu_topics(), site=g.site)
@bp.route('/donate') @bp.route('/donate')

View file

@ -29,7 +29,7 @@ from app.utils import get_setting, render_template, allowlist_html, markdown_to_
reply_already_exists, reply_is_just_link_to_gif_reaction, confidence, moderating_communities, joined_communities, \ reply_already_exists, reply_is_just_link_to_gif_reaction, confidence, moderating_communities, joined_communities, \
blocked_instances, blocked_domains, community_moderators, blocked_phrases, show_ban_message, recently_upvoted_posts, \ blocked_instances, blocked_domains, community_moderators, blocked_phrases, show_ban_message, recently_upvoted_posts, \
recently_downvoted_posts, recently_upvoted_post_replies, recently_downvoted_post_replies, reply_is_stupid, \ recently_downvoted_posts, recently_upvoted_post_replies, recently_downvoted_post_replies, reply_is_stupid, \
languages_for_form, english_language_id, MultiCheckboxField languages_for_form, english_language_id, MultiCheckboxField, menu_topics
def show_post(post_id: int): def show_post(post_id: int):
@ -314,6 +314,7 @@ def show_post(post_id: int):
SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR, SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR,
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()),
menu_topics=menu_topics(), site=g.site,
inoculation=inoculation[randint(0, len(inoculation) - 1)] inoculation=inoculation[randint(0, len(inoculation) - 1)]
) )
response.headers.set('Vary', 'Accept, Cookie, Accept-Language') response.headers.set('Vary', 'Accept, Cookie, Accept-Language')
@ -596,7 +597,9 @@ def continue_discussion(post_id, comment_id):
response = render_template('post/continue_discussion.html', title=_('Discussing %(title)s', title=post.title), post=post, mods=mod_list, response = render_template('post/continue_discussion.html', title=_('Discussing %(title)s', title=post.title), post=post, mods=mod_list,
is_moderator=is_moderator, comment=comment, replies=replies, markdown_editor=current_user.is_authenticated and current_user.markdown_editor, is_moderator=is_moderator, comment=comment, replies=replies, markdown_editor=current_user.is_authenticated and current_user.markdown_editor,
moderating_communities=moderating_communities(current_user.get_id()), 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()),
menu_topics=menu_topics(), site=g.site,
community=post.community,
SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR, SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR,
inoculation=inoculation[randint(0, len(inoculation) - 1)]) inoculation=inoculation[randint(0, len(inoculation) - 1)])
response.headers.set('Vary', 'Accept, Cookie, Accept-Language') response.headers.set('Vary', 'Accept, Cookie, Accept-Language')
@ -814,7 +817,8 @@ def post_options(post_id: int):
post = Post.query.get_or_404(post_id) post = Post.query.get_or_404(post_id)
return render_template('post/post_options.html', post=post, return render_template('post/post_options.html', post=post,
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()),
menu_topics=menu_topics(), site=g.site)
@bp.route('/post/<int:post_id>/comment/<int:comment_id>/options', methods=['GET']) @bp.route('/post/<int:post_id>/comment/<int:comment_id>/options', methods=['GET'])
@ -823,7 +827,8 @@ def post_reply_options(post_id: int, comment_id: int):
post_reply = PostReply.query.get_or_404(comment_id) post_reply = PostReply.query.get_or_404(comment_id)
return render_template('post/post_reply_options.html', post=post, post_reply=post_reply, return render_template('post/post_reply_options.html', post=post, post_reply=post_reply,
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()),
menu_topics=menu_topics(), site=g.site
) )
@ -900,6 +905,7 @@ def post_edit_discussion_post(post_id: int):
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()),
menu_topics=menu_topics(), site=g.site,
inoculation=inoculation[randint(0, len(inoculation) - 1)] inoculation=inoculation[randint(0, len(inoculation) - 1)]
) )
else: else:
@ -986,6 +992,7 @@ def post_edit_image_post(post_id: int):
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()),
menu_topics=menu_topics(), site=g.site,
inoculation=inoculation[randint(0, len(inoculation) - 1)] inoculation=inoculation[randint(0, len(inoculation) - 1)]
) )
else: else:
@ -1072,6 +1079,7 @@ def post_edit_link_post(post_id: int):
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()),
menu_topics=menu_topics(), site=g.site,
inoculation=inoculation[randint(0, len(inoculation) - 1)] inoculation=inoculation[randint(0, len(inoculation) - 1)]
) )
else: else:
@ -1158,6 +1166,7 @@ def post_edit_video_post(post_id: int):
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()),
menu_topics=menu_topics(), site=g.site,
inoculation=inoculation[randint(0, len(inoculation) - 1)] inoculation=inoculation[randint(0, len(inoculation) - 1)]
) )
else: else:
@ -1229,6 +1238,7 @@ def post_edit_poll_post(post_id: int):
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()),
menu_topics=menu_topics(), site=g.site,
inoculation=inoculation[randint(0, len(inoculation) - 1)] inoculation=inoculation[randint(0, len(inoculation) - 1)]
) )
else: else:
@ -1548,7 +1558,8 @@ def post_report(post_id: int):
return render_template('post/post_report.html', title=_('Report post'), form=form, post=post, return render_template('post/post_report.html', title=_('Report post'), form=form, post=post,
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()),
menu_topics=menu_topics(), site=g.site
) )
@ -1608,7 +1619,8 @@ def post_mea_culpa(post_id: int):
return render_template('post/post_mea_culpa.html', title=_('I changed my mind'), form=form, post=post, return render_template('post/post_mea_culpa.html', title=_('I changed my mind'), form=form, post=post,
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()),
menu_topics=menu_topics(), site=g.site
) )
@ -1683,7 +1695,8 @@ def post_reply_report(post_id: int, comment_id: int):
return render_template('post/post_reply_report.html', title=_('Report comment'), form=form, post=post, post_reply=post_reply, return render_template('post/post_reply_report.html', title=_('Report comment'), form=form, post=post, post_reply=post_reply,
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()),
menu_topics=menu_topics(), site=g.site
) )
@ -1843,7 +1856,8 @@ def post_reply_edit(post_id: int, comment_id: int):
form.language_id.data = post_reply.language_id form.language_id.data = post_reply.language_id
return render_template('post/post_reply_edit.html', title=_('Edit comment'), form=form, post=post, post_reply=post_reply, return render_template('post/post_reply_edit.html', title=_('Edit comment'), form=form, post=post, post_reply=post_reply,
comment=comment, markdown_editor=current_user.markdown_editor, moderating_communities=moderating_communities(current_user.get_id()), comment=comment, markdown_editor=current_user.markdown_editor, 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()), menu_topics=menu_topics(),
community=post.community, site=g.site,
SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR, SUBSCRIPTION_OWNER=SUBSCRIPTION_OWNER, SUBSCRIPTION_MODERATOR=SUBSCRIPTION_MODERATOR,
inoculation=inoculation[randint(0, len(inoculation) - 1)]) inoculation=inoculation[randint(0, len(inoculation) - 1)])
else: else:

View file

@ -6,7 +6,7 @@ from sqlalchemy import or_
from app.models import Post, Language, Community from app.models import Post, Language, Community
from app.search import bp from app.search import bp
from app.utils import moderating_communities, joined_communities, render_template, blocked_domains, blocked_instances, \ from app.utils import moderating_communities, joined_communities, render_template, blocked_domains, blocked_instances, \
communities_banned_from, recently_upvoted_posts, recently_downvoted_posts, blocked_users communities_banned_from, recently_upvoted_posts, recently_downvoted_posts, blocked_users, menu_topics
from app.community.forms import RetrieveRemotePost from app.community.forms import RetrieveRemotePost
from app.activitypub.util import resolve_remote_post_from_search from app.activitypub.util import resolve_remote_post_from_search
@ -81,6 +81,7 @@ def run_search():
recently_downvoted=recently_downvoted, recently_downvoted=recently_downvoted,
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()),
menu_topics=menu_topics(),
site=g.site) site=g.site)
else: else:
@ -88,6 +89,7 @@ def run_search():
languages=languages, languages=languages,
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()),
menu_topics=menu_topics(),
site=g.site) site=g.site)

View file

@ -9,7 +9,7 @@ from app.inoculation import inoculation
from app.models import Post, Community, Tag, post_tag from app.models import Post, Community, Tag, post_tag
from app.tag import bp from app.tag import bp
from app.utils import render_template, permission_required, joined_communities, moderating_communities, \ from app.utils import render_template, permission_required, joined_communities, moderating_communities, \
user_filters_posts, blocked_instances, blocked_users, blocked_domains user_filters_posts, blocked_instances, blocked_users, blocked_domains, menu_topics
from sqlalchemy import desc, or_ from sqlalchemy import desc, or_
@ -56,6 +56,7 @@ def show_tag(tag):
content_filters=content_filters, content_filters=content_filters,
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()),
menu_topics=menu_topics(),
inoculation=inoculation[randint(0, len(inoculation) - 1)] inoculation=inoculation[randint(0, len(inoculation) - 1)]
) )
else: else:

View file

@ -1,11 +1,11 @@
{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %} {% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') -%}
{% extends 'themes/' + theme() + '/base.html' %} {% extends 'themes/' + theme() + '/base.html' -%}
{% else %} {% else -%}
{% extends "base.html" %} {% extends "base.html" -%}
{% endif %} %} {% endif -%} -%}
{% from 'bootstrap/form.html' import render_form %} {% from 'bootstrap/form.html' import render_form -%}
{% block app_content %} {% block app_content -%}
<div class="row"> <div class="row">
<div class="col col-login mx-auto"> <div class="col col-login mx-auto">
<div class="card mt-5"> <div class="card mt-5">
@ -25,4 +25,4 @@
</div> </div>
</div> </div>
{% endblock %} {% endblock -%}

View file

@ -1,32 +1,32 @@
{% macro render_username(user) %} {% macro render_username(user) -%}
<span class="render_username"> <span class="render_username">
{% if user.deleted %} {% if user.deleted -%}
[deleted] [deleted]
{% else %} {% else -%}
{% if user.avatar_id and not low_bandwidth %} {% if user.avatar_id and not low_bandwidth -%}
<a href="/u/{{ user.link() }}" title="{{ user.ap_id if user.ap_id != none else user.user_name }}"> <a href="/u/{{ user.link() }}" title="{{ user.ap_id if user.ap_id != none else user.user_name }}">
<img src="{{ user.avatar_thumbnail() }}" alt="" loading="lazy" /></a> <img src="{{ user.avatar_thumbnail() }}" alt="" loading="lazy" /></a>
{% endif %} {% endif -%}
<a href="/u/{{ user.link() }}" title="{{ user.ap_id if user.ap_id != none else user.user_name }}">{{ user.display_name() }}</a> <a href="/u/{{ user.link() }}" title="{{ user.ap_id if user.ap_id != none else user.user_name }}">{{ user.display_name() }}</a>
{% if user.created_recently() %} {% if user.created_recently() -%}
<span class="fe fe-new-account" title="New account"> </span> <span class="fe fe-new-account" title="New account"> </span>
{% endif %} {% endif -%}
{% if user.bot %} {% if user.bot -%}
<span class="fe fe-bot-account" title="Bot account"> </span> <span class="fe fe-bot-account" title="Bot account"> </span>
{% endif %} {% endif -%}
{% if user.reputation < -10 %} {% if user.reputation < -10 -%}
<span class="fe fe-warning red" title="Very low reputation. Beware."> </span> <span class="fe fe-warning red" title="Very low reputation. Beware."> </span>
<span class="fe fe-warning red" title="Very low reputation. Beware!"> </span> <span class="fe fe-warning red" title="Very low reputation. Beware!"> </span>
{% elif user.reputation < 0 %} {% elif user.reputation < 0 -%}
<span class="fe fe-warning orangered" title="Low reputation."> </span> <span class="fe fe-warning orangered" title="Low reputation."> </span>
{% endif %} {% endif -%}
{% endif %} {% endif -%}
</span> </span>
{% endmacro %} {% endmacro -%}
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
{% block head %} {% block head -%}
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="Content-Language" content="en" /> <meta http-equiv="Content-Language" content="en" />
@ -39,19 +39,19 @@
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
<meta name="HandheldFriendly" content="True"> <meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320"> <meta name="MobileOptimized" content="320">
{% block styles %} {% block styles -%}
<link href="{{ url_for('static', filename='bootstrap.css') }}" type="text/css" rel="stylesheet" /> <link href="{{ url_for('static', filename='bootstrap.css') }}" type="text/css" rel="stylesheet" />
<link href="{{ url_for('static', filename='structure.css', changed=getmtime('structure.css')) }}" type="text/css" rel="stylesheet" /> <link href="{{ url_for('static', filename='structure.css', changed=getmtime('structure.css')) }}" type="text/css" rel="stylesheet" />
<link href="{{ url_for('static', filename='styles.css', changed=getmtime('styles.css')) }}" type="text/css" rel="stylesheet" /> <link href="{{ url_for('static', filename='styles.css', changed=getmtime('styles.css')) }}" type="text/css" rel="stylesheet" />
<link href="{{ url_for('static', filename='themes/high_contrast/styles.css') }}" type="text/css" rel="alternate stylesheet" title="High contrast" /> <link href="{{ url_for('static', filename='themes/high_contrast/styles.css') }}" type="text/css" rel="alternate stylesheet" title="High contrast" />
{% if not low_bandwidth %} {% if not low_bandwidth -%}
<link href="{{ url_for('static', filename='js/markdown/downarea.css') }}" type="text/css" rel="stylesheet" /> <link href="{{ url_for('static', filename='js/markdown/downarea.css') }}" type="text/css" rel="stylesheet" />
<link href="{{ url_for('static', filename='js/lightbox/baguetteBox.css') }}" type="text/css" rel="stylesheet" /> <link href="{{ url_for('static', filename='js/lightbox/baguetteBox.css') }}" type="text/css" rel="stylesheet" />
{% endif %} {% endif -%}
{% if theme() and file_exists('app/templates/themes/' + theme() + '/styles.css') %} {% if theme() and file_exists('app/templates/themes/' + theme() + '/styles.css') -%}
<link href="{{ url_for('static', filename='themes/' + theme() + '/styles.css') }}" type="text/css" rel="stylesheet" /> <link href="{{ url_for('static', filename='themes/' + theme() + '/styles.css') }}" type="text/css" rel="stylesheet" />
{% endif %} {% endif -%}
{% endblock %} {% endblock -%}
<title>{% if title %}{{ title }}{% else %}{{ _('PieFed') }}{% endif %}</title> <title>{% if title %}{{ title }}{% else %}{{ _('PieFed') }}{% endif %}</title>
<link rel="apple-touch-icon" sizes="152x152" href="/static/images/apple-touch-icon.png"> <link rel="apple-touch-icon" sizes="152x152" href="/static/images/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/images/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="32x32" href="/static/images/favicon-32x32.png">
@ -62,21 +62,21 @@
<meta name="msapplication-TileColor" content="#da532c"> <meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-config" content="/static/browserconfig.xml"> <meta name="msapplication-config" content="/static/browserconfig.xml">
<meta name="theme-color" content="#ffffff"> <meta name="theme-color" content="#ffffff">
{% if canonical %} {% if canonical -%}
<link rel="canonical" href="{{ canonical }}" /> <link rel="canonical" href="{{ canonical }}" />
{% endif %} {% endif -%}
{% if description %} {% if description -%}
<meta name="description" content="{{ description }}" /> <meta name="description" content="{{ description }}" />
{% endif %} {% endif -%}
{% if og_image %} {% if og_image -%}
<meta property="og:image" content="{{ og_image }}" /> <meta property="og:image" content="{{ og_image }}" />
{% endif %} {% endif -%}
{% if rss_feed %} {% if rss_feed -%}
<link rel="alternate" type="application/rss+xml" title="{{ rss_feed_name }}" href="{{ rss_feed }}" /> <link rel="alternate" type="application/rss+xml" title="{{ rss_feed_name }}" href="{{ rss_feed }}" />
{% endif %} {% endif -%}
{% if noindex %} {% if noindex -%}
<meta name="robots" content="noindex"> <meta name="robots" content="noindex">
{% endif %} {% endif -%}
<script nonce="{{ session['nonce']}}"> <script nonce="{{ session['nonce']}}">
const getStoredTheme = () => localStorage.getItem('theme') const getStoredTheme = () => localStorage.getItem('theme')
const setStoredTheme = theme => localStorage.setItem('theme', theme) const setStoredTheme = theme => localStorage.setItem('theme', theme)
@ -99,28 +99,28 @@
setTheme(getPreferredTheme()); setTheme(getPreferredTheme());
</script> </script>
{% if preconnect and not low_bandwidth %} {% if preconnect and not low_bandwidth -%}
<link rel="preconnect" href='{{ preconnect }}'> <link rel="preconnect" href='{{ preconnect }}'>
{% endif %} {% endif -%}
{% endblock %} {% endblock -%}
</head> </head>
<body class="d-flex flex-column{{ ' low_bandwidth' if low_bandwidth }}"> <body class="d-flex flex-column{{ ' low_bandwidth' if low_bandwidth }}">
<a href="#outer_container" class="skip-link" role="navigation" aria-label="Skip main navigation" tabindex="">Skip to main content</a> <a href="#outer_container" class="skip-link" role="navigation" aria-label="Skip main navigation" tabindex="">Skip to main content</a>
<a href="#side_pane" class="skip-link" role="navigation" aria-label="Go to side pane" tabindex="">Go to side pane</a> <a href="#side_pane" class="skip-link" role="navigation" aria-label="Go to side pane" tabindex="">Go to side pane</a>
<!-- Page content --> <!-- Page content -->
{% block navbar %} {% block navbar -%}
<div class="navbar navbar-expand-lg sticky-md-top"> <div class="navbar navbar-expand-lg sticky-md-top">
<div class="{{ 'container-lg' if post_layout != 'masonry_wide' else 'container-fluid' }}" role="banner"> <div class="{{ 'container-lg' if post_layout != 'masonry_wide' else 'container-fluid' }}" role="banner">
<a class="navbar-brand" href="/">{% if not low_bandwidth %}<img src="/static/images/logo2.png" alt="Logo" width="50" height="50" />{% endif %}{{ g.site.name }}</a> <a class="navbar-brand" href="/">{% if not low_bandwidth %}<img src="/static/images/logo2.png" alt="Logo" width="50" height="50" />{% endif %}{{ g.site.name }}</a>
{% if current_user.is_authenticated %} {% if current_user.is_authenticated -%}
<a class="nav-link d-lg-none" href="/notifications" aria-label="{{ _('Notifications') }}"> <a class="nav-link d-lg-none" href="/notifications" aria-label="{{ _('Notifications') }}">
{% if current_user.unread_notifications %} {% if current_user.unread_notifications -%}
<span class="fe fe-bell red"></span> <span class="red">{{ current_user.unread_notifications }}</span> <span class="fe fe-bell red"></span> <span class="red">{{ current_user.unread_notifications }}</span>
{% else %} {% else -%}
<span class="fe fe-bell"></span> <span class="fe fe-bell"></span>
{% endif %} {% endif -%}
</a> </a>
{% endif %} {% endif -%}
<button id="navbar-toggler" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="true" aria-label="Toggle navigation"> <button id="navbar-toggler" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="true" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
@ -139,7 +139,14 @@
<li class="nav-item dropdown{% if active_parent == 'communities' %} active{% endif %}"> <li class="nav-item dropdown{% if active_parent == 'communities' %} active{% endif %}">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="/topics" aria-haspopup="true" aria-expanded="false">{{ _('Topics') }}</a> <a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="/topics" aria-haspopup="true" aria-expanded="false">{{ _('Topics') }}</a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a class="dropdown-item{% if active_child == 'list_topics' %} active{% endif %}" href="/topics">{{ _('Browse by topic') }}</a></li> {% if menu_topics %}
{% for topic_menu_item in menu_topics -%}
<li><a class="dropdown-item{% if topic and topic.id == topic_menu_item.id%} active{% endif %}" href="/topic/{{ topic_menu_item.path() }}">{{ topic_menu_item.name }}</a></li>
{% endfor -%}
<li><a class="dropdown-item{% if active_child == 'list_topics' %} active{% endif %}" href="/topics">{{ _('More topics') }}</a></li>
{% else %}
<li><a class="dropdown-item{% if active_child == 'list_topics' %} active{% endif %}" href="/topics">{{ _('Browse by topic') }}</a></li>
{% endif %}
<li><a class="dropdown-item{% if active_child == 'list_communities' %} active{% endif %}" href="/communities">{{ _('All communities') }}</a></li> <li><a class="dropdown-item{% if active_child == 'list_communities' %} active{% endif %}" href="/communities">{{ _('All communities') }}</a></li>
</ul> </ul>
</li> </li>
@ -157,21 +164,28 @@
<li class="nav-item dropdown{% if active_parent == 'communities' %} active{% endif %}"> <li class="nav-item dropdown{% if active_parent == 'communities' %} active{% endif %}">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="/topics" aria-haspopup="true" aria-expanded="false">{{ _('Topics') }}</a> <a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="/topics" aria-haspopup="true" aria-expanded="false">{{ _('Topics') }}</a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a class="dropdown-item{% if active_child == 'list_communities' %} active{% endif %}" href="/topics">{{ _('Browse by topic') }}</a></li> {% if menu_topics -%}
<li><a class="dropdown-item{% if active_child == 'list_topics' %} active{% endif %}" href="/communities">{{ _('All communities') }}</a></li> {% for topic_menu_item in menu_topics -%}
<li><a class="dropdown-item{% if topic and topic.id == topic_menu_item.id%} active{% endif %}" href="/topic/{{ topic_menu_item.path() }}">{{ topic_menu_item.name }}</a></li>
{% endfor -%}
<li><a class="dropdown-item{% if active_child == 'list_topics' %} active{% endif %}" href="/topics">{{ _('More topics') }}</a></li>
{% else -%}
<li><a class="dropdown-item{% if active_child == 'list_topics' %} active{% endif %}" href="/topics">{{ _('Browse by topic') }}</a></li>
{% endif -%}
<li><a class="dropdown-item{% if active_child == 'list_communities' %} active{% endif %}" href="/communities">{{ _('All communities') }}</a></li>
{% if moderating_communities %} {% if moderating_communities %}
<li><hr class="dropdown-divider"></li> <li><hr class="dropdown-divider"></li>
<li><h6 class="dropdown-header">{{ _('Moderating') }}</h6></li> <li><h6 class="dropdown-header">{{ _('Moderating') }}</h6></li>
{% for community_menu_item in moderating_communities %} {% for community_menu_item in moderating_communities -%}
<li class="pl-2"><a class="dropdown-item{% if community and community.id == community_menu_item.id%} active{% endif %}" href="/c/{{ community_menu_item.link() }}">{{ community_menu_item.title }}</a></li> <li class="pl-2"><a class="dropdown-item{% if community and community.id == community_menu_item.id%} active{% endif %}" href="/c/{{ community_menu_item.link() }}">{{ community_menu_item.title }}</a></li>
{% endfor %} {% endfor -%}
{% endif %} {% endif %}
{% if joined_communities %} {% if joined_communities %}
<li><hr class="dropdown-divider"></li> <li><hr class="dropdown-divider"></li>
<li><h6 class="dropdown-header">{{ _('Joined communities') }}</h6></li> <li><h6 class="dropdown-header">{{ _('Joined communities') }}</h6></li>
{% for community_menu_item in joined_communities %} {% for community_menu_item in joined_communities -%}
<li class="pl-2"><a class="dropdown-item{% if community and community.id == community_menu_item.id%} active{% endif %}" href="/c/{{ community_menu_item.link() }}">{{ community_menu_item.title }}</a></li> <li class="pl-2"><a class="dropdown-item{% if community and community.id == community_menu_item.id%} active{% endif %}" href="/c/{{ community_menu_item.link() }}">{{ community_menu_item.title }}</a></li>
{% endfor %} {% endfor -%}
{% endif %} {% endif %}
</ul> </ul>
</li> </li>
@ -255,31 +269,31 @@
<p class="text-center"><a href="https://codeberg.org/rimu/pyfedi">PieFed is free and open source</a>.<br />Please <a href="https://codeberg.org/rimu/pyfedi/issues">report bugs</a> or <a href="https://join.piefed.social/get-involved/">get involved</a>.</p> <p class="text-center"><a href="https://codeberg.org/rimu/pyfedi">PieFed is free and open source</a>.<br />Please <a href="https://codeberg.org/rimu/pyfedi/issues">report bugs</a> or <a href="https://join.piefed.social/get-involved/">get involved</a>.</p>
<p class="text-center"><a href="/privacy">Privacy policy</a></p> <p class="text-center"><a href="/privacy">Privacy policy</a></p>
</footer> </footer>
{% endblock %} {% endblock -%}
{% block scripts %} {% block scripts -%}
{% if not low_bandwidth %} {% if not low_bandwidth -%}
{{ str(moment.include_moment()).replace('<script>', '<script nonce="' + session['nonce'] + '">')|safe }} {{ str(moment.include_moment()).replace('<script>', '<script nonce="' + session['nonce'] + '">')|safe }}
{{ str(moment.lang(g.locale)).replace('<script>', '<script nonce="' + session['nonce'] + '">')|safe }} {{ str(moment.lang(g.locale)).replace('<script>', '<script nonce="' + session['nonce'] + '">')|safe }}
{% endif %} {% endif -%}
{% endblock %} {% endblock -%}
{% if not low_bandwidth %} {% if not low_bandwidth -%}
{{ str(bootstrap.load_js()).replace('<script ', '<script nonce="' + session['nonce'] + '" ')|safe }} {{ str(bootstrap.load_js()).replace('<script ', '<script nonce="' + session['nonce'] + '" ')|safe }}
<script src="{{ url_for('static', filename='js/lightbox/baguetteBox.js') }}" nonce="{{ session['nonce'] }}"></script> <script src="{{ url_for('static', filename='js/lightbox/baguetteBox.js') }}" nonce="{{ session['nonce'] }}"></script>
{% endif %} {% endif -%}
<script type="text/javascript" src="{{ url_for('static', filename='js/htmx.min.js') }}"></script> <script type="text/javascript" src="{{ url_for('static', filename='js/htmx.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static', filename='js/scripts.js', changed=getmtime('js/scripts.js')) }}"></script> <script type="text/javascript" src="{{ url_for('static', filename='js/scripts.js', changed=getmtime('js/scripts.js')) }}"></script>
{% if not low_bandwidth %} {% if not low_bandwidth -%}
{% if post_layout == 'masonry' or post_layout == 'masonry_wide' %} {% if post_layout == 'masonry' or post_layout == 'masonry_wide' -%}
<!-- --> <!-- -->
{% endif %} {% endif -%}
<script type="text/javascript" src="{{ url_for('static', filename='js/markdown/downarea.js', changed=getmtime('js/markdown/downarea.js')) }}"></script> <script type="text/javascript" src="{{ url_for('static', filename='js/markdown/downarea.js', changed=getmtime('js/markdown/downarea.js')) }}"></script>
{% endif %} {% endif -%}
{% if theme() and file_exists('app/templates/themes/' + theme() + '/scripts.js') %} {% if theme() and file_exists('app/templates/themes/' + theme() + '/scripts.js') -%}
<script src="{{ url_for('static', filename='themes/' + theme() + '/scripts.js') }}"></script> <script src="{{ url_for('static', filename='themes/' + theme() + '/scripts.js') }}"></script>
{% endif %} {% endif -%}
{% block end_scripts %} {% block end_scripts -%}
{% endblock %} {% endblock -%}
</body> </body>
</html> </html>

View file

@ -1,39 +1,39 @@
{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %} {% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') -%}
{% extends 'themes/' + theme() + '/base.html' %} {% extends 'themes/' + theme() + '/base.html' -%}
{% else %} {% else -%}
{% extends "base.html" %} {% extends "base.html" -%}
{% endif %} %} {% endif -%} -%}
{% from 'bootstrap/form.html' import render_form %} {% from 'bootstrap/form.html' import render_form -%}
{% block app_content %} {% block app_content -%}
<div class="row"> <div class="row">
<div class="col-12 col-md-8 position-relative main_pane"> <div class="col-12 col-md-8 position-relative main_pane">
{% if community.header_image() != '' and not low_bandwidth %} {% if community.header_image() != '' and not low_bandwidth -%}
<div class="community_header" style="background-image: url({{ community.header_image() }});"> <div class="community_header" style="background-image: url({{ community.header_image() }});">
<nav aria-label="breadcrumb" id="breadcrumb_nav" title="Navigation"> <nav aria-label="breadcrumb" id="breadcrumb_nav" title="Navigation">
<ol class="breadcrumb"> <ol class="breadcrumb">
{% for breadcrumb in breadcrumbs %} {% for breadcrumb in breadcrumbs -%}
<li class="breadcrumb-item">{% if breadcrumb.url %}<a href="{{ breadcrumb.url }}">{% endif %}{{ breadcrumb.text }}{% if breadcrumb.url %}</a>{% endif %}</li> <li class="breadcrumb-item">{% if breadcrumb.url -%}<a href="{{ breadcrumb.url }}">{% endif -%}{{ breadcrumb.text }}{% if breadcrumb.url -%}</a>{% endif -%}</li>
{% endfor %} {% endfor -%}
<li class="breadcrumb-item active">{{ (community.title + '@' + community.ap_domain)|shorten }}</li> <li class="breadcrumb-item active">{{ (community.title + '@' + community.ap_domain)|shorten }}</li>
</ol> </ol>
</nav> </nav>
</div> </div>
<img class="community_icon_big bump_up rounded-circle" src="{{ community.icon_image() }}" alt="Community icon" /> <img class="community_icon_big bump_up rounded-circle" src="{{ community.icon_image() }}" alt="Community icon" />
<h1 class="mt-2" aria-live="assertive">{{ community.title }} <h1 class="mt-2" aria-live="assertive">{{ community.title }}
{% if current_user.is_authenticated %} {% if current_user.is_authenticated -%}
{% include 'community/_notification_toggle.html' %} {% include 'community/_notification_toggle.html' -%}
{% endif %} {% endif -%}
{% if community.nsfw %}<span class="warning_badge nsfw" title="{{ _('Not safe for work') }}">nsfw</span>{% endif %} {% if community.nsfw -%}<span class="warning_badge nsfw" title="{{ _('Not safe for work') }}">nsfw</span>{% endif -%}
{% if community.nsfl %}<span class="warning_badge nsfl" title="{{ _('Not safe for life') }}">nsfl</span>{% endif %} {% if community.nsfl -%}<span class="warning_badge nsfl" title="{{ _('Not safe for life') }}">nsfl</span>{% endif -%}
</h1> </h1>
{% elif community.icon_id and not low_bandwidth %} {% elif community.icon_id and not low_bandwidth -%}
<div class="row"> <div class="row">
<nav aria-label="breadcrumb" id="breadcrumb_nav" title="Navigation"> <nav aria-label="breadcrumb" id="breadcrumb_nav" title="Navigation">
<ol class="breadcrumb"> <ol class="breadcrumb">
{% for breadcrumb in breadcrumbs %} {% for breadcrumb in breadcrumbs -%}
<li class="breadcrumb-item">{% if breadcrumb.url %}<a href="{{ breadcrumb.url }}">{% endif %}{{ breadcrumb.text }}{% if breadcrumb.url %}</a>{% endif %}</li> <li class="breadcrumb-item">{% if breadcrumb.url -%}<a href="{{ breadcrumb.url }}">{% endif -%}{{ breadcrumb.text }}{% if breadcrumb.url -%}</a>{% endif -%}</li>
{% endfor %} {% endfor -%}
<li class="breadcrumb-item active">{{ (community.title + '@' + community.ap_domain)|shorten }}</li> <li class="breadcrumb-item active">{{ (community.title + '@' + community.ap_domain)|shorten }}</li>
</ol> </ol>
</nav> </nav>
@ -42,33 +42,33 @@
</div> </div>
<div class="col-10"> <div class="col-10">
<h1 class="mt-3">{{ community.title }} <h1 class="mt-3">{{ community.title }}
{% if current_user.is_authenticated %} {% if current_user.is_authenticated -%}
{% include 'community/_notification_toggle.html' %} {% include 'community/_notification_toggle.html' -%}
{% endif %} {% endif -%}
{% if community.nsfw %}<span class="warning_badge nsfw" title="{{ _('Not safe for work') }}">nsfw</span>{% endif %} {% if community.nsfw -%}<span class="warning_badge nsfw" title="{{ _('Not safe for work') }}">nsfw</span>{% endif -%}
{% if community.nsfl %}<span class="warning_badge nsfl" title="{{ _('Not safe for life') }}">nsfl</span>{% endif %} {% if community.nsfl -%}<span class="warning_badge nsfl" title="{{ _('Not safe for life') }}">nsfl</span>{% endif -%}
</h1> </h1>
</div> </div>
</div> </div>
{% else %} {% else -%}
<nav aria-label="breadcrumb" id="breadcrumb_nav" title="Navigation"> <nav aria-label="breadcrumb" id="breadcrumb_nav" title="Navigation">
<ol class="breadcrumb"> <ol class="breadcrumb">
{% for breadcrumb in breadcrumbs %} {% for breadcrumb in breadcrumbs -%}
<li class="breadcrumb-item">{% if breadcrumb.url %}<a href="{{ breadcrumb.url }}">{% endif %}{{ breadcrumb.text }}{% if breadcrumb.url %}</a>{% endif %}</li> <li class="breadcrumb-item">{% if breadcrumb.url -%}<a href="{{ breadcrumb.url }}">{% endif -%}{{ breadcrumb.text }}{% if breadcrumb.url -%}</a>{% endif -%}</li>
{% endfor %} {% endfor -%}
<li class="breadcrumb-item active">{{ (community.title + '@' + community.ap_domain)|shorten }}</li> <li class="breadcrumb-item active">{{ (community.title + '@' + community.ap_domain)|shorten }}</li>
</ol> </ol>
</nav> </nav>
<h1 class="mt-2">{{ community.title }} <h1 class="mt-2">{{ community.title }}
{% if current_user.is_authenticated %} {% if current_user.is_authenticated -%}
{% include 'community/_notification_toggle.html' %} {% include 'community/_notification_toggle.html' -%}
{% endif %} {% endif -%}
{% if community.nsfw %}<span class="warning_badge nsfw" title="{{ _('Not safe for work') }}">nsfw</span>{% endif %} {% if community.nsfw -%}<span class="warning_badge nsfw" title="{{ _('Not safe for work') }}">nsfw</span>{% endif -%}
{% if community.nsfl %}<span class="warning_badge nsfl" title="{{ _('Not safe for life') }}">nsfl</span>{% endif %} {% if community.nsfl -%}<span class="warning_badge nsfl" title="{{ _('Not safe for life') }}">nsfl</span>{% endif -%}
</h1> </h1>
{% endif %} {% endif -%}
{% include "community/_community_nav.html" %} {% include "community/_community_nav.html" -%}
{% if post_layout == 'masonry' or post_layout == 'masonry_wide' %} {% if post_layout == 'masonry' or post_layout == 'masonry_wide' -%}
<div class="masonry" id="masonry"> <div class="masonry" id="masonry">
<!-- Masonry columns will be added here --> <!-- Masonry columns will be added here -->
</div> </div>
@ -76,34 +76,34 @@
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {
const masonry = document.getElementById('masonry'); const masonry = document.getElementById('masonry');
const htmlSnippets = [ const htmlSnippets = [
{% for post in posts.items %} {% for post in posts.items -%}
{% raw %}`{% endraw %}{% include 'post/_post_teaser_masonry.html' %}{% raw %}`{% endraw %}, {% raw -%}`{% endraw -%}{% include 'post/_post_teaser_masonry.html' -%}{% raw -%}`{% endraw -%},
{% endfor %} {% endfor -%}
]; ];
renderMasonry(masonry, htmlSnippets); renderMasonry(masonry, htmlSnippets);
}); });
</script> </script>
{% else %} {% else -%}
<div class="post_list"> <div class="post_list">
{% for post in posts.items %} {% for post in posts.items -%}
{% include 'post/_post_teaser.html' %} {% include 'post/_post_teaser.html' -%}
{% else %} {% else -%}
<p>{{ _('No posts in this community yet.') }}</p> <p>{{ _('No posts in this community yet.') }}</p>
{% endfor %} {% endfor -%}
</div> </div>
{% endif %} {% endif -%}
<nav aria-label="Pagination" class="mt-4" role="navigation"> <nav aria-label="Pagination" class="mt-4" role="navigation">
{% if prev_url %} {% if prev_url -%}
<a href="{{ prev_url }}" class="btn btn-primary" rel='nofollow'> <a href="{{ prev_url }}" class="btn btn-primary" rel='nofollow'>
<span aria-hidden="true">&larr;</span> {{ _('Previous page') }} <span aria-hidden="true">&larr;</span> {{ _('Previous page') }}
</a> </a>
{% endif %} {% endif -%}
{% if next_url %} {% if next_url -%}
<a href="{{ next_url }}" class="btn btn-primary" rel='nofollow'> <a href="{{ next_url }}" class="btn btn-primary" rel='nofollow'>
{{ _('Next page') }} <span aria-hidden="true">&rarr;</span> {{ _('Next page') }} <span aria-hidden="true">&rarr;</span>
</a> </a>
{% endif %} {% endif -%}
</nav> </nav>
</div> </div>
@ -111,19 +111,19 @@
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<div class="row"> <div class="row">
{% if not community.restricted_to_mods or (community.restricted_to_mods and current_user.is_authenticated and community_membership(current_user, community) in [SUBSCRIPTION_MODERATOR, SUBSCRIPTION_OWNER]) %} {% if not community.restricted_to_mods or (community.restricted_to_mods and current_user.is_authenticated and community_membership(current_user, community) in [SUBSCRIPTION_MODERATOR, SUBSCRIPTION_OWNER]) -%}
<div class="col-6"> <div class="col-6">
<a class="w-100 btn btn-primary" href="/community/{{ community.link() }}/submit" rel="nofollow">{{ _('Create post') }}</a> <a class="w-100 btn btn-primary" href="/community/{{ community.link() }}/submit" rel="nofollow">{{ _('Create post') }}</a>
</div> </div>
{% endif %} {% endif -%}
<div class="col-6"> <div class="col-6">
{% if current_user.is_authenticated and community_membership(current_user, community) in [SUBSCRIPTION_MEMBER, SUBSCRIPTION_MODERATOR, SUBSCRIPTION_OWNER] %} {% if current_user.is_authenticated and community_membership(current_user, community) in [SUBSCRIPTION_MEMBER, SUBSCRIPTION_MODERATOR, SUBSCRIPTION_OWNER] -%}
<a class="w-100 btn btn-primary" href="/community/{{ community.link() }}/unsubscribe" rel="nofollow">{{ _('Leave') }}</a> <a class="w-100 btn btn-primary" href="/community/{{ community.link() }}/unsubscribe" rel="nofollow">{{ _('Leave') }}</a>
{% elif current_user.is_authenticated and community_membership(current_user, community) == SUBSCRIPTION_PENDING %} {% elif current_user.is_authenticated and community_membership(current_user, community) == SUBSCRIPTION_PENDING -%}
<a class="w-100 btn btn-outline-secondary" href="/community/{{ community.link() }}/unsubscribe" rel="nofollow">{{ _('Pending') }}</a> <a class="w-100 btn btn-outline-secondary" href="/community/{{ community.link() }}/unsubscribe" rel="nofollow">{{ _('Pending') }}</a>
{% else %} {% else -%}
<a class="w-100 btn btn-primary" href="/community/{{ community.link() }}/subscribe" rel="nofollow">{{ _('Join') }}</a> <a class="w-100 btn btn-primary" href="/community/{{ community.link() }}/subscribe" rel="nofollow">{{ _('Join') }}</a>
{% endif %} {% endif -%}
</div> </div>
</div> </div>
<form method="get" action="/search"> <form method="get" action="/search">
@ -139,66 +139,66 @@
<div class="card-body"> <div class="card-body">
<p>{{ community.description_html|safe if community.description_html else '' }}</p> <p>{{ community.description_html|safe if community.description_html else '' }}</p>
<p>{{ community.rules_html|safe if community.rules_html else '' }}</p> <p>{{ community.rules_html|safe if community.rules_html else '' }}</p>
{% if len(mods) > 0 and not community.private_mods %} {% if len(mods) > 0 and not community.private_mods -%}
<h3>Moderators</h3> <h3>Moderators</h3>
<ul class="moderator_list"> <ul class="moderator_list">
{% for mod in mods %} {% for mod in mods -%}
<li>{{ render_username(mod) }}</li> <li>{{ render_username(mod) }}</li>
{% endfor %} {% endfor -%}
</ul> </ul>
{% endif %} {% endif -%}
{% if not community.is_local() %} {% if not community.is_local() -%}
<ul> <ul>
<li><p><a href="{{ community.profile_id() }}">{{ _('View community on original server') }}</a></p></li> <li><p><a href="{{ community.profile_id() }}">{{ _('View community on original server') }}</a></p></li>
<li><p><a href="{{ url_for('community.retrieve_remote_post', community_id=community.id) }}">{{ _('Retrieve a post from the original server') }}</a></p></li> <li><p><a href="{{ url_for('community.retrieve_remote_post', community_id=community.id) }}">{{ _('Retrieve a post from the original server') }}</a></p></li>
</ul> </ul>
{% endif %} {% endif -%}
{% if community.local_only %} {% if community.local_only -%}
<p>{{ _('Only people on %(instance_name)s can post or reply in this community.', instance_name=current_app.config['SERVER_NAME']) }}</p> <p>{{ _('Only people on %(instance_name)s can post or reply in this community.', instance_name=current_app.config['SERVER_NAME']) }}</p>
{% endif %} {% endif -%}
<p> <p>
<a class="no-underline" href="{{ rss_feed }}" rel="nofollow"><span class="fe fe-rss"></span> </a><a href="{{ rss_feed }}" rel="nofollow">RSS feed</a> <a class="no-underline" href="{{ rss_feed }}" rel="nofollow"><span class="fe fe-rss"></span> </a><a href="{{ rss_feed }}" rel="nofollow">RSS feed</a>
</p> </p>
</div> </div>
</div> </div>
{% if related_communities %} {% if related_communities -%}
<div class="card mt-3"> <div class="card mt-3">
<div class="card-header"> <div class="card-header">
<h2>{{ _('Related communities') }}</h2> <h2>{{ _('Related communities') }}</h2>
</div> </div>
<div class="card-body"> <div class="card-body">
<ul class="list-group list-group-flush"> <ul class="list-group list-group-flush">
{% for community in related_communities %} {% for community in related_communities -%}
<li class="list-group-item"> <li class="list-group-item">
<a href="/c/{{ community.link() }}" aria-label="{{ _('Go to community') }}"><img src="{{ community.icon_image() }}" class="community_icon rounded-circle" loading="lazy" alt="" /> <a href="/c/{{ community.link() }}" aria-label="{{ _('Go to community') }}"><img src="{{ community.icon_image() }}" class="community_icon rounded-circle" loading="lazy" alt="" />
{{ community.display_name() }} {{ community.display_name() }}
</a> </a>
</li> </li>
{% endfor %} {% endfor -%}
</ul> </ul>
<p class="mt-4"><a class="btn btn-primary" href="/communities">{{ _('Explore communities') }}</a></p> <p class="mt-4"><a class="btn btn-primary" href="/communities">{{ _('Explore communities') }}</a></p>
</div> </div>
</div> </div>
{% endif %} {% endif -%}
{% if is_moderator or is_admin %} {% if is_moderator or is_admin -%}
<div class="card mt-3"> <div class="card mt-3">
<div class="card-header"> <div class="card-header">
<h2>{{ _('Community Settings') }}</h2> <h2>{{ _('Community Settings') }}</h2>
</div> </div>
<div class="card-body"> <div class="card-body">
{% if is_owner or is_admin %} {% if is_owner or is_admin -%}
<p><a href="{{ url_for('community.community_edit', community_id=community.id) }}" class="btn btn-primary">{{ _('Settings & Moderation') }}</a></p> <p><a href="{{ url_for('community.community_edit', community_id=community.id) }}" class="btn btn-primary">{{ _('Settings & Moderation') }}</a></p>
{% elif is_moderator %} {% elif is_moderator -%}
<p><a href="/community/{{ community.link() }}/moderate" class="btn btn-primary">{{ _('Moderation') }}</a></p> <p><a href="/community/{{ community.link() }}/moderate" class="btn btn-primary">{{ _('Moderation') }}</a></p>
{% endif %} {% endif -%}
</div> </div>
</div> </div>
{% endif %} {% endif -%}
{% include "_inoculation_links.html" %} {% include "_inoculation_links.html" -%}
</aside> </aside>
</div> </div>
<div class="row"> <div class="row">
</div> </div>
{% endblock %} {% endblock -%}

View file

@ -11,12 +11,12 @@
<div class="col-12 col-md-8 position-relative main_pane"> <div class="col-12 col-md-8 position-relative main_pane">
{% include "_home_nav.html" %} {% include "_home_nav.html" %}
<div class="post_list"> <div class="post_list">
{% for post in posts.items %} {% for post in posts.items -%}
{% include 'post/_post_teaser.html' %} {% include 'post/_post_teaser.html' %}
{% else %} {% else -%}
<p>{{ _('No posts yet. Join some communities to see more.') }}</p> <p>{{ _('No posts yet. Join some communities to see more.') }}</p>
<p><a class="btn btn-primary" href="/communities">{{ _('Explore communities') }}</a></p> <p><a class="btn btn-primary" href="/communities">{{ _('Explore communities') }}</a></p>
{% endfor %} {% endfor -%}
</div> </div>
<nav aria-label="Pagination" class="mt-4" role="navigation"> <nav aria-label="Pagination" class="mt-4" role="navigation">

View file

@ -1,12 +1,12 @@
{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %} {% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') -%}
{% extends 'themes/' + theme() + '/base.html' %} {% extends 'themes/' + theme() + '/base.html' -%}
{% else %} {% else -%}
{% extends "base.html" %} {% extends "base.html" -%}
{% endif %} %} {% endif -%} -%}
{% from 'bootstrap5/form.html' import render_form %} {% from 'bootstrap5/form.html' import render_form -%}
{% set active_child = 'list_communities' %} {% set active_child = 'list_communities' -%}
{% block app_content %} {% block app_content -%}
<div class="row g-2 justify-content-between mt-2"> <div class="row g-2 justify-content-between mt-2">
<div class="col-auto"> <div class="col-auto">
<div class="btn-group"> <div class="btn-group">
@ -23,26 +23,26 @@
</div> </div>
</div> </div>
<div class="col-auto"> <div class="col-auto">
{% if topics %} {% if topics -%}
<form method="get" style="display:inline;">Topic: <form method="get" style="display:inline;">Topic:
<select name="topic_id" class="form-control-sm submit_on_change" aria-label="{{ _('Choose a topic to filter communities by') }}"> <select name="topic_id" class="form-control-sm submit_on_change" aria-label="{{ _('Choose a topic to filter communities by') }}">
<option value="0">All</option> <option value="0">All</option>
{% for topic in topics %} {% for topic in topics -%}
<option value="{{ topic.id }}" {{ 'selected' if topic.id == topic_id }}>{{ topic.name }}</option> <option value="{{ topic.id }}" {{ 'selected' if topic.id == topic_id }}>{{ topic.name }}</option>
{% endfor %} {% endfor -%}
</select> </select>
</form> </form>
{% endif %} {% endif -%}
{% if languages %} {% if languages -%}
<form method="get" style="display:inline;">Language: <form method="get" style="display:inline;">Language:
<select name="language_id" class="form-control-sm submit_on_change" aria-label="{{ _('Choose a language to filter communities by') }}"> <select name="language_id" class="form-control-sm submit_on_change" aria-label="{{ _('Choose a language to filter communities by') }}">
<option value="0">All</option> <option value="0">All</option>
{% for language in languages %} {% for language in languages -%}
<option value="{{ language.id }}" {{ 'selected' if language.id == language_id }}>{{ language.name }}</option> <option value="{{ language.id }}" {{ 'selected' if language.id == language_id }}>{{ language.name }}</option>
{% endfor %} {% endfor -%}
</select> </select>
</form> </form>
{% endif %} {% endif -%}
<form method="get" style="display:inline;"><input type="search" name="search" placeholder="{{ _('Search') }}" value="{{ search }}"></form> <form method="get" style="display:inline;"><input type="search" name="search" placeholder="{{ _('Search') }}" value="{{ search }}"></form>
</div> </div>
<div class="col-auto"> <div class="col-auto">
@ -55,14 +55,14 @@
</form> --> </form> -->
</div> </div>
</div> </div>
{% if communities %} {% if communities -%}
<div class="table-responsive-md mt-4"> <div class="table-responsive-md mt-4">
<table class="communities_table table table-striped table-hover w-100"> <table class="communities_table table table-striped table-hover w-100">
<caption class="visually-hidden">{{ _('Communities') }}</caption> <caption class="visually-hidden">{{ _('Communities') }}</caption>
<thead> <thead>
<tr> <tr>
<th> </th> <th> </th>
<th {% if not low_bandwidth %}colspan="2"{% endif %} scope="col"> <th {% if not low_bandwidth -%}colspan="2"{% endif -%} scope="col">
<a href="?sort_by=title{{ ' desc' if sort_by == 'title' }}" title="{{ _('Sort by name') }}" rel="nofollow">{{ _('Community') }} <a href="?sort_by=title{{ ' desc' if sort_by == 'title' }}" title="{{ _('Sort by name') }}" rel="nofollow">{{ _('Community') }}
<span class="{{ 'fe fe-chevron-up' if sort_by == 'community.title' }}{{ 'fe fe-chevron-down' if sort_by == 'community.title desc' }}"></span> <span class="{{ 'fe fe-chevron-up' if sort_by == 'community.title' }}{{ 'fe fe-chevron-down' if sort_by == 'community.title desc' }}"></span>
</a> </a>
@ -85,47 +85,47 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for community in communities.items %} {% for community in communities.items -%}
<tr class=""> <tr class="">
<td width="70">{% if current_user.is_authenticated %} <td width="70">{% if current_user.is_authenticated -%}
{% if community_membership(current_user, community) in [SUBSCRIPTION_MEMBER, SUBSCRIPTION_MODERATOR, SUBSCRIPTION_OWNER] %} {% if community_membership(current_user, community) in [SUBSCRIPTION_MEMBER, SUBSCRIPTION_MODERATOR, SUBSCRIPTION_OWNER] -%}
<a class="btn btn-primary btn-sm" href="/community/{{ community.link() }}/unsubscribe" rel="nofollow" aria-label="{{ _('Leave %(name)s', name=community.display_name()) }}">{{ _('Leave') }}</a> <a class="btn btn-primary btn-sm" href="/community/{{ community.link() }}/unsubscribe" rel="nofollow" aria-label="{{ _('Leave %(name)s', name=community.display_name()) }}">{{ _('Leave') }}</a>
{% elif community_membership(current_user, community) == SUBSCRIPTION_PENDING %} {% elif community_membership(current_user, community) == SUBSCRIPTION_PENDING -%}
<a class="btn btn-outline-secondary btn-sm" href="/community/{{ community.link() }}/unsubscribe" rel="nofollow">{{ _('Pending') }}</a> <a class="btn btn-outline-secondary btn-sm" href="/community/{{ community.link() }}/unsubscribe" rel="nofollow">{{ _('Pending') }}</a>
{% else %} {% else -%}
<a class="btn btn-primary btn-sm" href="/community/{{ community.link() }}/subscribe" rel="nofollow" aria-label="{{ _('Join %(name)s', name=community.display_name()) }}">{{ _('Join') }}</a> <a class="btn btn-primary btn-sm" href="/community/{{ community.link() }}/subscribe" rel="nofollow" aria-label="{{ _('Join %(name)s', name=community.display_name()) }}">{{ _('Join') }}</a>
{% endif %} {% endif -%}
{% else %} {% else -%}
<a class="btn btn-primary btn-sm" href="/community/{{ community.link() }}/subscribe" rel="nofollow" aria-label="{{ _('Join %(name)s', name=community.display_name()) }}">{{ _('Join') }}</a> <a class="btn btn-primary btn-sm" href="/community/{{ community.link() }}/subscribe" rel="nofollow" aria-label="{{ _('Join %(name)s', name=community.display_name()) }}">{{ _('Join') }}</a>
{% endif %}</td> {% endif -%}</td>
{% if not low_bandwidth %} {% if not low_bandwidth -%}
<td width="46"> <td width="46">
<a href="/c/{{ community.link() }}"><img src="{{ community.icon_image('tiny') }}" class="community_icon rounded-circle" loading="lazy" alt="" /></a> <a href="/c/{{ community.link() }}"><img src="{{ community.icon_image('tiny') }}" class="community_icon rounded-circle" loading="lazy" alt="" /></a>
</td> </td>
{% endif %} {% endif -%}
<th scope="row" class="pl-0"><a href="/c/{{ community.link() }}" aria-label="{{ _('Browse %(name)s', name=community.display_name()) }}">{{ community.display_name() }}</a></th> <th scope="row" class="pl-0"><a href="/c/{{ community.link() }}" aria-label="{{ _('Browse %(name)s', name=community.display_name()) }}">{{ community.display_name() }}</a></th>
<td>{{ community.post_count }}</td> <td>{{ community.post_count }}</td>
<td>{{ community.post_reply_count }}</td> <td>{{ community.post_reply_count }}</td>
<td>{{ moment(community.last_active).fromNow(refresh=True) }}</td> <td>{{ moment(community.last_active).fromNow(refresh=True) }}</td>
</tr> </tr>
{% endfor %} {% endfor -%}
</tbody> </tbody>
</table> </table>
</div> </div>
<nav aria-label="Pagination" class="mt-4" role="navigation"> <nav aria-label="Pagination" class="mt-4" role="navigation">
{% if prev_url %} {% if prev_url -%}
<a href="{{ prev_url }}" class="btn btn-primary" rel='nofollow'> <a href="{{ prev_url }}" class="btn btn-primary" rel='nofollow'>
<span aria-hidden="true">&larr;</span> {{ _('Previous page') }} <span aria-hidden="true">&larr;</span> {{ _('Previous page') }}
</a> </a>
{% endif %} {% endif -%}
{% if next_url %} {% if next_url -%}
<a href="{{ next_url }}" class="btn btn-primary" rel='nofollow'> <a href="{{ next_url }}" class="btn btn-primary" rel='nofollow'>
{{ _('Next page') }} <span aria-hidden="true">&rarr;</span> {{ _('Next page') }} <span aria-hidden="true">&rarr;</span>
</a> </a>
{% endif %} {% endif -%}
</nav> </nav>
{% else %} {% else -%}
<p>{{ _('There are no communities yet.') }}</p> <p>{{ _('There are no communities yet.') }}</p>
{% endif %} {% endif -%}
<p class="mt-4"><a href="/topics" class="btn btn-primary">{{ _('Browse topics') }}</a></p> <p class="mt-4"><a href="/topics" class="btn btn-primary">{{ _('Browse topics') }}</a></p>
{% endblock %} {% endblock -%}

View file

@ -1,37 +1,37 @@
{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %} {% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') -%}
{% extends 'themes/' + theme() + '/base.html' %} {% extends 'themes/' + theme() + '/base.html' -%}
{% else %} {% else -%}
{% extends "base.html" %} {% extends "base.html" -%}
{% endif %} %} {% endif -%} -%}
{% from 'bootstrap5/form.html' import render_form %} {% from 'bootstrap5/form.html' import render_form -%}
{% set active_child = 'list_topics' %} {% set active_child = 'list_topics' -%}
{% block app_content %} {% block app_content -%}
{% if len(topics) > 0 %} {% if len(topics) > 0 -%}
{% macro render_topic(topic, depth) %} {% macro render_topic(topic, depth) -%}
<li> <li>
{% if depth == 0 %}<strong>{% endif %} {% if depth == 0 -%}<strong>{% endif -%}
<a href="/topic/{{ topic['topic'].path() }}">{{ topic['topic'].name }}</a> <a href="/topic/{{ topic['topic'].path() }}">{{ topic['topic'].name }}</a>
{% if depth == 0 %}</strong>{% endif %} {% if depth == 0 -%}</strong>{% endif -%}
{% if topic['children'] %} {% if topic['children'] -%}
<ul> <ul>
{% for topic in topic['children'] %} {% for topic in topic['children'] -%}
{{ render_topic(topic, depth + 1)|safe }} {{ render_topic(topic, depth + 1)|safe }}
{% endfor %} {% endfor -%}
</ul> </ul>
{% endif %} {% endif -%}
</li> </li>
{% endmacro %} {% endmacro -%}
<h1>{{ _('Choose a topic') }}</h1> <h1>{{ _('Choose a topic') }}</h1>
<div class="table-responsive-md mt-4"> <div class="table-responsive-md mt-4">
<ul class="topics_list"> <ul class="topics_list">
{% for topic in topics %} {% for topic in topics -%}
{{ render_topic(topic, 0)|safe }} {{ render_topic(topic, 0)|safe }}
{% endfor %} {% endfor -%}
</ul> </ul>
</div> </div>
{% else %} {% else -%}
<p>{{ _('There are no communities yet.') }}</p> <p>{{ _('There are no communities yet.') }}</p>
{% endif %} {% endif -%}
<p><a href="/communities" class="btn btn-primary">{{ _('Explore communities') }}</a></p> <p><a href="/communities" class="btn btn-primary">{{ _('Explore communities') }}</a></p>
{% endblock %} {% endblock -%}

View file

@ -1,89 +1,88 @@
{% set content_blocked = post.blocked_by_content_filter(content_filters) %} {% set content_blocked = post.blocked_by_content_filter(content_filters) -%}
{% if content_blocked and content_blocked == '-1' %} {% if content_blocked and content_blocked == '-1' -%}
{# do nothing - blocked by keyword filter #} {# do nothing - blocked by keyword filter #}
{% else %} {% else -%}
<div class="post_teaser type_{{ post.type }}{{ ' reported' if post.reports > 0 and current_user.is_authenticated and post.community.is_moderator() }}{{ ' blocked' if content_blocked }}" <div class="post_teaser type_{{ post.type }}{{ ' reported' if post.reports > 0 and current_user.is_authenticated and post.community.is_moderator() }}{{ ' blocked' if content_blocked }}"
{% if content_blocked %} title="{{ _('Filtered: ') }}{{ content_blocked }}"{% endif %} tabindex="0"> {% if content_blocked -%} title="{{ _('Filtered: ') }}{{ content_blocked }}"{% endif -%} tabindex="0">
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="row main_row"> <div class="row main_row">
<div class="col"> <div class="col">
{% if not hide_vote_buttons %} {% if not hide_vote_buttons -%}
<div class="voting_buttons" aria-hidden="true"> <div class="voting_buttons" aria-hidden="true">
{% include "post/_post_voting_buttons.html" %} {% include "post/_post_voting_buttons.html" -%}
</div> </div>
{% endif %} {% endif -%}
{% if post.image_id %} {% if post.image_id -%}
<div class="thumbnail{{ ' lbw' if low_bandwidth }}" aria-hidden="true"> <div class="thumbnail{{ ' lbw' if low_bandwidth }}" aria-hidden="true">
{% if low_bandwidth %} {% if low_bandwidth -%}
{% if post.type == POST_TYPE_LINK or post.type == POST_TYPE_VIDEO %} {% if post.type == POST_TYPE_LINK or post.type == POST_TYPE_VIDEO -%}
<a href="{{ post.url }}" rel="nofollow ugc" target="_blank" aria-label="{{ _('Follow link') }}"><span class="fe fe-external"></span></a> <a href="{{ post.url }}" rel="nofollow ugc" target="_blank" aria-label="{{ _('Follow link') }}"><span class="fe fe-external"></span></a>
{% elif post.type == POST_TYPE_IMAGE %} {% elif post.type == POST_TYPE_IMAGE -%}
<a href="{{ post.image.view_url() }}" rel="nofollow ugc" aria-label="{{ _('View image') }}" target="_blank"><span class="fe fe-magnify"></span></a> <a href="{{ post.image.view_url() }}" rel="nofollow ugc" aria-label="{{ _('View image') }}" target="_blank"><span class="fe fe-magnify"></span></a>
{% else %} {% else -%}
<a href="{{ url_for('activitypub.post_ap', post_id=post.id) }}" aria-label="{{ _('Read post') }}"><span class="fe fe-reply"></span></a> <a href="{{ url_for('activitypub.post_ap', post_id=post.id) }}" aria-label="{{ _('Read post') }}"><span class="fe fe-reply"></span></a>
{% endif %} {% endif -%}
{% else %} {% else -%}
{% if post.type == POST_TYPE_VIDEO %} {% if post.type == POST_TYPE_VIDEO -%}
<a href="{{ url_for('activitypub.post_ap', post_id=post.id, sort='new' if sort == 'active' else None, autoplay='true') }}" rel="nofollow ugc" aria-label="{{ _('Read article') }}"><span class="fe fe-video"></span><img src="{{ post.image.thumbnail_url() }}" <a href="{{ url_for('activitypub.post_ap', post_id=post.id, sort='new' if sort == 'active' else None, autoplay='true') }}" rel="nofollow ugc" aria-label="{{ _('Read article') }}"><span class="fe fe-video"></span><img src="{{ post.image.thumbnail_url() }}"
alt="{{ post.image.alt_text if post.image.alt_text else '' }}" loading="lazy" class="{{ 'blur' if (post.nsfw and not post.community.nsfw) or (post.nsfl and not post.community.nsfl) }}" /></a> alt="{{ post.image.alt_text if post.image.alt_text else '' }}" loading="lazy" class="{{ 'blur' if (post.nsfw and not post.community.nsfw) or (post.nsfl and not post.community.nsfl) }}" /></a>
{% elif post.type == POST_TYPE_LINK %} {% elif post.type == POST_TYPE_LINK -%}
<a href="{{ post.url }}" rel="nofollow ugc" target="_blank" aria-label="{{ _('Read article') }}"><span class="fe fe-external"></span><img src="{{ post.image.thumbnail_url() }}" <a href="{{ post.url }}" rel="nofollow ugc" target="_blank" aria-label="{{ _('Read article') }}"><span class="fe fe-external"></span><img src="{{ post.image.thumbnail_url() }}"
alt="{{ post.image.alt_text if post.image.alt_text else '' }}" loading="lazy" class="{{ 'blur' if (post.nsfw and not post.community.nsfw) or (post.nsfl and not post.community.nsfl) }}" /></a> alt="{{ post.image.alt_text if post.image.alt_text else '' }}" loading="lazy" class="{{ 'blur' if (post.nsfw and not post.community.nsfw) or (post.nsfl and not post.community.nsfl) }}" /></a>
{% elif post.type == POST_TYPE_IMAGE %} {% elif post.type == POST_TYPE_IMAGE -%}
{% if post.image_id %} {% if post.image_id -%}
<a href="{{ post.image.view_url() }}" rel="nofollow ugc" aria-label="{{ _('View image') }}" target="_blank"><span class="fe fe-magnify"></span><img src="{{ post.image.thumbnail_url() }}" <a href="{{ post.image.view_url() }}" rel="nofollow ugc" aria-label="{{ _('View image') }}" target="_blank"><span class="fe fe-magnify"></span><img src="{{ post.image.thumbnail_url() }}"
alt="{{ post.image.alt_text if post.image.alt_text else '' }}" loading="lazy" class="{{ 'blur' if (post.nsfw and not post.community.nsfw) or (post.nsfl and not post.community.nsfl) }}" /></a> alt="{{ post.image.alt_text if post.image.alt_text else '' }}" loading="lazy" class="{{ 'blur' if (post.nsfw and not post.community.nsfw) or (post.nsfl and not post.community.nsfl) }}" /></a>
{% endif %} {% endif -%}
{% else %} {% else -%}
<a href="{{ url_for('activitypub.post_ap', post_id=post.id) }}" aria-label="{{ _('Read post') }}"><span class="fe fe-reply"></span><img src="{{ post.image.thumbnail_url() }}" <a href="{{ url_for('activitypub.post_ap', post_id=post.id) }}" aria-label="{{ _('Read post') }}"><span class="fe fe-reply"></span><img src="{{ post.image.thumbnail_url() }}"
alt="{{ post.image.alt_text if post.image.alt_text else '' }}" loading="lazy" class="{{ 'blur' if (post.nsfw and not post.community.nsfw) or (post.nsfl and not post.community.nsfl) }}" /></a> alt="{{ post.image.alt_text if post.image.alt_text else '' }}" loading="lazy" class="{{ 'blur' if (post.nsfw and not post.community.nsfw) or (post.nsfl and not post.community.nsfl) }}" /></a>
{% endif %} {% endif -%}
{% endif %} {% endif -%}
</div> </div>
{% else %} {% else -%}
{% if (post.type == POST_TYPE_LINK or post.type == POST_TYPE_VIDEO) and post.domain_id %} {% if (post.type == POST_TYPE_LINK or post.type == POST_TYPE_VIDEO) and post.domain_id -%}
<div class="thumbnail{{ ' lbw' if low_bandwidth }} missing_thumbnail" aria-hidden="true"> <div class="thumbnail{{ ' lbw' if low_bandwidth }} missing_thumbnail" aria-hidden="true">
<a href="{{ post.url }}" rel="nofollow ugc" target="_blank" aria-label="{{ _('Read article') }}"><span class="fe fe-external"></span></a> <a href="{{ post.url }}" rel="nofollow ugc" target="_blank" aria-label="{{ _('Read article') }}"><span class="fe fe-external"></span></a>
</div> </div>
{% endif %} {% endif -%}
{% endif %} {% endif -%}
<h3>{% if post.sticky %}<span class="fe fe-sticky-left"></span>{% endif %}<a href="{{ url_for('activitypub.post_ap', post_id=post.id, sort='new' if sort == 'active' else None) }}" class="post_teaser_title_a">{{ post.title }}</a> <h3>{% if post.sticky -%}<span class="fe fe-sticky-left"></span>{% endif -%}<a href="{{ url_for('activitypub.post_ap', post_id=post.id, sort='new' if sort == 'active' else None) }}" class="post_teaser_title_a">{{ post.title }}</a>
{% if post.type == POST_TYPE_IMAGE %}<span class="fe fe-image" aria-hidden="true"> </span> {% if post.type == POST_TYPE_IMAGE -%}<span class="fe fe-image" aria-hidden="true"> </span>
{% elif post.type == POST_TYPE_POLL %}<span class="fe fe-poll" aria-hidden="true"> </span> {% elif post.type == POST_TYPE_POLL -%}<span class="fe fe-poll" aria-hidden="true"> </span>
{% elif (post.type == POST_TYPE_LINK or post.type == POST_TYPE_VIDEO) and post.domain_id %} {% elif (post.type == POST_TYPE_LINK or post.type == POST_TYPE_VIDEO) and post.domain_id -%}
{% if post.url and (post.type == POST_TYPE_VIDEO or 'youtube.com' in post.url) %} {% if post.url and (post.type == POST_TYPE_VIDEO or 'youtube.com' in post.url) -%}
<span class="fe fe-video" aria-hidden="true"></span> <span class="fe fe-video" aria-hidden="true"></span>
{% elif post.url.endswith('.mp3') %} {% elif post.url.endswith('.mp3') -%}
<span class="fe fe-audio" aria-hidden="true"></span> <span class="fe fe-audio" aria-hidden="true"></span>
{% endif %} {% endif -%}
<span class="domain_link" aria-hidden="true">(<a href="/d/{{ post.domain_id }}" aria-label="{{ _('All posts about this domain') }}">{{ post.domain.name }}</a>)</span> <span class="domain_link" aria-hidden="true">(<a href="/d/{{ post.domain_id }}" aria-label="{{ _('All posts about this domain') }}">{{ post.domain.name }}</a>)</span>
{% endif %} {% endif -%}
{% if post.nsfw %}<span class="warning_badge nsfw" title="{{ _('Not safe for work') }}">nsfw</span>{% endif %} {% if post.nsfw -%}<span class="warning_badge nsfw" title="{{ _('Not safe for work') }}">nsfw</span>{% endif -%}
{% if post.nsfl %}<span class="warning_badge nsfl" title="{{ _('Potentially emotionally scarring content') }}">nsfl</span>{% endif %} {% if post.nsfl -%}<span class="warning_badge nsfl" title="{{ _('Potentially emotionally scarring content') }}">nsfl</span>{% endif -%}
{% if post.reports > 0 and current_user.is_authenticated and post.community.is_moderator(current_user) %} {% if post.reports > 0 and current_user.is_authenticated and post.community.is_moderator(current_user) -%}
<span class="red fe fe-report" title="{{ _('Reported. Check post for issues.') }}"></span> <span class="red fe fe-report" title="{{ _('Reported. Check post for issues.') }}"></span>
{% endif %} {% endif -%}
{% if post.sticky %}<span class="fe fe-sticky-right"></span>{% endif %} {% if post.sticky -%}<span class="fe fe-sticky-right"></span>{% endif -%}
</h3> </h3>
<span class="author small">{% if show_post_community %}<a href="/c/{{ post.community.link() }}" aria-label="{{ _('Go to community %(name)s', name=post.community.name) }}">c/{{ post.community.name }}</a>{% endif %} <span class="author small">{% if show_post_community -%}<a href="/c/{{ post.community.link() }}" aria-label="{{ _('Go to community %(name)s', name=post.community.name) }}">c/{{ post.community.name }}</a>{% endif -%}
by {{ render_username(post.author) }} {{ moment(post.last_active if sort == 'active' else post.posted_at).fromNow() }}</span> by {{ render_username(post.author) }} {{ moment(post.last_active if sort == 'active' else post.posted_at).fromNow() }}</span>
<div class="post_utilities"> <div class="post_utilities">
<a href="{{ url_for('activitypub.post_ap', post_id=post.id, sort='new' if sort == 'active' else None, _anchor='post_replies') }}" aria-label="{{ _('View comments') }}"><span class="fe fe-reply"></span> <span aria-label="{{ _('Number of comments:') }}">{{ post.reply_count }}</span></a> <a href="{{ url_for('activitypub.post_ap', post_id=post.id, sort='new' if sort == 'active' else None, _anchor='post_replies') }}" aria-label="{{ _('View comments') }}"><span class="fe fe-reply"></span> <span aria-label="{{ _('Number of comments:') }}">{{ post.reply_count }}</span></a>
{% if post.type == POST_TYPE_IMAGE %} {% if post.type == POST_TYPE_IMAGE -%}
{% if post.image_id %} {% if post.image_id -%}
<a href="{{ post.image.view_url() }}" rel="nofollow ugc" class="preview_image" aria-label="{{ _('View image') }}" aria-hidden="true"><span class="fe fe-magnify"></span></a> <a href="{{ post.image.view_url() }}" rel="nofollow ugc" class="preview_image" aria-label="{{ _('View image') }}" aria-hidden="true"><span class="fe fe-magnify"></span></a>
{% else %} {% else -%}
<a href="{{ post.url }}" rel="nofollow ugc" class="preview_image" target="_blank" aria-label="{{ _('View image') }}" aria-hidden="true"><span class="fe fe-magnify"></span></a> <a href="{{ post.url }}" rel="nofollow ugc" class="preview_image" target="_blank" aria-label="{{ _('View image') }}" aria-hidden="true"><span class="fe fe-magnify"></span></a>
{% endif %} {% endif -%}
{% endif %} {% endif -%}
<a href="{{ url_for('post.post_options', post_id=post.id) }}" rel="nofollow" class="post_options" aria-label="{{ _('Options') }}"><span class="fe fe-options" title="Options"> </span></a> <a href="{{ url_for('post.post_options', post_id=post.id) }}" rel="nofollow" class="post_options" aria-label="{{ _('Options') }}"><span class="fe fe-options" title="Options"> </span></a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{% endif %} {% endif -%}

View file

@ -1,21 +1,21 @@
{% if current_user.is_authenticated and current_user.verified %} {% if current_user.is_authenticated and current_user.verified -%}
{% if can_upvote(current_user, post.community) %} {% if can_upvote(current_user, post.community) -%}
<div class="upvote_button {{ 'voted_up' if in_sorted_list(recently_upvoted, post.id) }}" role="button" aria-label="{{ _('UpVote button, %(count)d upvotes so far.', count=post.up_votes) }}" aria-live="assertive" <div class="upvote_button {{ 'voted_up' if in_sorted_list(recently_upvoted, post.id) }}" role="button" aria-label="{{ _('UpVote button, %(count)d upvotes so far.', count=post.up_votes) }}" aria-live="assertive"
hx-post="/post/{{ post.id }}/upvote" hx-trigger="click throttle:1s" hx-target="closest .voting_buttons" tabindex="0"> hx-post="/post/{{ post.id }}/upvote" hx-trigger="click throttle:1s" hx-target="closest .voting_buttons" tabindex="0">
<span class="fe fe-arrow-up"></span> <span class="fe fe-arrow-up"></span>
{{ shorten_number(post.up_votes) }} {{ shorten_number(post.up_votes) }}
<img class="htmx-indicator" src="/static/images/spinner.svg" alt="" style="opacity: 0;"> <img class="htmx-indicator" src="/static/images/spinner.svg" alt="" style="opacity: 0;">
</div> </div>
{% endif %} {% endif -%}
{% if can_downvote(current_user, post.community) %} {% if can_downvote(current_user, post.community) -%}
<div class="downvote_button {{ 'voted_down' if in_sorted_list(recently_downvoted, post.id) }}" role="button" aria-label="{{ _('DownVote button, %(count)d downvotes so far.', count=post.down_votes) }}" aria-live="assertive" <div class="downvote_button {{ 'voted_down' if in_sorted_list(recently_downvoted, post.id) }}" role="button" aria-label="{{ _('DownVote button, %(count)d downvotes so far.', count=post.down_votes) }}" aria-live="assertive"
hx-post="/post/{{ post.id }}/downvote" hx-trigger="click throttle:1s" hx-target="closest .voting_buttons" tabindex="0"> hx-post="/post/{{ post.id }}/downvote" hx-trigger="click throttle:1s" hx-target="closest .voting_buttons" tabindex="0">
<span class="fe fe-arrow-down"></span> <span class="fe fe-arrow-down"></span>
{{ shorten_number(post.down_votes) }} {{ shorten_number(post.down_votes) }}
<img class="htmx-indicator" src="/static/images/spinner.svg" alt="" style="opacity: 0;"> <img class="htmx-indicator" src="/static/images/spinner.svg" alt="" style="opacity: 0;">
</div> </div>
{% endif %} {% endif -%}
{% else %} {% else -%}
<div class="upvote_button digits_{{ digits(post.up_votes) }} {{ upvoted_class }} redirect_login"> <div class="upvote_button digits_{{ digits(post.up_votes) }} {{ upvoted_class }} redirect_login">
<span class="fe fe-arrow-up"></span> <span class="fe fe-arrow-up"></span>
{{ shorten_number(post.up_votes) }} {{ shorten_number(post.up_votes) }}
@ -24,4 +24,4 @@
<span class="fe fe-arrow-down"></span> <span class="fe fe-arrow-down"></span>
{{ shorten_number(post.down_votes) }} {{ shorten_number(post.down_votes) }}
</div> </div>
{% endif %} {% endif -%}

View file

@ -1,33 +1,33 @@
{% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') %} {% if theme() and file_exists('app/templates/themes/' + theme() + '/base.html') -%}
{% extends 'themes/' + theme() + '/base.html' %} {% extends 'themes/' + theme() + '/base.html' -%}
{% else %} {% else -%}
{% extends "base.html" %} {% extends "base.html" -%}
{% endif %} %} {% endif -%} -%}
{% from 'bootstrap/form.html' import render_form %} {% from 'bootstrap/form.html' import render_form -%}
{% block app_content %} {% block app_content -%}
<script type="text/javascript" nonce="{{ session['nonce'] }}"> <script type="text/javascript" nonce="{{ session['nonce'] }}">
var toBeHidden = Array(); // this list of comment IDs will be iterated over in setupHideButtons() and the 'hide' button clicked var toBeHidden = Array(); // this list of comment IDs will be iterated over in setupHideButtons() and the 'hide' button clicked
</script> </script>
<div class="row"> <div class="row">
<div class="col-12 col-md-8 position-relative main_pane"> <div class="col-12 col-md-8 position-relative main_pane">
{% include 'post/_post_full.html' %} {% include 'post/_post_full.html' -%}
{% if post.comments_enabled %} {% if post.comments_enabled -%}
{% if current_user.is_authenticated %} {% if current_user.is_authenticated -%}
{% if current_user.verified %} {% if current_user.verified -%}
<div class="row post_reply_form"> <div class="row post_reply_form">
<hr class="mt-1" /> <hr class="mt-1" />
<div class="col"> <div class="col">
<div class="reply_form_inner position-relative"> <div class="reply_form_inner position-relative">
{% if post.community.ap_id and '@beehaw.org' in post.community.ap_id %} {% if post.community.ap_id and '@beehaw.org' in post.community.ap_id -%}
<p>{{ _('This post is hosted on beehaw.org which has <a href="https://docs.beehaw.org/docs/core-principles/what-is-beehaw/" target="_blank" rel="nofollow">higher standards of behaviour than most places. Be nice</a>.') }}</p> <p>{{ _('This post is hosted on beehaw.org which has <a href="https://docs.beehaw.org/docs/core-principles/what-is-beehaw/" target="_blank" rel="nofollow">higher standards of behaviour than most places. Be nice</a>.') }}</p>
{% endif %} {% endif -%}
{% if post.community.posting_warning %} {% if post.community.posting_warning -%}
<p align="center">{{ post.community.posting_warning|safe }}</p> <p align="center">{{ post.community.posting_warning|safe }}</p>
{% endif %} {% endif -%}
{{ render_form(form) }} {{ render_form(form) }}
{% 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({
@ -38,26 +38,26 @@
setupAutoResize('body'); setupAutoResize('body');
}); });
</script> </script>
{% else %} {% else -%}
<!-- <a href="#" aria-hidden="true" id="post_reply_markdown_editor_enabler" class="markdown_editor_enabler" data-id="body">{{ _('Enable markdown editor') }}</a> --> <!-- <a href="#" aria-hidden="true" id="post_reply_markdown_editor_enabler" class="markdown_editor_enabler" data-id="body">{{ _('Enable markdown editor') }}</a> -->
{% endif %} {% endif -%}
{% endif %} {% endif -%}
</div> </div>
</div> </div>
{% if replies %} {% if replies -%}
<hr class="mt-4" /> <hr class="mt-4" />
{% endif %} {% endif -%}
</div> </div>
{% else %} {% else -%}
<p><a href="{{ url_for('auth.validation_required') }}">{{ _('Verify your email address to comment') }}</a></p> <p><a href="{{ url_for('auth.validation_required') }}">{{ _('Verify your email address to comment') }}</a></p>
{% endif %} {% endif -%}
{% else %} {% else -%}
<p><a href="{{ url_for('auth.login', next='/post/' + str(post.id)) }}">{{ _('Log in to comment') }}</a></p> <p><a href="{{ url_for('auth.login', next='/post/' + str(post.id)) }}">{{ _('Log in to comment') }}</a></p>
{% endif %} {% endif -%}
{% else %} {% else -%}
<p>{{ _('Comments are disabled.') }}</p> <p>{{ _('Comments are disabled.') }}</p>
{% endif %} {% endif -%}
{% if replies %} {% if replies -%}
<h2 class="visually-hidden">{{ post.reply_count }} {{ _('Comments') }}</h2> <h2 class="visually-hidden">{{ post.reply_count }} {{ _('Comments') }}</h2>
<div id="post_replies" class="row"> <div id="post_replies" class="row">
<div class="col"> <div class="col">
@ -72,114 +72,114 @@
{{ _('New') }} {{ _('New') }}
</a> </a>
</div> </div>
{% macro render_comment(comment) %} {% macro render_comment(comment) -%}
<div id="comment_{{ comment['comment'].id }}" class="comment {% if comment['comment'].score <= -10 %}low_score{% endif %} <div id="comment_{{ comment['comment'].id }}" class="comment {% if comment['comment'].score <= -10 -%}low_score{% endif -%}
{% if comment['comment'].author.id == post.author.id %}original_poster{% endif %}" aria-level="{{ comment['comment'].depth + 1 }}" role="treeitem" aria-expanded="true" tabindex="0"> {% if comment['comment'].author.id == post.author.id -%}original_poster{% endif -%}" aria-level="{{ comment['comment'].depth + 1 }}" role="treeitem" aria-expanded="true" tabindex="0">
<div class="limit_height">{% if not comment['comment'].author.indexable %}<!--googleoff: all-->{% endif %} <div class="limit_height">{% if not comment['comment'].author.indexable -%}<!--googleoff: all-->{% endif -%}
<div class="comment_author"> <div class="comment_author">
{% if comment['comment'].author.deleted %} {% if comment['comment'].author.deleted -%}
[deleted] [deleted]
{% else %} {% else -%}
{% if comment['comment'].author.avatar_id and comment['comment'].score > -10 and not low_bandwidth %} {% if comment['comment'].author.avatar_id and comment['comment'].score > -10 and not low_bandwidth -%}
<a href="/u/{{ comment['comment'].author.link() }}" title="{{ comment['comment'].author.ap_id }}"> <a href="/u/{{ comment['comment'].author.link() }}" title="{{ comment['comment'].author.ap_id }}">
<img src="{{ comment['comment'].author.avatar_thumbnail() }}" alt="" loading="lazy" /></a> <img src="{{ comment['comment'].author.avatar_thumbnail() }}" alt="" loading="lazy" /></a>
{% endif %} {% endif -%}
<a href="/u/{{ comment['comment'].author.link() }}" title="{{ comment['comment'].author.link() }}" aria-label="{{ _('Author') }}"> <a href="/u/{{ comment['comment'].author.link() }}" title="{{ comment['comment'].author.link() }}" aria-label="{{ _('Author') }}">
{{ comment['comment'].author.display_name() }}</a> {{ comment['comment'].author.display_name() }}</a>
{% endif %} {% endif -%}
{% if comment['comment'].author.created_recently() %} {% if comment['comment'].author.created_recently() -%}
<span class="fe fe-new-account small" title="New account"> </span> <span class="fe fe-new-account small" title="New account"> </span>
{% endif %} {% endif -%}
{% if comment['comment'].author.bot %} {% if comment['comment'].author.bot -%}
<span class="fe fe-bot-account small" title="Bot account"> </span> <span class="fe fe-bot-account small" title="Bot account"> </span>
{% endif %} {% endif -%}
{% if comment['comment'].author.id != current_user.id %} {% if comment['comment'].author.id != current_user.id -%}
{% if comment['comment'].author.reputation < -10 %} {% if comment['comment'].author.reputation < -10 -%}
<span class="fe fe-warning red" title="Very low reputation. Beware."> </span> <span class="fe fe-warning red" title="Very low reputation. Beware."> </span>
<span class="fe fe-warning red" title="Very low reputation. Beware!"> </span> <span class="fe fe-warning red" title="Very low reputation. Beware!"> </span>
{% elif comment['comment'].author.reputation < 0 %} {% elif comment['comment'].author.reputation < 0 -%}
<span class="fe fe-warning orangered" title="Low reputation."> </span> <span class="fe fe-warning orangered" title="Low reputation."> </span>
{% endif %} {% endif -%}
{% endif %} {% endif -%}
{% if comment['comment'].author.id == post.author.id %}<span title="Submitter of original post" aria-label="{{ _('Post creator') }}" class="small">[OP]</span>{% endif %} {% if comment['comment'].author.id == post.author.id -%}<span title="Submitter of original post" aria-label="{{ _('Post creator') }}" class="small">[OP]</span>{% endif -%}
<span class="text-muted small" aria_label="{{ _('When: ') }}">{{ moment(comment['comment'].posted_at).fromNow(refresh=True) }}{% if comment['comment'].edited_at %}, edited {{ moment(comment['comment'].edited_at).fromNow(refresh=True) }} {% endif %}</span> <span class="text-muted small" aria_label="{{ _('When: ') }}">{{ moment(comment['comment'].posted_at).fromNow(refresh=True) }}{% if comment['comment'].edited_at -%}, edited {{ moment(comment['comment'].edited_at).fromNow(refresh=True) }} {% endif -%}</span>
<a class="unhide" href="#"><span class="fe fe-expand"></span></a> <a class="unhide" href="#"><span class="fe fe-expand"></span></a>
{% if comment['comment'].reports and current_user.is_authenticated and post.community.is_moderator(current_user)%} {% if comment['comment'].reports and current_user.is_authenticated and post.community.is_moderator(current_user)%}
<span class="red fe fe-report" title="{{ _('Reported. Check comment for issues.') }}"></span> <span class="red fe fe-report" title="{{ _('Reported. Check comment for issues.') }}"></span>
{% endif %} {% endif -%}
</div> </div>
<div class="comment_body hidable {% if comment['comment'].reports and current_user.is_authenticated and post.community.is_moderator(current_user) %}reported{% endif %}"> <div class="comment_body hidable {% if comment['comment'].reports and current_user.is_authenticated and post.community.is_moderator(current_user) -%}reported{% endif -%}">
{{ comment['comment'].body_html | community_links | safe }} {{ comment['comment'].body_html | community_links | safe }}
</div>{% if not comment['comment'].author.indexable %}<!--googleon: all-->{% endif %} </div>{% if not comment['comment'].author.indexable -%}<!--googleon: all-->{% endif -%}
</div> </div>
<div class="comment_actions hidable"> <div class="comment_actions hidable">
{% if post.comments_enabled %} {% if post.comments_enabled -%}
<a href="{{ url_for('post.add_reply', post_id=post.id, comment_id=comment['comment'].id) }}" rel="nofollow noindex"><span class="fe fe-reply"></span> reply</a> <a href="{{ url_for('post.add_reply', post_id=post.id, comment_id=comment['comment'].id) }}" rel="nofollow noindex"><span class="fe fe-reply"></span> reply</a>
{% endif %} {% endif -%}
<div class="voting_buttons_new"> <div class="voting_buttons_new">
{% with comment=comment['comment'] %} {% with comment=comment['comment'] -%}
{% include "post/_comment_voting_buttons.html" %} {% include "post/_comment_voting_buttons.html" -%}
{% endwith %} {% endwith -%}
</div> </div>
<div class="hide_button"> <div class="hide_button">
{% if comment['comment'].score <= -10 %} {% if comment['comment'].score <= -10 -%}
<a href='#'><span class="fe fe-expand"></span></a> <a href='#'><span class="fe fe-expand"></span></a>
{% else %} {% else -%}
<a href='#'><span class="fe fe-collapse"></span></a> <a href='#'><span class="fe fe-collapse"></span></a>
{% endif %} {% endif -%}
</div> </div>
{% if current_user.is_authenticated and current_user.verified %} {% if current_user.is_authenticated and current_user.verified -%}
{% include "post/_reply_notification_toggle.html" %} {% include "post/_reply_notification_toggle.html" -%}
{% endif %} {% endif -%}
<a href="{{ url_for('post.post_reply_options', post_id=post.id, comment_id=comment['comment'].id) }}" class="comment_actions_link" rel="nofollow noindex" aria-label="{{ _('Comment options') }}"><span class="fe fe-options" title="Options"> </span></a> <a href="{{ url_for('post.post_reply_options', post_id=post.id, comment_id=comment['comment'].id) }}" class="comment_actions_link" rel="nofollow noindex" aria-label="{{ _('Comment options') }}"><span class="fe fe-options" title="Options"> </span></a>
</div> </div>
{% if comment['replies'] %} {% if comment['replies'] -%}
{% if comment['comment'].depth <= THREAD_CUTOFF_DEPTH %} {% if comment['comment'].depth <= THREAD_CUTOFF_DEPTH -%}
<div class="replies hidable" role="group"> <div class="replies hidable" role="group">
{% for reply in comment['replies'] %} {% for reply in comment['replies'] -%}
{{ render_comment(reply) | safe }} {{ render_comment(reply) | safe }}
{% endfor %} {% endfor -%}
</div> </div>
{% else %} {% else -%}
<div class="continue_thread hidable"> <div class="continue_thread hidable">
<a href="{{ url_for('post.continue_discussion', post_id=post.id, comment_id=comment['comment'].id, _anchor='replies') }}"> <a href="{{ url_for('post.continue_discussion', post_id=post.id, comment_id=comment['comment'].id, _anchor='replies') }}">
Continue thread</a> Continue thread</a>
</div> </div>
{% endif %} {% endif -%}
{% endif %} {% endif -%}
</div> </div>
{% if comment['comment'].score <= -10 %} {% if comment['comment'].score <= -10 -%}
<script nonce="{{ session['nonce'] }}" type="text/javascript"> <script nonce="{{ session['nonce'] }}" type="text/javascript">
toBeHidden.push({{ comment['comment'].id }}); toBeHidden.push({{ comment['comment'].id }});
</script> </script>
{% endif %} {% endif -%}
{% endmacro %} {% endmacro -%}
<div id="replies" class="comments" role="tree" aria-label="{{ _('Comments') }}" aria-expanded="true"> <div id="replies" class="comments" role="tree" aria-label="{{ _('Comments') }}" aria-expanded="true">
{% for reply in replies %} {% for reply in replies -%}
{{ render_comment(reply) | safe }} {{ render_comment(reply) | safe }}
{% endfor %} {% endfor -%}
</div> </div>
</div> </div>
</div> </div>
{% endif %} {% endif -%}
</div> </div>
<aside id="side_pane" class="col-12 col-md-4 side_pane" role="complementary"> <aside id="side_pane" class="col-12 col-md-4 side_pane" role="complementary">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<div class="row"> <div class="row">
{% if not community.restricted_to_mods or (community.restricted_to_mods and current_user.is_authenticated and community_membership(current_user, community) in [SUBSCRIPTION_MODERATOR, SUBSCRIPTION_OWNER]) %} {% if not community.restricted_to_mods or (community.restricted_to_mods and current_user.is_authenticated and community_membership(current_user, community) in [SUBSCRIPTION_MODERATOR, SUBSCRIPTION_OWNER]) -%}
<div class="col-6"> <div class="col-6">
<a class="w-100 btn btn-primary" href="/community/{{ post.community.link() }}/submit">{{ _('Create post') }}</a> <a class="w-100 btn btn-primary" href="/community/{{ post.community.link() }}/submit">{{ _('Create post') }}</a>
</div> </div>
{% endif %} {% endif -%}
<div class="col-6"> <div class="col-6">
{% if current_user.is_authenticated and community_membership(current_user, post.community) >= SUBSCRIPTION_MEMBER %} {% if current_user.is_authenticated and community_membership(current_user, post.community) >= SUBSCRIPTION_MEMBER -%}
<a class="w-100 btn btn-primary" href="/community/{{ post.community.link() }}/unsubscribe" rel="nofollow">{{ _('Leave') }}</a> <a class="w-100 btn btn-primary" href="/community/{{ post.community.link() }}/unsubscribe" rel="nofollow">{{ _('Leave') }}</a>
{% else %} {% else -%}
<a class="w-100 btn btn-primary" href="/community/{{ post.community.link() }}/subscribe" rel="nofollow">{{ _('Join') }}</a> <a class="w-100 btn btn-primary" href="/community/{{ post.community.link() }}/subscribe" rel="nofollow">{{ _('Join') }}</a>
{% endif %} {% endif -%}
</div> </div>
</div> </div>
<form method="get" action="/search"> <form method="get" action="/search">
@ -195,54 +195,54 @@
<div class="card-body"> <div class="card-body">
<p>{{ post.community.description_html|safe if post.community.description_html else '' }}</p> <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> <p>{{ post.community.rules_html|safe if post.community.rules_html else '' }}</p>
{% if len(mods) > 0 and not post.community.private_mods %} {% if len(mods) > 0 and not post.community.private_mods -%}
<h3>Moderators</h3> <h3>Moderators</h3>
<ul class="moderator_list"> <ul class="moderator_list">
{% for mod in mods %} {% for mod in mods -%}
<li><a href="/u/{{ mod.link() }}">{{ mod.display_name() }}</a></li> <li><a href="/u/{{ mod.link() }}">{{ mod.display_name() }}</a></li>
{% endfor %} {% endfor -%}
</ul> </ul>
{% endif %} {% endif -%}
</div> </div>
</div> </div>
{% if related_communities %} {% if related_communities -%}
<div class="card mt-3"> <div class="card mt-3">
<div class="card-header"> <div class="card-header">
<h2>{{ _('Related communities') }}</h2> <h2>{{ _('Related communities') }}</h2>
</div> </div>
<div class="card-body"> <div class="card-body">
<ul class="list-group list-group-flush"> <ul class="list-group list-group-flush">
{% for community in related_communities %} {% for community in related_communities -%}
<li class="list-group-item"> <li class="list-group-item">
<a href="/c/{{ community.link() }}" aria-label="{{ _('Go to community') }}"><img src="{{ community.icon_image() }}" class="community_icon rounded-circle" loading="lazy" alt="" /> <a href="/c/{{ community.link() }}" aria-label="{{ _('Go to community') }}"><img src="{{ community.icon_image() }}" class="community_icon rounded-circle" loading="lazy" alt="" />
{{ community.display_name() }} {{ community.display_name() }}
</a> </a>
</li> </li>
{% endfor %} {% endfor -%}
</ul> </ul>
<p class="mt-4"><a class="btn btn-primary" href="/communities">{{ _('Explore communities') }}</a></p> <p class="mt-4"><a class="btn btn-primary" href="/communities">{{ _('Explore communities') }}</a></p>
</div> </div>
</div> </div>
{% endif %} {% endif -%}
{% if is_moderator %} {% if is_moderator -%}
<div class="card mt-3"> <div class="card mt-3">
<div class="card-header"> <div class="card-header">
<h2>{{ _('Community Settings') }}</h2> <h2>{{ _('Community Settings') }}</h2>
</div> </div>
<div class="card-body"> <div class="card-body">
{% if is_moderator or is_owner or is_admin %} {% if is_moderator or is_owner or is_admin -%}
<p><a href="/community/{{ community.link() }}/moderate" class="btn btn-primary">{{ _('Moderate') }}</a></p> <p><a href="/community/{{ community.link() }}/moderate" class="btn btn-primary">{{ _('Moderate') }}</a></p>
{% endif %} {% endif -%}
{% if is_owner or is_admin %} {% if is_owner or is_admin -%}
<p><a href="{{ url_for('community.community_edit', community_id=community.id) }}" class="btn btn-primary">{{ _('Settings') }}</a></p> <p><a href="{{ url_for('community.community_edit', community_id=community.id) }}" class="btn btn-primary">{{ _('Settings') }}</a></p>
{% endif %} {% endif -%}
{% if community.is_local() and (community.is_owner() or current_user.is_admin()) %} {% if community.is_local() and (community.is_owner() or current_user.is_admin()) -%}
<p><a class="btn btn-primary btn-warning" href="{{ url_for('community.community_delete', community_id=community.id) }}" rel="nofollow">Delete community</a></p> <p><a class="btn btn-primary btn-warning" href="{{ url_for('community.community_delete', community_id=community.id) }}" rel="nofollow">Delete community</a></p>
{% endif %} {% endif -%}
</div> </div>
</div> </div>
{% endif %} {% endif -%}
{% include "_inoculation_links.html" %} {% include "_inoculation_links.html" -%}
</aside> </aside>
</div> </div>
<script nonce="{{ session['nonce'] }}"> <script nonce="{{ session['nonce'] }}">
@ -250,4 +250,4 @@
currentPost = document.querySelector('.post_col'); // set the current post, so A and Z voting keys work when viewing a post page currentPost = document.querySelector('.post_col'); // set the current post, so A and Z voting keys work when viewing a post page
}); });
</script> </script>
{% endblock %} {% endblock -%}

View file

@ -19,7 +19,7 @@ from app import db, celery, cache
from app.topic.forms import ChooseTopicsForm from app.topic.forms import ChooseTopicsForm
from app.utils import render_template, user_filters_posts, moderating_communities, joined_communities, \ from app.utils import render_template, user_filters_posts, moderating_communities, joined_communities, \
community_membership, blocked_domains, validation_required, mimetype_from_url, blocked_instances, \ community_membership, blocked_domains, validation_required, mimetype_from_url, blocked_instances, \
communities_banned_from, blocked_users communities_banned_from, blocked_users, menu_topics
@bp.route('/topic/<path:topic_path>', methods=['GET']) @bp.route('/topic/<path:topic_path>', methods=['GET'])
@ -118,6 +118,7 @@ def show_topic(topic_path):
rss_feed_name=f"{current_topic.name} on {g.site.name}", rss_feed_name=f"{current_topic.name} on {g.site.name}",
show_post_community=True, moderating_communities=moderating_communities(current_user.get_id()), show_post_community=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()),
menu_topics=menu_topics(),
inoculation=inoculation[randint(0, len(inoculation) - 1)], inoculation=inoculation[randint(0, len(inoculation) - 1)],
POST_TYPE_LINK=POST_TYPE_LINK, POST_TYPE_IMAGE=POST_TYPE_IMAGE, POST_TYPE_LINK=POST_TYPE_LINK, POST_TYPE_IMAGE=POST_TYPE_IMAGE,
POST_TYPE_VIDEO=POST_TYPE_VIDEO, POST_TYPE_VIDEO=POST_TYPE_VIDEO,
@ -190,6 +191,7 @@ def choose_topics():
return render_template('topic/choose_topics.html', form=form, return render_template('topic/choose_topics.html', form=form,
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()),
menu_topics=menu_topics(), site=g.site,
) )

View file

@ -1,7 +1,7 @@
from datetime import datetime, timedelta from datetime import datetime, timedelta
from time import sleep from time import sleep
from flask import redirect, url_for, flash, request, make_response, session, Markup, current_app, abort, json from flask import redirect, url_for, flash, request, make_response, session, Markup, current_app, abort, json, g
from flask_login import login_user, logout_user, current_user, login_required from flask_login import login_user, logout_user, current_user, login_required
from flask_babel import _, lazy_gettext as _l from flask_babel import _, lazy_gettext as _l
@ -23,7 +23,7 @@ from app.user.utils import purge_user_then_delete, unsubscribe_from_community
from app.utils import get_setting, render_template, markdown_to_html, user_access, markdown_to_text, shorten_string, \ from app.utils import get_setting, render_template, markdown_to_html, user_access, markdown_to_text, shorten_string, \
is_image_url, ensure_directory_exists, gibberish, file_get_contents, community_membership, user_filters_home, \ is_image_url, ensure_directory_exists, gibberish, file_get_contents, community_membership, user_filters_home, \
user_filters_posts, user_filters_replies, moderating_communities, joined_communities, theme_list, blocked_instances, \ user_filters_posts, user_filters_replies, moderating_communities, joined_communities, theme_list, blocked_instances, \
allowlist_html, recently_upvoted_posts, recently_downvoted_posts, blocked_users allowlist_html, recently_upvoted_posts, recently_downvoted_posts, blocked_users, menu_topics
from sqlalchemy import desc, or_, text from sqlalchemy import desc, or_, text
import os import os
@ -36,7 +36,9 @@ def show_people():
else: else:
people = User.query.filter_by(ap_id=None, deleted=False, banned=False, searchable=True).all() people = User.query.filter_by(ap_id=None, deleted=False, banned=False, searchable=True).all()
return render_template('user/people.html', people=people, moderating_communities=moderating_communities(current_user.get_id()), return render_template('user/people.html', people=people, moderating_communities=moderating_communities(current_user.get_id()),
joined_communities=joined_communities(current_user.get_id()), title=_('People')) joined_communities=joined_communities(current_user.get_id()),
menu_topics=menu_topics(), site=g.site,
title=_('People'))
@bp.route('/user/<int:user_id>', methods=['GET']) @bp.route('/user/<int:user_id>', methods=['GET'])
@ -93,7 +95,8 @@ def show_profile(user):
replies_next_url=replies_next_url, replies_prev_url=replies_prev_url, replies_next_url=replies_next_url, replies_prev_url=replies_prev_url,
noindex=not user.indexable, show_post_community=True, hide_vote_buttons=True, noindex=not user.indexable, show_post_community=True, hide_vote_buttons=True,
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()),
menu_topics=menu_topics(), site=g.site
) )
@ -170,7 +173,8 @@ def edit_profile(actor):
return render_template('user/edit_profile.html', title=_('Edit profile'), form=form, user=current_user, return render_template('user/edit_profile.html', title=_('Edit profile'), form=form, user=current_user,
markdown_editor=current_user.markdown_editor, markdown_editor=current_user.markdown_editor,
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()),
menu_topics=menu_topics(), site=g.site
) )
@ -275,7 +279,8 @@ def change_settings():
return render_template('user/edit_settings.html', title=_('Edit profile'), form=form, user=current_user, return render_template('user/edit_settings.html', title=_('Edit profile'), form=form, user=current_user,
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()),
menu_topics=menu_topics(), site=g.site
) )
@ -457,7 +462,8 @@ def report_profile(actor):
return render_template('user/user_report.html', title=_('Report user'), form=form, user=user, return render_template('user/user_report.html', title=_('Report user'), form=form, user=user,
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()),
menu_topics = menu_topics(), site=g.site
) )
@ -536,7 +542,8 @@ def delete_account():
return render_template('user/delete_account.html', title=_('Delete my account'), form=form, user=current_user, return render_template('user/delete_account.html', title=_('Delete my account'), form=form, user=current_user,
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()),
menu_topics=menu_topics(), site=g.site
) )
@ -626,7 +633,8 @@ def notifications():
return render_template('user/notifications.html', title=_('Notifications'), notifications=notification_list, user=current_user, return render_template('user/notifications.html', title=_('Notifications'), notifications=notification_list, user=current_user,
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()),
menu_topics=menu_topics(), site=g.site
) )
@ -754,7 +762,8 @@ def user_settings_filters():
blocked_users=blocked_users, blocked_communities=blocked_communities, blocked_users=blocked_users, blocked_communities=blocked_communities,
blocked_domains=blocked_domains, blocked_instances=blocked_instances, blocked_domains=blocked_domains, blocked_instances=blocked_instances,
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()),
menu_topics=menu_topics(), site=g.site
) )
@ -778,7 +787,8 @@ def user_settings_filters_add():
return render_template('user/edit_filters.html', title=_('Add filter'), form=form, user=current_user, return render_template('user/edit_filters.html', title=_('Add filter'), form=form, user=current_user,
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()),
menu_topics=menu_topics(), site=g.site
) )
@ -818,7 +828,8 @@ def user_settings_filters_edit(filter_id):
return render_template('user/edit_filters.html', title=_('Edit filter'), form=form, content_filter=content_filter, user=current_user, return render_template('user/edit_filters.html', title=_('Edit filter'), form=form, content_filter=content_filter, user=current_user,
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()),
menu_topics=menu_topics(), site=g.site
) )

View file

@ -725,6 +725,11 @@ def joined_communities(user_id):
filter(CommunityMember.user_id == user_id).order_by(Community.title).all() filter(CommunityMember.user_id == user_id).order_by(Community.title).all()
@cache.memoize(timeout=3000)
def menu_topics():
return Topic.query.filter(Topic.parent_id == None).order_by(Topic.name).all()
@cache.memoize(timeout=300) @cache.memoize(timeout=300)
def community_moderators(community_id): def community_moderators(community_id):
return CommunityMember.query.filter((CommunityMember.community_id == community_id) & return CommunityMember.query.filter((CommunityMember.community_id == community_id) &