def update_config(self, config_): toolkit.add_template_directory(config_, 'templates') toolkit.add_public_directory(config_, 'public') toolkit.add_resource('public', 'composite') asset_path = os.path.join( os.path.dirname(__file__), 'public' ) add_public_path(asset_path, '/')
def update_config(self, config): p.toolkit.add_template_directory(config, 'templates') p.toolkit.add_public_directory(config, 'fanstatic') p.toolkit.add_resource('fanstatic', 'hierarchy') try: from ckan.lib.webassets_tools import add_public_path except ImportError: pass else: asset_path = os.path.join(os.path.dirname(__file__), 'fanstatic') add_public_path(asset_path, '/')
def _add_public_directory(cls, config, relative_path): '''Add a path to the :ref:`extra_public_paths` config setting. The path is relative to the file calling this function. Webassets addition: append directory to webassets load paths in order to correctly rewrite relative css paths and resolve public urls. ''' import ckan.lib.helpers as h from ckan.lib.webassets_tools import add_public_path path = cls._add_served_directory(config, relative_path, 'extra_public_paths') add_public_path(path, h.url_for_static('/'))
def add_public_directory(config_: CKANConfig, relative_path: str): """Add a path to the :ref:`extra_public_paths` config setting. The path is relative to the file calling this function. Webassets addition: append directory to webassets load paths in order to correctly rewrite relative css paths and resolve public urls. """ from ckan.lib.helpers import _local_url from ckan.lib.webassets_tools import add_public_path path = _add_served_directory(config_, relative_path, "extra_public_paths") url = _local_url("/", locale="default") add_public_path(path, url)