added site_name placeholder to templates
This commit is contained in:
parent
8d9f2bf4e7
commit
5ac9613909
3 changed files with 12 additions and 1 deletions
9
db.py
9
db.py
|
|
@ -300,6 +300,15 @@ def init_db():
|
||||||
db.execute("UPDATE settings SET value=? WHERE key='custom_template'", (updated,))
|
db.execute("UPDATE settings SET value=? WHERE key='custom_template'", (updated,))
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
# Migrate custom_template: replace hardcoded site name with {{site_name}} placeholder
|
||||||
|
cur = db.execute("SELECT value FROM settings WHERE key='custom_template'")
|
||||||
|
row = cur.fetchone()
|
||||||
|
if row and '{{site_name}}' not in row[0]:
|
||||||
|
updated = row[0].replace('href="/">tinyweb</a>', 'href="/">{{site_name}}</a>')
|
||||||
|
if updated != row[0]:
|
||||||
|
db.execute("UPDATE settings SET value=? WHERE key='custom_template'", (updated,))
|
||||||
|
db.commit()
|
||||||
|
|
||||||
db.execute("PRAGMA journal_mode=WAL")
|
db.execute("PRAGMA journal_mode=WAL")
|
||||||
db.execute("PRAGMA synchronous=NORMAL")
|
db.execute("PRAGMA synchronous=NORMAL")
|
||||||
db.execute("PRAGMA cache_size=-64000")
|
db.execute("PRAGMA cache_size=-64000")
|
||||||
|
|
|
||||||
|
|
@ -33,4 +33,5 @@ def wrap_page(body_html, use_default=False):
|
||||||
template = _default_template()
|
template = _default_template()
|
||||||
forum_link = ' <a href="/forum">forum</a>' if FORUM_ENABLED else ""
|
forum_link = ' <a href="/forum">forum</a>' if FORUM_ENABLED else ""
|
||||||
template = template.replace("{{forum_link}}", forum_link)
|
template = template.replace("{{forum_link}}", forum_link)
|
||||||
|
template = template.replace("{{site_name}}", esc(get_setting("site_name", "tinyweb")))
|
||||||
return template.replace("{{content}}", body_html)
|
return template.replace("{{content}}", body_html)
|
||||||
|
|
|
||||||
|
|
@ -368,11 +368,12 @@
|
||||||
<canvas id="trail"></canvas>
|
<canvas id="trail"></canvas>
|
||||||
<div class="shell">
|
<div class="shell">
|
||||||
<nav>
|
<nav>
|
||||||
<a class="site" href="/">tinyweb</a>
|
<a class="site" href="/">{{site_name}}</a>
|
||||||
<div class="links">
|
<div class="links">
|
||||||
<a href="/pages">browse</a>
|
<a href="/pages">browse</a>
|
||||||
<a href="/tags">tags</a>
|
<a href="/tags">tags</a>
|
||||||
<a href="/subscriptions">network</a>
|
<a href="/subscriptions">network</a>
|
||||||
|
{{forum_link}}
|
||||||
<a href="/style">customize</a>
|
<a href="/style">customize</a>
|
||||||
<a href="/about">about</a>
|
<a href="/about">about</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue