#!/usr/bin/env python3
"""Push skin files to all repos in /var/fossil/repos/."""
import sqlite3, time, os, glob
REPOS = glob.glob("/var/fossil/repos/*.fossil")
SKIN_DIR = os.path.dirname(os.path.abspath(__file__))
parts = {
"css": open(f"{SKIN_DIR}/css.txt").read(),
"header": open(f"{SKIN_DIR}/header.txt").read(),
"footer": open(f"{SKIN_DIR}/footer.txt").read(),
# Tell Fossil this is a dark (white-foreground) skin.
# Sets fossil.config.skin.isDark = true in JS, which adds the
# 'fossil-dark-style' class to <body> and may affect other built-in JS.
"skin-detail": "white-foreground",
}
mtime = int(time.time())
for repo in sorted(REPOS):
con = sqlite3.connect(repo)
for name, value in parts.items():
con.execute("INSERT OR REPLACE INTO config(name,value,mtime) VALUES(?,?,?)",
(name, value, mtime))
con.commit()
con.close()
print(f" skinned {os.path.basename(repo)}")
print("done.")