From d43bf546099e427ccf961ce127101d9551f126e0 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Wed, 24 Aug 2022 21:18:30 +0200 Subject: [PATCH] Custom footer support --- app/config.py | 9 +++++++++ app/scss/main.scss | 11 +++++++---- app/templates.py | 2 ++ app/templates/layout.html | 6 +++++- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/config.py b/app/config.py index ba04acd..d497cad 100644 --- a/app/config.py +++ b/app/config.py @@ -12,6 +12,7 @@ from fastapi import HTTPException from fastapi import Request from itsdangerous import URLSafeTimedSerializer from loguru import logger +from markdown import markdown from app.utils.emoji import _load_emojis from app.utils.version import get_version_commit @@ -72,6 +73,7 @@ class Config(pydantic.BaseModel): metadata: list[_ProfileMetadata] | None = None code_highlighting_theme = "friendly_grayscale" blocked_servers: list[_BlockedServer] = [] + custom_footer: str | None = None 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} 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 DEBUG = CONFIG.debug diff --git a/app/scss/main.scss b/app/scss/main.scss index f572c4b..1c37459 100644 --- a/app/scss/main.scss +++ b/app/scss/main.scss @@ -194,10 +194,13 @@ main { margin: 30px auto; } footer { - width: 100%; - max-width: 1000px; - margin: 20px auto; - color: $muted-color; + width: 100%; + max-width: 1000px; + margin: 20px auto; + color: $muted-color; + p { + margin: 0; + } } .actor-box { display: flex; diff --git a/app/templates.py b/app/templates.py index 2ba36fa..ab229be 100644 --- a/app/templates.py +++ b/app/templates.py @@ -27,6 +27,7 @@ from app.ap_object import Attachment from app.ap_object import Object from app.config import BASE_URL from app.config import CSS_HASH +from app.config import CUSTOM_FOOTER from app.config import DEBUG from app.config import VERSION from app.config import generate_csrf_token @@ -132,6 +133,7 @@ async def render_template( select(func.count(models.Following.id)) ), "actor_types": ap.ACTOR_TYPES, + "custom_footer": CUSTOM_FOOTER, **template_args, }, status_code=status_code, diff --git a/app/templates/layout.html b/app/templates/layout.html index 0124969..8e7a0c3 100644 --- a/app/templates/layout.html +++ b/app/templates/layout.html @@ -47,7 +47,11 @@