From 2b8d30fbe8d8c821ef4d36d47e7d694869d48517f2830fe2b37f5a033d1a42fc Mon Sep 17 00:00:00 2001 From: Nicholas Johnson Date: Mon, 9 May 2022 00:00:00 +0000 Subject: Remove hardcoded resources directory in generate.py --- generate.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'generate.py') 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) -- cgit v1.2.3