From b505ccbd878909a27db7a4dff796694f5e87b598 Mon Sep 17 00:00:00 2001 From: tobiichi3227 Date: Sat, 25 May 2024 14:02:12 +0800 Subject: [PATCH] feat: set custom page title --- scripts/.env.example | 1 + scripts/install.sh | 5 +++++ src/utils/htmlgen.py | 16 ++++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 src/utils/htmlgen.py diff --git a/scripts/.env.example b/scripts/.env.example index f189059b..c9173fd2 100644 --- a/scripts/.env.example +++ b/scripts/.env.example @@ -6,3 +6,4 @@ UNLOCK_PASSWORD=UNLOCK_PASSWORD ADMIN_NAME=admin ADMIN_MAIL=admin@admin ADMIN_PASSWORD=admin1234 +SITE_TITLE="New TNFSH Online Judge" diff --git a/scripts/install.sh b/scripts/install.sh index d2c9af80..97b9e6e8 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -38,6 +38,10 @@ if [ -z $ADMIN_PASSWORD ]; then ADMIN_PASSWORD=admin1234 fi +if [ -z $SITE_TITLE ]; then + SITE_TITLE="New TNFSH Online Judge" +fi + # Update and upgrade sudo apt update sudo apt upgrade @@ -111,6 +115,7 @@ DBNAME_OJ = '${DB_NAME}' DBUSER_OJ = '${DB_USERNAME}' DBPW_OJ = '${DB_PASSWORD}' COOKIE_SEC = '${COOKIE_SEC}' +SITE_TITLE = '${SITE_TITLE}' lock_user_list = [] can_see_code_user = [1] unlock_pwd = ${UNLOCK_PWD} diff --git a/src/utils/htmlgen.py b/src/utils/htmlgen.py new file mode 100644 index 00000000..e13586f7 --- /dev/null +++ b/src/utils/htmlgen.py @@ -0,0 +1,16 @@ +import config + +def set_page_title(title: str, site_title: str = None): + if site_title is None: + site_title = config.SITE_TITLE + + if title == "": + t = site_title + else: + t = f"{title} | {site_title}" + + return f""" + + """