Custom footer support

This commit is contained in:
Thomas Sileo 2022-08-24 21:18:30 +02:00
parent 953a6c3b91
commit d43bf54609
4 changed files with 23 additions and 5 deletions

View file

@ -12,6 +12,7 @@ from fastapi import HTTPException
from fastapi import Request from fastapi import Request
from itsdangerous import URLSafeTimedSerializer from itsdangerous import URLSafeTimedSerializer
from loguru import logger from loguru import logger
from markdown import markdown
from app.utils.emoji import _load_emojis from app.utils.emoji import _load_emojis
from app.utils.version import get_version_commit from app.utils.version import get_version_commit
@ -72,6 +73,7 @@ class Config(pydantic.BaseModel):
metadata: list[_ProfileMetadata] | None = None metadata: list[_ProfileMetadata] | None = None
code_highlighting_theme = "friendly_grayscale" code_highlighting_theme = "friendly_grayscale"
blocked_servers: list[_BlockedServer] = [] blocked_servers: list[_BlockedServer] = []
custom_footer: str | None = None
inbox_retention_days: int = 15 inbox_retention_days: int = 15
@ -122,6 +124,13 @@ if CONFIG.privacy_replace:
BLOCKED_SERVERS = {blocked_server.hostname for blocked_server in CONFIG.blocked_servers} BLOCKED_SERVERS = {blocked_server.hostname for blocked_server in CONFIG.blocked_servers}
INBOX_RETENTION_DAYS = CONFIG.inbox_retention_days INBOX_RETENTION_DAYS = CONFIG.inbox_retention_days
CUSTOM_FOOTER = (
markdown(
CONFIG.custom_footer.replace("{version}", VERSION), extensions=["mdx_linkify"]
)
if CONFIG.custom_footer
else None
)
BASE_URL = ID BASE_URL = ID
DEBUG = CONFIG.debug DEBUG = CONFIG.debug

View file

@ -198,6 +198,9 @@ footer {
max-width: 1000px; max-width: 1000px;
margin: 20px auto; margin: 20px auto;
color: $muted-color; color: $muted-color;
p {
margin: 0;
}
} }
.actor-box { .actor-box {
display: flex; display: flex;

View file

@ -27,6 +27,7 @@ from app.ap_object import Attachment
from app.ap_object import Object from app.ap_object import Object
from app.config import BASE_URL from app.config import BASE_URL
from app.config import CSS_HASH from app.config import CSS_HASH
from app.config import CUSTOM_FOOTER
from app.config import DEBUG from app.config import DEBUG
from app.config import VERSION from app.config import VERSION
from app.config import generate_csrf_token from app.config import generate_csrf_token
@ -132,6 +133,7 @@ async def render_template(
select(func.count(models.Following.id)) select(func.count(models.Following.id))
), ),
"actor_types": ap.ACTOR_TYPES, "actor_types": ap.ACTOR_TYPES,
"custom_footer": CUSTOM_FOOTER,
**template_args, **template_args,
}, },
status_code=status_code, status_code=status_code,

View file

@ -47,7 +47,11 @@
<footer class="footer"> <footer class="footer">
<div class="box"> <div class="box">
{% if custom_footer %}
{{ custom_footer | safe }}
{% else %}
Powered by <a href="https://docs.microblog.pub">microblog.pub</a> <small class="microblogpub-version"><code>{{ microblogpub_version }}</code></small> and the <a href="https://activitypub.rocks/">ActivityPub</a> protocol. <a href="{{ url_for("login") }}">Admin</a>. Powered by <a href="https://docs.microblog.pub">microblog.pub</a> <small class="microblogpub-version"><code>{{ microblogpub_version }}</code></small> and the <a href="https://activitypub.rocks/">ActivityPub</a> protocol. <a href="{{ url_for("login") }}">Admin</a>.
{% endif %}
</div> </div>
</footer> </footer>
</body> </body>