import commonmark, os, shutil, json, datetime css = """ body { max-width: 40em; text-align: justify; font-family: 'Fira Sans', sans-serif; } ul { list-style-type: square; padding: 0; padding-left: 1em; } code { background: black; color: white; padding: 2px; } h1, h2, h3, h4, h5, h6 { border-bottom: 1px solid gray; margin: 0; margin-bottom: 0.5em; font-weight: 500; } h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { color: inherit; text-decoration: none; } ul p, ol p { margin: 0; } img { width: 100%; } """ def privacy_policy(): import cmarkgfm import re from cmarkgfm.cmark import Options as cmarkgfmOptions md = open("privacy/index.md").read() out = [] tlcounter = 0 counter = 0 after_prelude = False for line in md.split("\n"): if line == "## Welcome to potatOS!": after_prelude = True if not after_prelude: out.append(line) continue if re.match(r"^##", line): tlcounter += 1 counter = 0 if re.match(r"""^[^#]+""", line) and not re.match(r"^[*\[]", line): out.append("") counter += 1 out.append(f"""
{meta["hash"][:8]} ({main["description"]}), version {main["build"]}, built {datetime.datetime.fromtimestamp(main["timestamp"], tz=datetime.timezone.utc).strftime("%Y-%m-%d %H:%M:%S (UTC)")}.
{potatos_meta}
{html}
"""
os.makedirs("website/privacy", exist_ok=True)
for im in os.listdir("images"):
shutil.copy(os.path.join("images", im), os.path.join("website", im))
with open("website/index.html", "w") as f:
f.write(html)
with open("website/privacy/index.html", "w") as f:
f.write(privacy_policy())