Fix navbar disappearing when saving customize form

Browser textarea submissions convert \n to \r\n, causing the template
comparison against DEFAULT_TEMPLATE to always fail. This saved the bare
skeleton as a custom template, overriding the default navbar.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Derick Phan 2026-03-26 22:00:27 -07:00
parent 7c225145f0
commit 6070e09834
No known key found for this signature in database

View file

@ -528,7 +528,7 @@ def handle_style_submit(body):
template = body.get("template", [""])[0] template = body.get("template", [""])[0]
name = body.get("site_name", ["tinyweb"])[0].strip() name = body.get("site_name", ["tinyweb"])[0].strip()
sharing = "1" if body.get("sharing_enabled") else "0" sharing = "1" if body.get("sharing_enabled") else "0"
set_setting("custom_template", template if template.strip() != DEFAULT_TEMPLATE.strip() else "") set_setting("custom_template", template if template.strip().replace("\r\n", "\n") != DEFAULT_TEMPLATE.strip() else "")
set_setting("site_name", name or "tinyweb") set_setting("site_name", name or "tinyweb")
set_setting("sharing_enabled", sharing) set_setting("sharing_enabled", sharing)
return handle_style_form("Saved.") return handle_style_form("Saved.")