From 167fea0a2cacafb83720ad91eb928ee8d6c29027 Mon Sep 17 00:00:00 2001 From: Jim Shepich III Date: Wed, 4 Feb 2026 12:42:53 -0500 Subject: [PATCH] Added SiteConfig.ignore_assets --- config.yaml | 2 ++ jimsite/assets.py | 21 +++++++++++++++++++- jimsite/common.py | 2 -- jimsite/requirements.txt => requirements.txt | 0 4 files changed, 22 insertions(+), 3 deletions(-) rename jimsite/requirements.txt => requirements.txt (100%) diff --git a/config.yaml b/config.yaml index ae00c7d..6767839 100644 --- a/config.yaml +++ b/config.yaml @@ -43,6 +43,8 @@ sites: web_root: ./dist/dogma-jimfinium assets: - assets + ignore_assets: + - assets/videos articles: - '*.md' addons: diff --git a/jimsite/assets.py b/jimsite/assets.py index 8c0d88b..78d05f2 100644 --- a/jimsite/assets.py +++ b/jimsite/assets.py @@ -40,12 +40,24 @@ def copy_assets(site: SiteConfig) -> None: # Assets are defined relative to the build cache; construct the full path. glob.glob(f'{site.build_cache}/{a.lstrip("/")}') ) + + # Also expand the expressions in the ignore list. + ignored_asset_list = [] + for a in (site.ignore_assets or []): + ignored_asset_list.extend( + # Assets are defined relative to the build cache; construct the full path. + glob.glob(f'{site.build_cache}/{a.lstrip("/")}') + ) for asset in expanded_asset_list: + + # Skip ignored assets. + if asset in ignored_asset_list: + continue # Construct the destination path analogous to the source path # but in the web root instead of the build cache. - destination = f'{site.web_root}/{a.lstrip("/")}' + destination = f'{site.web_root}/{asset.removeprefix(site.build_cache).lstrip("/")}' # Delete existing files. shutil.rmtree(destination, ignore_errors=True) @@ -58,4 +70,11 @@ def copy_assets(site: SiteConfig) -> None: else: continue + # In cases where the ignored assets are defined at a different + # level of the filetree than the included assets, remove them. + for asset in ignored_asset_list: + destination = f'{site.web_root}/{asset.removeprefix(site.build_cache).lstrip("/")}' + shutil.rmtree(destination, ignore_errors=True) + + return None \ No newline at end of file diff --git a/jimsite/common.py b/jimsite/common.py index 5478169..0c98bcd 100644 --- a/jimsite/common.py +++ b/jimsite/common.py @@ -41,8 +41,6 @@ class SiteConfig(pydantic.BaseModel): published: Optional[bool] = True git_repo: Optional[GitRepo] = None assets: Optional[list] = None - - # TODO: implement ignore for assets ignore_assets: Optional[list] = None articles: Optional[list] = None template_selections: Optional[dict] = {} diff --git a/jimsite/requirements.txt b/requirements.txt similarity index 100% rename from jimsite/requirements.txt rename to requirements.txt