diff --git a/handlers/__init__.py b/handlers/__init__.py
index ba91d9a..0b4365e 100644
--- a/handlers/__init__.py
+++ b/handlers/__init__.py
@@ -32,7 +32,7 @@ from .subscriptions import (
handle_subscription_delete, handle_subscription_syncall,
_sync_threads,
)
-from .customize import handle_style_form, handle_style_submit, handle_about
+from .customize import handle_style_form, handle_style_submit, handle_style_template_submit, handle_about
from .tags import handle_tags, handle_tag_browse
from .data import (
handle_export, handle_import_form, handle_import_submit,
@@ -123,6 +123,8 @@ def _dispatch_inner(data):
return handle_delete(pid) if pid is not None else _error(400)
elif path == "/style":
return handle_style_submit(body, gateway_host=gateway_host, scheme=scheme)
+ elif path == "/style/template":
+ return handle_style_template_submit(body, gateway_host=gateway_host, scheme=scheme)
elif path == "/style/reset":
set_setting("custom_template", "")
return handle_style_form("Template reset to default.", gateway_host=gateway_host, scheme=scheme)
diff --git a/handlers/customize.py b/handlers/customize.py
index 098f56b..02ad2d2 100644
--- a/handlers/customize.py
+++ b/handlers/customize.py
@@ -127,22 +127,16 @@ def handle_style_form(msg="", gateway_host="", scheme="http"):
f'manage semantic index
'
f""
f"{forum_section}"
- f'
Edit the full page template. Use {esc('{{content}}')} "
f"where page content should appear.
Drag this link to your bookmarks bar. Click it on any page to index it instantly.
" f'r.text()).then(t=>alert(t)).catch(()=>alert(\'tinyweb not running\')))">+ save to {esc(name)}
' @@ -223,6 +217,12 @@ def handle_style_submit(body, gateway_host="", scheme="http"): gateway_host=gateway_host, scheme=scheme) +def handle_style_template_submit(body, gateway_host="", scheme="http"): + template = body.get("template", [""])[0].replace("\r\n", "\n").replace("\r", "\n") + set_setting("custom_template", template if template.strip() != DEFAULT_TEMPLATE.strip() else "") + return handle_style_form("Template saved.", gateway_host=gateway_host, scheme=scheme) + + def handle_about(): name = get_site_name() dest_hash = get_setting("dest_hash")