Exemple #1
0
    def _add_resource(cls, path, name):
        '''Add a WebAssets library to CKAN.

        WebAssets libraries are directories containing static resource
        files (e.g. CSS, JavaScript or image files) that can be
        compiled into WebAsset Bundles.

        See :doc:`/theming/index` for more details.

        '''
        import inspect
        import os
        from ckan.lib.webassets_tools import create_library

        # we want the filename that of the function caller but they
        # will have used one of the available helper functions
        # TODO: starting from python 3.5, `inspect.stack` returns list
        # of named tuples `FrameInfo`. Don't forget to remove
        # `getframeinfo` wrapper after migration.
        filename = inspect.getframeinfo(inspect.stack()[1][0]).filename

        this_dir = os.path.dirname(filename)
        absolute_path = os.path.join(this_dir, path)
        create_library(name, absolute_path)

        # TODO: remove next two lines after dropping Fanstatic support
        import ckan.lib.fanstatic_resources
        ckan.lib.fanstatic_resources.create_library(name, absolute_path)
Exemple #2
0
    def _add_resource(cls, path, name):
        '''Add a WebAssets library to CKAN.

        WebAssets libraries are directories containing static resource
        files (e.g. CSS, JavaScript or image files) that can be
        compiled into WebAsset Bundles.

        See :doc:`/theming/index` for more details.

        '''
        import inspect
        import os
        from ckan.lib.webassets_tools import create_library

        # we want the filename that of the function caller but they
        # will have used one of the available helper functions
        # TODO: starting from python 3.5, `inspect.stack` returns list
        # of named tuples `FrameInfo`. Don't forget to remove
        # `getframeinfo` wrapper after migration.
        filename = inspect.getframeinfo(inspect.stack()[1][0]).filename

        this_dir = os.path.dirname(filename)
        absolute_path = os.path.join(this_dir, path)
        create_library(name, absolute_path)

        # TODO: remove next two lines after dropping Fanstatic support
        import ckan.lib.fanstatic_resources
        ckan.lib.fanstatic_resources.create_library(name, absolute_path)
Exemple #3
0
def add_resource(path: str, name: str):
    """Add a WebAssets library to CKAN.

    WebAssets libraries are directories containing static resource
    files (e.g. CSS, JavaScript or image files) that can be
    compiled into WebAsset Bundles.

    See :doc:`/theming/index` for more details.

    """
    import inspect
    import os
    from ckan.lib.webassets_tools import create_library

    # we want the filename that of the function caller but they
    # will have used one of the available helper functions
    filename = inspect.stack()[1].filename

    this_dir = os.path.dirname(filename)
    absolute_path = os.path.join(this_dir, path)
    create_library(name, absolute_path)