Added SiteConfig.ignore_assets
This commit is contained in:
parent
d5624e209c
commit
167fea0a2c
@ -43,6 +43,8 @@ sites:
|
|||||||
web_root: ./dist/dogma-jimfinium
|
web_root: ./dist/dogma-jimfinium
|
||||||
assets:
|
assets:
|
||||||
- assets
|
- assets
|
||||||
|
ignore_assets:
|
||||||
|
- assets/videos
|
||||||
articles:
|
articles:
|
||||||
- '*.md'
|
- '*.md'
|
||||||
addons:
|
addons:
|
||||||
|
|||||||
@ -41,11 +41,23 @@ def copy_assets(site: SiteConfig) -> None:
|
|||||||
glob.glob(f'{site.build_cache}/{a.lstrip("/")}')
|
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:
|
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
|
# Construct the destination path analogous to the source path
|
||||||
# but in the web root instead of the build cache.
|
# 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.
|
# Delete existing files.
|
||||||
shutil.rmtree(destination, ignore_errors=True)
|
shutil.rmtree(destination, ignore_errors=True)
|
||||||
@ -58,4 +70,11 @@ def copy_assets(site: SiteConfig) -> None:
|
|||||||
else:
|
else:
|
||||||
continue
|
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
|
return None
|
||||||
@ -41,8 +41,6 @@ class SiteConfig(pydantic.BaseModel):
|
|||||||
published: Optional[bool] = True
|
published: Optional[bool] = True
|
||||||
git_repo: Optional[GitRepo] = None
|
git_repo: Optional[GitRepo] = None
|
||||||
assets: Optional[list] = None
|
assets: Optional[list] = None
|
||||||
|
|
||||||
# TODO: implement ignore for assets
|
|
||||||
ignore_assets: Optional[list] = None
|
ignore_assets: Optional[list] = None
|
||||||
articles: Optional[list] = None
|
articles: Optional[list] = None
|
||||||
template_selections: Optional[dict] = {}
|
template_selections: Optional[dict] = {}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user