remove demo pages, rename themes, add Content-Length header

This commit is contained in:
blankie 2026-06-16 05:11:37 +00:00
parent a72de2bb10
commit 7a81b519bb
10 changed files with 1652 additions and 2370 deletions

View file

@ -7,33 +7,6 @@ def esc(s):
return html.escape(str(s))
FORUM_CSS = """
<style>
.forum-form { max-width: 500px; }
.forum-form input:not([type=checkbox]):not([type=radio]), .forum-form textarea { width: 100%; box-sizing: border-box; }
.forum-form textarea { resize: vertical; }
.forum-form input, .forum-form textarea, .forum-form button { margin-bottom: 8px; }
.forum-form small { display: block; margin-bottom: 6px; }
.forum-form label { display: block; margin-bottom: 6px; }
.forum-form + .forum-form { margin-top: 1rem; }
.forum-form + .section-title { margin-top: 1rem; }
.section-desc + .forum-form { margin-top: 0.8rem; }
ul + .forum-form { margin-top: 1rem; }
.checkbox-label { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.forum-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.forum-toolbar form { flex: 1; min-width: 160px; margin: 0; }
.forum-toolbar input[name=q] { width: 100%; box-sizing: border-box; }
.forum-toolbar-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.forum-list { list-style: none; padding: 0; }
.forum-status { margin: 0 0 0.8rem 0; }
.forum-status span { margin-right: 0.5rem; }
.forum-nav { margin: 0.5rem 0; }
.section { margin: 1.5rem 0; }
.section-title { font-weight: 600; margin-bottom: 0.3rem; }
.section-desc { font-size: 0.85rem; margin-bottom: 0.5rem; }
.section ul { margin: 0.3rem 0; }
</style>"""
def _nav_html():
name = esc(get_setting("site_name", "tinyweb"))
forum_link = ' | <a href="/forum">forum</a>' if FORUM_ENABLED else ""
@ -56,7 +29,7 @@ def _default_template():
)
def wrap_page(body_html, use_default=False):
def wrap_page(body_html, use_default=False, head_html=""):
if use_default:
template = _default_template()
else:
@ -67,8 +40,6 @@ def wrap_page(body_html, use_default=False):
template = template.replace("{{forum_link}}", forum_link)
template = template.replace("{{site_name}}", esc(get_setting("site_name", "tinyweb")))
template = template.replace("{{nav}}", _nav_html())
# Inject forum layout CSS into <head> for any template
head_end = "</head>"
if head_end in template and FORUM_CSS not in template:
template = template.replace(head_end, FORUM_CSS + head_end)
if head_html:
template = template.replace("</head>", head_html + "</head>")
return template.replace("{{content}}", body_html)