From 86dbb6ac282c9f055f1688b7340b66d845d54536 Mon Sep 17 00:00:00 2001 From: blankie Date: Sat, 6 Jun 2026 01:41:41 +0000 Subject: [PATCH] move forum layout CSS to main site template system - Remove FORUM_CSS_DEFAULT/KODAMA2 and _forum_css() from forum handlers - Add FORUM_CSS constant to templates.py with layout-only forum CSS - Inject forum CSS into any template's via wrap_page() - Add forum layout styles to kodama2.html theme - Update database custom template --- templates.py | 24 ++++++++++++++++++++++-- themes/kodama2.html | 19 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/templates.py b/templates.py index ff533cc..c528b27 100644 --- a/templates.py +++ b/templates.py @@ -7,14 +7,30 @@ def esc(s): return html.escape(str(s)) -DEFAULT_TEMPLATE = "\n\n\n\n\n\n{{content}}\n\n" +FORUM_CSS = """ +""" + +DEFAULT_TEMPLATE = "\n\n\n\n" + FORUM_CSS + "\n\n{{content}}\n\n" def _default_template(): name = esc(get_setting("site_name", "tinyweb")) forum_link = ' | forum' if FORUM_ENABLED else "" return ( - '\n\n\n\n\n\n' + '\n\n\n\n' + f'{FORUM_CSS}\n\n' f'

{name}' ' | search | browse' ' | tags | subscriptions' @@ -34,4 +50,8 @@ def wrap_page(body_html, use_default=False): 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"))) + # Inject forum layout CSS into for any template + head_end = "" + if head_end in template and FORUM_CSS not in template: + template = template.replace(head_end, FORUM_CSS + head_end) return template.replace("{{content}}", body_html) diff --git a/themes/kodama2.html b/themes/kodama2.html index 31bd5fd..ebdfbfa 100644 --- a/themes/kodama2.html +++ b/themes/kodama2.html @@ -335,6 +335,25 @@ } a.forum-action:hover, a.forum-action-inline:hover { color: #90b4ac; background: rgba(10, 22, 25, 0.6); } a.forum-action-inline { padding: 2px 6px; border: none; } + .forum-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0.5rem 0; } + .forum-toolbar form { flex: 1; min-width: 160px; margin: 0; } + .forum-toolbar input[name=q] { width: 100%; box-sizing: border-box; padding: 6px 10px; } + .forum-toolbar-actions { display: flex; flex-wrap: wrap; gap: 4px; } + .forum-status { font-size: 0.82rem; opacity: 0.65; margin: 0 0 0.8rem 0; } + .forum-status span { margin-right: 1.2rem; } + .forum-nav { margin: 0.5rem 0; } + .forum-list { list-style: none; padding: 0; } + .forum-list li { padding: 0.6rem 0; } + .forum-list li + li { border-top: 1px solid rgba(30, 55, 50, 0.2); } + .forum-list .thread-title { font-size: 1.05rem; margin-bottom: 0.1rem; } + .forum-list .thread-meta { font-size: 0.8rem; opacity: 0.7; } + .forum-list .thread-badge { font-size: 0.78rem; opacity: 0.6; } + .post { margin-bottom: 1rem; padding-left: 1rem; border-left: 1px solid rgba(40, 70, 65, 0.3); } + .post-meta { font-size: 0.82rem; opacity: 0.7; } + .section { margin: 1.5rem 0; } + .section-title { font-weight: bold; margin-bottom: 0.3rem; } + .section-desc { font-size: 0.85rem; opacity: 0.7; margin-bottom: 0.5rem; } + .section ul { margin: 0.3rem 0; } hr { border: none; border-top: 1px solid rgba(30, 55, 50, 0.3); margin: 1rem 0; } small {