import os import shutil import common import templates.index import templates.entries import templates.series import templates.tag import templates.year import templates.month import templates.day import templates.entry import templates.error output_dir = "output" shutil.rmtree(output_dir, ignore_errors=True) shutil.copytree("static", output_dir, dirs_exist_ok=True) os.makedirs(output_dir, exist_ok=True) for font in ["iosevka-grey", "iosevka-grey-mono"]: os.makedirs(os.path.join(output_dir, f"style/fonts/{font}"), exist_ok=True) shutil.copytree( os.path.expanduser(f"~/Software/src/iosevka/dist/{font}/woff2"), os.path.join(output_dir, f"style/fonts/{font}/woff2"), dirs_exist_ok=True, ) shutil.copy( os.path.expanduser(f"~/Software/src/iosevka/dist/{font}/{font}.css"), os.path.join(output_dir, f"style/fonts/{font}"), ) shutil.copy( os.path.expanduser("~/Software/src/iosevka/LICENSE.md"), os.path.join(output_dir, f"style/fonts/{font}"), ) os.makedirs(os.path.join(output_dir, "style/fonts/smol-emoji"), exist_ok=True) shutil.copy( os.path.expanduser(f"~/Software/src/smol-emoji/SmolEmoji-Regular.otf"), os.path.join(output_dir, "style/fonts/smol-emoji"), ) shutil.copy( os.path.expanduser(f"~/Software/src/smol-emoji/LICENSE"), os.path.join(output_dir, "style/fonts/smol-emoji"), ) with open(output_dir + "/index.html", "w") as file: file.write(templates.index.html(common.entries)) os.makedirs(output_dir + "/entries", exist_ok=True) with open(output_dir + "/entries/index.html", "w") as file: file.write(templates.entries.html(common.entries)) with open(output_dir + "/feed", "w") as file: file.write(templates.entries.atom(common.entries)) for series in common.series: os.makedirs(output_dir + common.url_of_series(series), exist_ok=True) with open(output_dir + common.url_of_series(series) + "/index.html", "w") as file: file.write(templates.series.html(common.entries, series)) with open(output_dir + common.url_of_series_feed(series), "w") as file: file.write(templates.series.atom(common.entries, series)) for tag in common.tags: os.makedirs(output_dir + common.url_of_tag(tag), exist_ok=True) with open(output_dir + common.url_of_tag(tag) + "/index.html", "w") as file: file.write(templates.tag.html(common.entries, tag)) with open(output_dir + common.url_of_tag_feed(tag), "w") as file: file.write(templates.tag.atom(common.entries, tag)) for date in common.years: os.makedirs(output_dir + common.url_of_year(date), exist_ok=True) with open(output_dir + common.url_of_year(date) + "/index.html", "w") as file: file.write(templates.year.html(common.entries, date)) for date in common.months: os.makedirs(output_dir + common.url_of_month(date), exist_ok=True) with open(output_dir + common.url_of_month(date) + "/index.html", "w") as file: file.write(templates.month.html(common.entries, date)) for date in common.days: os.makedirs(output_dir + common.url_of_day(date), exist_ok=True) with open(output_dir + common.url_of_day(date) + "/index.html", "w") as file: file.write(templates.day.html(common.entries, date)) for id in common.entries: os.makedirs(output_dir + common.url_of_entry(id), exist_ok=True) with open(output_dir + common.url_of_entry(id) + "/index.html", "w") as file: file.write(templates.entry.html(common.entries, id)) if "dir" in common.entries[id]: shutil.copytree( common.entries[id]["dir"], output_dir + common.url_of_entry(id), dirs_exist_ok=True, ) for code in [400, 401, 403, 404, 500]: with open(output_dir + f"/{code}.shtml", "w") as file: file.write(templates.error.html(code))