feat: added recursively copying static files
This commit is contained in:
parent
8e64e48097
commit
b28bb33412
@ -9,10 +9,7 @@ from .config import SOURCE_DIRECTORY, DIST_DIRECTORY, STATIC_DIRECTORY
|
|||||||
logger = logging.getLogger("stsg.build")
|
logger = logging.getLogger("stsg.build")
|
||||||
|
|
||||||
|
|
||||||
def copy_static():
|
def copy_static(src, dst):
|
||||||
src = str(Path(SOURCE_DIRECTORY, STATIC_DIRECTORY))
|
|
||||||
dst = str(Path(DIST_DIRECTORY, STATIC_DIRECTORY))
|
|
||||||
|
|
||||||
if not os.path.exists(src):
|
if not os.path.exists(src):
|
||||||
logger.warn("The static folder '%s' wasn't defined.", src)
|
logger.warn("The static folder '%s' wasn't defined.", src)
|
||||||
return
|
return
|
||||||
@ -30,7 +27,7 @@ def copy_static():
|
|||||||
dest_dir = os.path.join(dst, rel_path)
|
dest_dir = os.path.join(dst, rel_path)
|
||||||
|
|
||||||
os.makedirs(dest_dir, exist_ok=True)
|
os.makedirs(dest_dir, exist_ok=True)
|
||||||
|
|
||||||
for file in files:
|
for file in files:
|
||||||
if file.startswith("."):
|
if file.startswith("."):
|
||||||
continue
|
continue
|
||||||
@ -67,9 +64,30 @@ class Context:
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
def walk_directory(root):
|
||||||
|
src_path = Path(SOURCE_DIRECTORY, root)
|
||||||
|
dst_path = Path(DIST_DIRECTORY, root)
|
||||||
|
|
||||||
|
for current_full_path in src_path.iterdir():
|
||||||
|
current_name = Path(current_full_path).name
|
||||||
|
current_dst = Path(dst_path, current_name)
|
||||||
|
current_src = Path(src_path, current_name)
|
||||||
|
|
||||||
|
if current_name == "static":
|
||||||
|
print(current_src, current_dst)
|
||||||
|
copy_static(current_src, current_dst)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if current_dst.is_dir():
|
||||||
|
walk_directory(Path(root, current_full_path.name))
|
||||||
|
|
||||||
|
|
||||||
def build():
|
def build():
|
||||||
logger.info("building static page")
|
logger.info("building static page")
|
||||||
copy_static()
|
|
||||||
|
walk_directory("")
|
||||||
|
return
|
||||||
|
# copy_static()
|
||||||
|
|
||||||
context = Context()
|
context = Context()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user