From 5869d0ebc747531d84e74e448a8c4bbecd74bb0e Mon Sep 17 00:00:00 2001 From: Govindas Date: Mon, 31 Jan 2022 12:56:41 +0200 Subject: [PATCH] Add basic resources support --- .gitignore | 1 + gsitegen/generate.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/.gitignore b/.gitignore index 1301020..872dc15 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ website-output __pycache__ coverage.xml /gsitegen/*.page +resources diff --git a/gsitegen/generate.py b/gsitegen/generate.py index c21d076..65a8a73 100644 --- a/gsitegen/generate.py +++ b/gsitegen/generate.py @@ -132,6 +132,22 @@ def writePages(homepage): newpage.write(page) print("Written changed page: " + titles[id]) + #resources + respath = Path(__file__).parent.joinpath("resources") + if respath.exists(): + for item in respath.iterdir(): + if item.is_dir(): + dir = item.name.replace(" ", "-").lower() + + #loop all files within page's directory + for file in item.iterdir(): + dest = Path(__file__).parent.joinpath("website-output" + "/" + dir + "/" + file.name) + #TODO write only if file has changed + dest.write_bytes(file.read_bytes()) + else: + dest = Path(__file__).parent.joinpath("website-output" + "/" + item.name) + #TODO write only if file has changed + dest.write_bytes(item.read_bytes()) def main(): #if homepage is at Home.page, set homepage to "Home"