From 5ac9613909fcdaeb1f145e1d5d022ae11a963161 Mon Sep 17 00:00:00 2001 From: lichenblankie Date: Fri, 5 Jun 2026 04:17:02 +0000 Subject: [PATCH] added site_name placeholder to templates --- db.py | 9 +++++++++ templates.py | 1 + themes/kodama2.html | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/db.py b/db.py index 8b27e29..ec13254 100644 --- a/db.py +++ b/db.py @@ -300,6 +300,15 @@ def init_db(): db.execute("UPDATE settings SET value=? WHERE key='custom_template'", (updated,)) db.commit() + # Migrate custom_template: replace hardcoded site name with {{site_name}} placeholder + cur = db.execute("SELECT value FROM settings WHERE key='custom_template'") + row = cur.fetchone() + if row and '{{site_name}}' not in row[0]: + updated = row[0].replace('href="/">tinyweb', 'href="/">{{site_name}}') + if updated != row[0]: + db.execute("UPDATE settings SET value=? WHERE key='custom_template'", (updated,)) + db.commit() + db.execute("PRAGMA journal_mode=WAL") db.execute("PRAGMA synchronous=NORMAL") db.execute("PRAGMA cache_size=-64000") diff --git a/templates.py b/templates.py index 90a609e..ff533cc 100644 --- a/templates.py +++ b/templates.py @@ -33,4 +33,5 @@ def wrap_page(body_html, use_default=False): template = _default_template() forum_link = ' forum' if FORUM_ENABLED else "" template = template.replace("{{forum_link}}", forum_link) + template = template.replace("{{site_name}}", esc(get_setting("site_name", "tinyweb"))) return template.replace("{{content}}", body_html) diff --git a/themes/kodama2.html b/themes/kodama2.html index 96eb963..641a60e 100644 --- a/themes/kodama2.html +++ b/themes/kodama2.html @@ -368,11 +368,12 @@