template: add {{nav}} placeholder, separate from {{content}}
This commit is contained in:
parent
1d40f996ab
commit
ca855cfff9
1 changed files with 12 additions and 7 deletions
19
templates.py
19
templates.py
|
|
@ -34,21 +34,25 @@ ul + .forum-form { margin-top: 1rem; }
|
|||
.section ul { margin: 0.3rem 0; }
|
||||
</style>"""
|
||||
|
||||
DEFAULT_TEMPLATE = "<html>\n<head>\n<meta name=\"referrer\" content=\"no-referrer\">\n<meta http-equiv=\"x-dns-prefetch-control\" content=\"off\">\n" + FORUM_CSS + "</head>\n<body>\n{{content}}\n</body>\n</html>"
|
||||
|
||||
|
||||
def _default_template():
|
||||
def _nav_html():
|
||||
name = esc(get_setting("site_name", "tinyweb"))
|
||||
forum_link = ' | <a href="/forum">forum</a>' if FORUM_ENABLED else ""
|
||||
return (
|
||||
'<html>\n<head>\n<meta name="referrer" content="no-referrer">\n<meta http-equiv="x-dns-prefetch-control" content="off">\n'
|
||||
f'{FORUM_CSS}</head>\n<body>\n'
|
||||
f'<p><b><a href="/">{name}</a></b>'
|
||||
' | <a href="/">search</a> | <a href="/pages">browse</a>'
|
||||
' | <a href="/tags">tags</a> | <a href="/subscriptions">subscriptions</a>'
|
||||
f'{forum_link}'
|
||||
' | <a href="/style">customize</a> | <a href="/about">about</a></p>\n'
|
||||
"<hr>\n{{content}}\n</body>\n</html>"
|
||||
"<hr>\n"
|
||||
)
|
||||
|
||||
DEFAULT_TEMPLATE = "<html>\n<head>\n<meta name=\"referrer\" content=\"no-referrer\">\n<meta http-equiv=\"x-dns-prefetch-control\" content=\"off\">\n" + FORUM_CSS + "</head>\n<body>\n{{nav}}{{content}}\n</body>\n</html>"
|
||||
|
||||
|
||||
def _default_template():
|
||||
return (
|
||||
'<html>\n<head>\n<meta name="referrer" content="no-referrer">\n<meta http-equiv="x-dns-prefetch-control" content="off">\n'
|
||||
+ FORUM_CSS + '</head>\n<body>\n{{nav}}{{content}}\n</body>\n</html>'
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -62,6 +66,7 @@ def wrap_page(body_html, use_default=False):
|
|||
forum_link = ' <a href="/forum">forum</a>' if FORUM_ENABLED else ""
|
||||
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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue