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).
This commit is contained in:
TLSM 2022-08-30 16:23:09 -04:00
parent fcb51c09d3
commit 6f3b995455
No known key found for this signature in database
GPG key ID: E745A82778055C7E
2 changed files with 14 additions and 10 deletions

View file

@ -3,7 +3,7 @@ from .get import *
from os import listdir, environ
from .const import *
import time
from files.helpers.assetcache import assetcache_get
from files.helpers.assetcache import assetcache_path
@app.template_filter("post_embed")
def post_embed(id, v):
@ -49,13 +49,7 @@ def timestamp(timestamp):
@app.template_filter("asset")
def template_asset(asset_path):
outpath = '/assets/' + asset_path
cachehash = assetcache_get(asset_path)
if cachehash:
outpath += '?v=' + cachehash
return outpath
return assetcache_path(asset_path)
@app.context_processor
def inject_constants():