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:
parent
fcb51c09d3
commit
6f3b995455
2 changed files with 14 additions and 10 deletions
|
@ -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():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue