当前位置: 首页>>代码示例>>Python>>正文


Python flask_assets.Bundle方法代码示例

本文整理汇总了Python中flask_assets.Bundle方法的典型用法代码示例。如果您正苦于以下问题:Python flask_assets.Bundle方法的具体用法?Python flask_assets.Bundle怎么用?Python flask_assets.Bundle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask_assets的用法示例。


在下文中一共展示了flask_assets.Bundle方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: compile_auth_assets

# 需要导入模块: import flask_assets [as 别名]
# 或者: from flask_assets import Bundle [as 别名]
def compile_auth_assets(app):
    """Configure authorization asset bundles."""
    assets = Environment(app)
    Environment.auto_build = True
    Environment.debug = False
    # Stylesheets Bundle
    less_bundle = Bundle(
        'src/less/account.less',
        filters='less,cssmin',
        output='dist/css/account.css',
        extra={'rel': 'stylesheet/less'}
    )
    # JavaScript Bundle
    js_bundle = Bundle(
        'src/js/main.js',
        filters='jsmin',
        output='dist/js/main.min.js'
    )
    # Register assets
    assets.register('less_all', less_bundle)
    assets.register('js_all', js_bundle)
    # Build assets in development mode
    if app.config['FLASK_ENV'] == 'development':
        less_bundle.build(force=True)
        js_bundle.build() 
开发者ID:hackersandslackers,项目名称:flask-session-tutorial,代码行数:27,代码来源:assets.py

示例2: compile_main_assets

# 需要导入模块: import flask_assets [as 别名]
# 或者: from flask_assets import Bundle [as 别名]
def compile_main_assets(app):
    """Configure logged-in asset bundles."""
    assets = Environment(app)
    Environment.auto_build = True
    Environment.debug = False
    # Stylesheets Bundle
    less_bundle = Bundle(
        'src/less/dashboard.less',
        filters='less,cssmin',
        output='dist/css/dashboard.css',
        extra={'rel': 'stylesheet/less'}
    )
    # Register assets
    assets.register('less_all', less_bundle)
    # Build assets in development mode
    if app.config['FLASK_ENV'] == 'development':
        less_bundle.build(force=True) 
开发者ID:hackersandslackers,项目名称:flask-session-tutorial,代码行数:19,代码来源:assets.py

示例3: compile_assets

# 需要导入模块: import flask_assets [as 别名]
# 或者: from flask_assets import Bundle [as 别名]
def compile_assets(app_assets):
    """Configure and build asset bundles."""
    js_assets = ("create",
                 "created",
                 "read",
                 "utils/errorParser",
                 "utils/fetchRetry")
    css_assets = ("styles", )
    for code in js_assets:
        bundle = Bundle(f"src/js/{code}.js",
                        filters="jsmin",
                        output=f"dist/js/{code}.min.js")
        app_assets.register(code, bundle)
        bundle.build()
    for style in css_assets:
        bundle = Bundle(f"src/css/{style}.css",
                        filters="cssmin",
                        output=f"dist/css/{style}.min.css")
        app_assets.register(style, bundle)
        bundle.build() 
开发者ID:smallwat3r,项目名称:shhh,代码行数:22,代码来源:entrypoint.py

示例4: js_files

# 需要导入模块: import flask_assets [as 别名]
# 或者: from flask_assets import Bundle [as 别名]
def js_files():
    js = Bundle('js/jquery.cookie.js',
                'js/jquery.SuperSlide.js',
                'js/autocomplete.js',
                'js/spop.js',
                'js/function.js',
                'js/fishBone.js',
                'js/dropdown.js',
                'js/tooltip.min.js',
                'js/clipboard.min.js',
                'js/Modal.js',
                'js/minigrid.js',
                'js/dynamics.js',
                'js/zh.js',
                'js/jquery.step.min.js',
                'js/jquery-rvnm.js',
                'js/botui.min.js',
                filters='jsmin',
                output='js/js_packed.js'
                )
    return js 
开发者ID:wylok,项目名称:sparrow,代码行数:23,代码来源:conf.py

示例5: css_files

# 需要导入模块: import flask_assets [as 别名]
# 或者: from flask_assets import Bundle [as 别名]
def css_files():
    css = Bundle('css/material_blue.css',
                'css/mstyle.css',
                'css/style.css',
                'css/spop.css',
                'css/fishBone.css',
                'css/buttons.css',
                'css/radar.css',
                'css/font-awesome.min.css',
                'css/jquery-rvnm.css',
                'css/jquery.step.css',
                'css/botui.min.css',
                'css/botui-theme-default.css',
                'css/mimic.css',
                filters='cssmin',
                output='css/css_packed.css'
                )
    return css 
