當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。