mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
announcements on home page, set in Admin -> Site Profile
This commit is contained in:
parent
a0f9f10a3a
commit
7534822231
8 changed files with 38 additions and 2 deletions
|
@ -18,6 +18,7 @@ class SiteProfileForm(FlaskForm):
|
|||
])
|
||||
sidebar = TextAreaField(_l('Sidebar'))
|
||||
about = TextAreaField(_l('About'))
|
||||
announcement = TextAreaField(_l('Announcement at top of home page'))
|
||||
legal_information = TextAreaField(_l('Legal information'))
|
||||
contact_email = EmailField(_l('General instance contact email address'), validators=[DataRequired(), Length(min=5, max=255)])
|
||||
submit = SubmitField(_l('Save'))
|
||||
|
|
|
@ -54,6 +54,7 @@ def admin_site():
|
|||
if site.id is None:
|
||||
db.session.add(site)
|
||||
db.session.commit()
|
||||
set_setting('announcement', form.announcement.data)
|
||||
flash('Settings saved.')
|
||||
elif request.method == 'GET':
|
||||
form.name.data = site.name
|
||||
|
@ -62,6 +63,7 @@ def admin_site():
|
|||
form.sidebar.data = site.sidebar
|
||||
form.legal_information.data = site.legal_information
|
||||
form.contact_email.data = site.contact_email
|
||||
form.announcement.data = get_setting('announcement', '')
|
||||
return render_template('admin/site.html', title=_('Site profile'), form=form,
|
||||
moderating_communities=moderating_communities(current_user.get_id()),
|
||||
joined_communities=joined_communities(current_user.get_id()),
|
||||
|
|
|
@ -165,6 +165,7 @@ def home_page(type, sort):
|
|||
title=f"{g.site.name} - {g.site.description}",
|
||||
description=shorten_string(markdown_to_text(g.site.sidebar), 150),
|
||||
content_filters=content_filters, type=type, sort=sort,
|
||||
announcement=allowlist_html(get_setting('announcement', '')),
|
||||
moderating_communities=moderating_communities(current_user.get_id()),
|
||||
joined_communities=joined_communities(current_user.get_id()),
|
||||
menu_topics=menu_topics(), site=g.site,
|
||||
|
|
|
@ -795,6 +795,20 @@ div.navbar {
|
|||
display: inline-block;
|
||||
}
|
||||
|
||||
#home_announcement {
|
||||
padding: 0.5rem 1rem;
|
||||
color: var(--bs-card-cap-color);
|
||||
background-color: rgba(var(--bs-body-color-rgb), 0.03);
|
||||
border-bottom: var(--bs-border-width) solid var(--bs-border-color-translucent);
|
||||
margin-top: -8px;
|
||||
margin-bottom: 8px;
|
||||
margin-right: calc(var(--bs-gutter-x) * -0.5);
|
||||
margin-left: calc(var(--bs-gutter-x) * -0.5);
|
||||
}
|
||||
#home_announcement p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
/* high contrast */
|
||||
@media (prefers-contrast: more) {
|
||||
:root {
|
||||
|
|
|
@ -384,6 +384,21 @@ div.navbar {
|
|||
}
|
||||
}
|
||||
|
||||
#home_announcement {
|
||||
padding: 0.5rem 1rem;
|
||||
color: var(--bs-card-cap-color);
|
||||
background-color: rgba(var(--bs-body-color-rgb), 0.03);
|
||||
border-bottom: var(--bs-border-width) solid var(--bs-border-color-translucent);
|
||||
margin-top: -8px;
|
||||
margin-bottom: 8px;
|
||||
margin-right: calc(var(--bs-gutter-x) * -.5);
|
||||
margin-left: calc(var(--bs-gutter-x) * -.5);
|
||||
|
||||
p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* high contrast */
|
||||
@media (prefers-contrast: more) {
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
{{ render_field(form.description) }}
|
||||
{{ render_field(form.sidebar) }}
|
||||
<p class="small field_hint">HTML is allowed in this field.</p>
|
||||
{{ render_field(form.announcement) }}
|
||||
<p class="small field_hint">HTML is allowed in this field.</p>
|
||||
{{ render_field(form.icon) }}
|
||||
|
||||
<h2>{{ _('About this instance') }}</h2>
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
{% block app_content %}
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-8 position-relative main_pane">
|
||||
{% if announcement -%}
|
||||
<div id="home_announcement">{{ announcement|safe }}</div>
|
||||
{% endif -%}
|
||||
{% include "_home_nav.html" %}
|
||||
<div class="post_list">
|
||||
{% for post in posts.items -%}
|
||||
|
|
|
@ -369,8 +369,6 @@ def user_access(permission: str, user_id: int) -> bool:
|
|||
|
||||
@cache.memoize(timeout=10)
|
||||
def community_membership(user: User, community: Community) -> int:
|
||||
# @cache.memoize works with User.subscribed but cache.delete_memoized does not, making it bad to use on class methods.
|
||||
# however cache.memoize and cache.delete_memoized works fine with normal functions
|
||||
if community is None:
|
||||
return False
|
||||
return user.subscribed(community.id)
|
||||
|
|
Loading…
Reference in a new issue