misc: remove unused settings.CDNS (#64434)
This commit is contained in:
parent
b97be713d9
commit
114cac011c
|
@ -21,11 +21,6 @@ You should add gadjo.finders.XStaticFinder to STATICFILES_FINDERS,
|
||||||
STATICFILES_FINDERS = global_settings.STATICFILES_FINDERS + \
|
STATICFILES_FINDERS = global_settings.STATICFILES_FINDERS + \
|
||||||
('gadjo.finders.XStaticFinder',)
|
('gadjo.finders.XStaticFinder',)
|
||||||
|
|
||||||
There is a CDNS settings, that can contain a list of (cdn name, protocol)
|
|
||||||
tuples; for example:
|
|
||||||
|
|
||||||
CDNS = [('google', 'https')]
|
|
||||||
|
|
||||||
|
|
||||||
Additional static files
|
Additional static files
|
||||||
------------------------
|
------------------------
|
||||||
|
|
|
@ -15,32 +15,8 @@ register = template.Library()
|
||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def xstatic(modname, filename):
|
def xstatic(modname, filename):
|
||||||
try:
|
|
||||||
# list of tuples of the form (cdnname, protocol)
|
|
||||||
cdns = settings.CDNS
|
|
||||||
except AttributeError:
|
|
||||||
cdns = []
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
filename = filename.replace('.min.', '.')
|
filename = filename.replace('.min.', '.')
|
||||||
|
|
||||||
if cdns:
|
|
||||||
modname = str(modname.replace('-', '_'))
|
|
||||||
pkg = __import__('xstatic.pkg', fromlist=[modname])
|
|
||||||
mod = getattr(pkg, modname)
|
|
||||||
for cdnname, protocol in cdns:
|
|
||||||
try:
|
|
||||||
base_url = XStatic(mod, provider=cdnname, protocol=protocol).base_url
|
|
||||||
except KeyError:
|
|
||||||
continue
|
|
||||||
if isinstance(base_url, str):
|
|
||||||
# base_url is often a str
|
|
||||||
return base_url + '/' + filename
|
|
||||||
else:
|
|
||||||
# But it also can be a dict (which maps relative paths to
|
|
||||||
# full urls) (this happens with jquery CDN)
|
|
||||||
if filename in base_url:
|
|
||||||
return base_url.get(filename)
|
|
||||||
|
|
||||||
return settings.STATIC_URL + 'xstatic/' + filename
|
return settings.STATIC_URL + 'xstatic/' + filename
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue