Add 'fanstatic' support for sake of libcache assets
for vue.js and oruga etc. we don't want to include files in tailbone since they are apt to change over time, and probably need to use different versions for different apps etc. much may need to change yet, this is a first attempt but so far it seems quite promising
This commit is contained in:
parent
1afc70e788
commit
d9911cf23d
|
@ -57,6 +57,7 @@ install_requires =
|
||||||
pyramid_beaker
|
pyramid_beaker
|
||||||
pyramid_deform
|
pyramid_deform
|
||||||
pyramid_exclog
|
pyramid_exclog
|
||||||
|
pyramid_fanstatic
|
||||||
pyramid_mako
|
pyramid_mako
|
||||||
pyramid_retry
|
pyramid_retry
|
||||||
pyramid_tm
|
pyramid_tm
|
||||||
|
|
|
@ -129,6 +129,7 @@ def make_pyramid_config(settings, configure_csrf=True):
|
||||||
# we want the new themes feature!
|
# we want the new themes feature!
|
||||||
establish_theme(settings)
|
establish_theme(settings)
|
||||||
|
|
||||||
|
settings.setdefault('fanstatic.versioning', 'true')
|
||||||
settings.setdefault('pyramid_deform.template_search_path', 'tailbone:templates/deform')
|
settings.setdefault('pyramid_deform.template_search_path', 'tailbone:templates/deform')
|
||||||
config = Configurator(settings=settings, root_factory=Root)
|
config = Configurator(settings=settings, root_factory=Root)
|
||||||
|
|
||||||
|
@ -147,6 +148,7 @@ def make_pyramid_config(settings, configure_csrf=True):
|
||||||
# Bring in some Pyramid goodies.
|
# Bring in some Pyramid goodies.
|
||||||
config.include('tailbone.beaker')
|
config.include('tailbone.beaker')
|
||||||
config.include('pyramid_deform')
|
config.include('pyramid_deform')
|
||||||
|
config.include('pyramid_fanstatic')
|
||||||
config.include('pyramid_mako')
|
config.include('pyramid_mako')
|
||||||
config.include('pyramid_tm')
|
config.include('pyramid_tm')
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ Utilities
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
|
@ -195,6 +196,12 @@ def get_liburl(request, key, fallback=True):
|
||||||
|
|
||||||
version = get_libver(request, key)
|
version = get_libver(request, key)
|
||||||
|
|
||||||
|
static = config.get('tailbone.static_libcache.module')
|
||||||
|
if static:
|
||||||
|
static = importlib.import_module(static)
|
||||||
|
needed = request.environ['fanstatic.needed']
|
||||||
|
liburl = needed.library_url(static.libcache) + '/'
|
||||||
|
|
||||||
if key == 'buefy':
|
if key == 'buefy':
|
||||||
return 'https://unpkg.com/buefy@{}/dist/buefy.min.js'.format(version)
|
return 'https://unpkg.com/buefy@{}/dist/buefy.min.js'.format(version)
|
||||||
|
|
||||||
|
@ -211,24 +218,38 @@ def get_liburl(request, key, fallback=True):
|
||||||
return 'https://use.fontawesome.com/releases/v{}/js/all.js'.format(version)
|
return 'https://use.fontawesome.com/releases/v{}/js/all.js'.format(version)
|
||||||
|
|
||||||
elif key == 'bb_vue':
|
elif key == 'bb_vue':
|
||||||
|
if static and hasattr(static, 'bb_vue_js'):
|
||||||
|
return liburl + static.bb_vue_js.relpath
|
||||||
return f'https://unpkg.com/vue@{version}/dist/vue.esm-browser.prod.js'
|
return f'https://unpkg.com/vue@{version}/dist/vue.esm-browser.prod.js'
|
||||||
|
|
||||||
elif key == 'bb_oruga':
|
elif key == 'bb_oruga':
|
||||||
|
if static and hasattr(static, 'bb_oruga_js'):
|
||||||
|
return liburl + static.bb_oruga_js.relpath
|
||||||
return f'https://unpkg.com/@oruga-ui/oruga-next@{version}/dist/oruga.mjs'
|
return f'https://unpkg.com/@oruga-ui/oruga-next@{version}/dist/oruga.mjs'
|
||||||
|
|
||||||
elif key == 'bb_oruga_bulma':
|
elif key == 'bb_oruga_bulma':
|
||||||
|
if static and hasattr(static, 'bb_oruga_bulma_js'):
|
||||||
|
return liburl + static.bb_oruga_bulma_js.relpath
|
||||||
return f'https://unpkg.com/@oruga-ui/theme-bulma@{version}/dist/bulma.mjs'
|
return f'https://unpkg.com/@oruga-ui/theme-bulma@{version}/dist/bulma.mjs'
|
||||||
|
|
||||||
elif key == 'bb_oruga_bulma_css':
|
elif key == 'bb_oruga_bulma_css':
|
||||||
|
if static and hasattr(static, 'bb_oruga_bulma_css'):
|
||||||
|
return liburl + static.bb_oruga_bulma_css.relpath
|
||||||
return f'https://unpkg.com/@oruga-ui/theme-bulma@{version}/dist/bulma.css'
|
return f'https://unpkg.com/@oruga-ui/theme-bulma@{version}/dist/bulma.css'
|
||||||
|
|
||||||
elif key == 'bb_fontawesome_svg_core':
|
elif key == 'bb_fontawesome_svg_core':
|
||||||
|
if static and hasattr(static, 'bb_fontawesome_svg_core_js'):
|
||||||
|
return liburl + static.bb_fontawesome_svg_core_js.relpath
|
||||||
return f'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-svg-core@{version}/+esm'
|
return f'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-svg-core@{version}/+esm'
|
||||||
|
|
||||||
elif key == 'bb_free_solid_svg_icons':
|
elif key == 'bb_free_solid_svg_icons':
|
||||||
|
if static and hasattr(static, 'bb_free_solid_svg_icons_js'):
|
||||||
|
return liburl + static.bb_free_solid_svg_icons_js.relpath
|
||||||
return f'https://cdn.jsdelivr.net/npm/@fortawesome/free-solid-svg-icons@{version}/+esm'
|
return f'https://cdn.jsdelivr.net/npm/@fortawesome/free-solid-svg-icons@{version}/+esm'
|
||||||
|
|
||||||
elif key == 'bb_vue_fontawesome':
|
elif key == 'bb_vue_fontawesome':
|
||||||
|
if static and hasattr(static, 'bb_vue_fontawesome_js'):
|
||||||
|
return liburl + static.bb_vue_fontawesome_js.relpath
|
||||||
return f'https://cdn.jsdelivr.net/npm/@fortawesome/vue-fontawesome@{version}/+esm'
|
return f'https://cdn.jsdelivr.net/npm/@fortawesome/vue-fontawesome@{version}/+esm'
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue