def xstatic(*tags):
from .vendors import vendors
node = vendors
fs = []
lang = get_language()
cls_str = str if six.PY3 else basestring
for tag in tags:
try:
for p in tag.split('.'):
node = node[p]
except Exception as e:
if tag.startswith('xadmin'):
file_type = tag.split('.')[-1]
if file_type in ('css', 'js'):
node = "xadmin/%s/%s" % (file_type, tag)
else:
raise e
else:
raise e
if isinstance(node, cls_str):
files = node
else:
mode = 'dev'
if not settings.DEBUG:
mode = getattr(settings, 'STATIC_USE_CDN',
False) and 'cdn' or 'production'
if mode == 'cdn' and mode not in node:
mode = 'production'
if mode == 'production' and mode not in node:
mode = 'dev'
files = node[mode]
files = type(files) in (list, tuple) and files or [files, ]
fs.extend([f % {'lang': lang.replace('_', '-')} for f in files])
return [f.startswith('http://') and f or static(f) for f in fs]
评论列表
文章目录