diff options
author | Nicholas Johnson <nick@nicksphere.ch> | 2022-05-09 00:00:00 +0000 |
---|---|---|
committer | Nicholas Johnson <nick@nicksphere.ch> | 2022-05-09 00:00:00 +0000 |
commit | 2b8d30fbe8d8c821ef4d36d47e7d694869d48517f2830fe2b37f5a033d1a42fc (patch) | |
tree | 03b0b9219eabd4c212d822b9a30cbdf1cfb5307276cbbef8b9727654bc3bbe99 | |
parent | 248607267f2c844c2fa521ab170c19fc750f281843166caf5ac9e6f895ef8927 (diff) | |
download | journal-2b8d30fbe8d8c821ef4d36d47e7d694869d48517f2830fe2b37f5a033d1a42fc.tar.gz journal-2b8d30fbe8d8c821ef4d36d47e7d694869d48517f2830fe2b37f5a033d1a42fc.zip |
Remove hardcoded resources directory in generate.py
-rw-r--r-- | generate.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/generate.py b/generate.py index c043194..d5c7fb6 100644 --- a/generate.py +++ b/generate.py @@ -27,6 +27,10 @@ if __name__ == '__main__': gemini_output_dir = os.path.join(root_dir, "capsule") html_output_dir = os.path.join(root_dir, "website") + # detect static files + os.chdir(os.path.join(root_dir, "static")) + static_files = [os.path.join(root, name) for root, dirs, files in os.walk(".") for name in files] + # delete output directories shutil.rmtree(output_dir, ignore_errors=True) shutil.rmtree(gemini_output_dir, ignore_errors=True) @@ -38,14 +42,20 @@ if __name__ == '__main__': # generate Gemini output directory shutil.copytree(output_dir, gemini_output_dir, ignore=shutil.ignore_patterns("*.html")) - shutil.copytree(os.path.join(output_dir, "resource"), os.path.join(gemini_output_dir, "resource"), dirs_exist_ok=True) + + os.chdir(os.path.join(root_dir, "static")) + os.chdir(gemini_output_dir) os.remove("robots.txt") os.remove("sitemap.xml") shutil.move(os.path.join("gemini_atom", "atom.xml"), "atom.xml") os.rmdir("gemini_atom") + for file in static_files: + shutil.copy(os.path.join(output_dir, file), file) # generate HTML output directory shutil.copytree(output_dir, html_output_dir, ignore=shutil.ignore_patterns("*.gmi", "gemini_atom")) - shutil.copytree(os.path.join(output_dir, "resource"), os.path.join(html_output_dir, "resource"), dirs_exist_ok=True) + os.chdir(html_output_dir) + for file in static_files: + shutil.copy(os.path.join(output_dir, file), file) |