开发者ID:wylok,项目名称:sparrow,代码行数:20,代码来源:conf.py

示例6: register

# 需要导入模块: import flask_assets [as 别名]
# 或者: from flask_assets import Bundle [as 别名]
def register(self, name, *args, **kwargs):
        ext = args[0].split('.')[-1]
        filters = kwargs.get('filters', self.default_filters[ext])
        output = kwargs.get('output', self.default_output[ext])

        return super(Assets, self).register(name, Bundle(*args, filters=filters, output=output)) 
开发者ID:scragg0x,项目名称:realms-wiki,代码行数:8,代码来源:__init__.py

示例7: init

# 需要导入模块: import flask_assets [as 别名]
# 或者: from flask_assets import Bundle [as 别名]
def init(app) -> None:
    """
    Bundle projects assets.

    :param app: Main application instance
    :type app: flask.Flask
    """
    assets = Environment(app)
    assets.auto_build = app.config.get('ASSETS_AUTO_BUILD', True)
    files_to_watch = []

    if 'COLLECT_STATIC_ROOT' in app.config:
        assets.cache = app.config['COLLECT_STATIC_ROOT']
        collect = Collect()
        collect.init_app(app)
        collect.collect()
        app.static_folder = app.config['COLLECT_STATIC_ROOT']

    for key in ['js', 'css']:
        assets_key = '%s_ASSETS' % key.upper()
        build_files = app.config[assets_key]

        files_to_watch.extend(_get_files_for_settings(app, assets_key))

        bundle = Bundle(*build_files,
                        output=app.config['%s_OUTPUT' % assets_key],
                        filters=app.config['%s_FILTERS' % assets_key]
                        )

        assets.register('%s_all' % key, bundle)

        app.logger.debug('Bundling files: %s%s',
                         os.linesep,
                         os.linesep.join(build_files))

    app.assets = assets
    app._base_files_to_watch = files_to_watch

    app.logger.info('Base assets are collected successfully.') 
开发者ID:mrgambal,项目名称:vulyk,代码行数:41,代码来源:_assets.py

示例8: init

# 需要导入模块: import flask_assets [as 别名]
# 或者: from flask_assets import Bundle [as 别名]
def init(app):
    assets = Environment(app)
    js = Bundle(*app.config['JS_ASSETS'],
                output=app.config['JS_ASSETS_OUTPUT'],
                filters=app.config['JS_ASSETS_FILTERS'])

    css = Bundle(*app.config['CSS_ASSETS'],
                 output=app.config['CSS_ASSETS_OUTPUT'],
                 filters=app.config['CSS_ASSETS_FILTERS'])

    assets.register('js_all', js)
    assets.register('css_all', css) 
开发者ID:dchaplinsky,项目名称:unshred-tag,代码行数:14,代码来源:assets.py

示例9: _init_plugin_assets

# 需要导入模块: import flask_assets [as 别名]
# 或者: from flask_assets import Bundle [as 别名]
def _init_plugin_assets(app, task_type, static_path) -> List[str]:
    """
    Bundle plugin static files.

    :param app: Main application instance.
    :type app: flask.Flask
    :param task_type: Plugin root instance.
    :type task_type: vulyk.models.task_types.AbstractTaskType
    :param static_path: Path to plugin's static folder.
    :type static_path: str

    :return: List of paths to plugin's asset files.
    :rtype: List[str]
    """
    app.logger.debug('Collecting <%s> assets.', task_type.type_name)

    files_to_watch = []
    assets_location_map = {
        'js': task_type.JS_ASSETS,
        'css': task_type.CSS_ASSETS
    }

    for key in assets_location_map.keys():
        name = 'plugin_{key}_{task}'.format(key=key, task=task_type.type_name)
        assets = assets_location_map[key]

        if len(assets) > 0:
            files = [os.path.join(static_path, x) for x in assets]
            files_to_watch += files

            folder = ['scripts', 'styles'][key == 'css']
            filters_name = '{key}_ASSETS_FILTERS'.format(key=key.upper())
            output_path = '{folder}/{name}.{key}'.format(folder=folder,
                                                         name=name,
                                                         key=key)
            bundle = Bundle(*files,
                            output=output_path,
                            filters=app.config.get(filters_name, ''))
            app.assets.register(name, bundle)
            app.logger.debug('Bundling files: %s%s',
                             os.linesep,
                             os.linesep.join(files))

    app.logger.debug('Finished collecting <%s> assets.', task_type.type_name)

    return files_to_watch 
开发者ID:mrgambal,项目名称:vulyk,代码行数:48,代码来源:_tasks.py


注:本文中的flask_assets.Bundle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。