diff --git a/db.py b/db.py index 8a645ab..8b27e29 100644 --- a/db.py +++ b/db.py @@ -291,6 +291,15 @@ def init_db(): db.execute("CREATE INDEX IF NOT EXISTS idx_page_tags_page ON page_tags(page_id)") db.execute("CREATE INDEX IF NOT EXISTS idx_page_tags_tag ON page_tags(tag_id)") + # Migrate custom_template: replace hardcoded forum link with {{forum_link}} placeholder + cur = db.execute("SELECT value FROM settings WHERE key='custom_template'") + row = cur.fetchone() + if row: + updated = row[0].replace('forum', "{{forum_link}}") + 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 651e08c..90a609e 100644 --- a/templates.py +++ b/templates.py @@ -31,4 +31,6 @@ def wrap_page(body_html, use_default=False): template = get_setting("custom_template") or _default_template() if "{{content}}" not in template: template = _default_template() + forum_link = ' forum' if FORUM_ENABLED else "" + template = template.replace("{{forum_link}}", forum_link) return template.replace("{{content}}", body_html)