Commit graph

2 commits

Author SHA1 Message Date
TLSM
6f3b995455
assetcache: add interface for non-Jinja consumers.
Rather than generating the URL in helpers/jinja2.py, we move the logic
to helpers/assetcache.py because there are consumers of asset URLs
in Python code (for better or for worse).
2022-08-30 16:23:09 -04:00
TLSM
fcb51c09d3
Implement assetcache module with asset hashing.
Provides a module `assetcache` to support automatic cachebusting of
static web assets, rather than the current approach of incrementing
a version number.

On module load, it walks the file/assets/ dir, computes a CRC32 of
each asset, and provides those hashes via `assetcache_get(path)` at
runtime. The primary consumer of hashes at present is the new `asset`
filter for Jinja2, which accepts a relative asset path and returns the
full path, with cache busting, suitable for final use in the template.

Ex: `{{ 'css/main.css' | asset }}`
2022-08-30 16:00:24 -04:00