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


Python Environment.auto_build方法代码示例

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


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

示例1: install

# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import auto_build [as 别名]
    def install(cls, app):
        """Install the extension into the application."""
        Environment.resolver_class = InvenioResolver
        env = Environment(app)
        env.url = "{0}/{1}/".format(app.static_url_path,
                                    app.config["ASSETS_BUNDLES_DIR"])
        env.directory = os.path.join(app.static_folder,
                                     app.config["ASSETS_BUNDLES_DIR"])
        env.append_path(app.static_folder)
        env.auto_build = app.config.get("ASSETS_AUTO_BUILD", True)

        # The filters less and requirejs don't have the same behaviour by
        # default. Make sure we are respecting that.
        app.config.setdefault("LESS_RUN_IN_DEBUG", True)
        app.config.setdefault("REQUIREJS_RUN_IN_DEBUG", False)
        # Fixing some paths as we forced the output directory with the
        # .directory
        app.config.setdefault("REQUIREJS_BASEURL", app.static_folder)
        requirejs_config = os.path.join(env.directory,
                                        app.config["REQUIREJS_CONFIG"])
        if not os.path.exists(requirejs_config):
            app.config["REQUIREJS_CONFIG"] = os.path.relpath(
                os.path.join(app.static_folder,
                             app.config["REQUIREJS_CONFIG"]),
                env.directory)

        app.jinja_env.add_extension(BundleExtension)
        app.context_processor(BundleExtension.inject)
开发者ID:Theer108,项目名称:invenio,代码行数:30,代码来源:extensions.py

示例2: register_assets

# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import auto_build [as 别名]
def register_assets(app):
    assets = Environment(app)
    assets.debug = app.debug
    assets.auto_build = True
    assets.url = app.static_url_path

    css_all = Bundle(*CSS_ASSETS, filters='cssmin', output='css/bundle.min.css')

    assets.register('css_all', css_all)
    app.logger.info("Registered assets...")
    return assets
开发者ID:Alben26,项目名称:Zimbra_administration,代码行数:13,代码来源:assets.py

示例3: init_app

# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import auto_build [as 别名]
def init_app(app, allow_auto_build=True):
    assets = Environment(app)
    # on google app engine put manifest file beside code
    # static folders are stored separately and there is no access to them in production
    folder = os.path.abspath(os.path.dirname(__file__)) if "APPENGINE_RUNTIME" in os.environ else ""
    assets.directory = os.path.join(app.static_folder, "compressed")
    assets.manifest = "json:{}/manifest.json".format(assets.directory)
    assets.url = app.static_url_path + "/compressed"
    compress = not app.debug  # and False
    assets.debug = not compress
    assets.auto_build = compress and allow_auto_build
    assets.register('js', Bundle(*JS, filters='yui_js', output='script.%(version)s.js'))
    assets.register('css', Bundle(*CSS, filters='yui_css', output='style.%(version)s.css'))
开发者ID:wooyek,项目名称:glosuj-w-lomiankach,代码行数:15,代码来源:assets.py

示例4: register_assets

# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import auto_build [as 别名]
def register_assets(app):
    assets = Environment(app)
    assets.debug = app.debug
    assets.auto_build = True
    assets.url = app.static_url_path

    css_blog = Bundle(*BLOG_ASSETS, filters='cssmin', output='css/blog.min.css')
    css_welcome = Bundle(*INDEX_ASSETS, filters='cssmin', output='css/welcome.min.css')

    js_all = Bundle(*JS_ASSETS, filters='rjsmin', output='js/all.min.js')

    assets.register('css_blog', css_blog)
    assets.register('css_welcome', css_welcome)
    assets.register('js_all', js_all)
    app.logger.info("Registered assets...")

    return assets
开发者ID:nezaj,项目名称:portfolio,代码行数:19,代码来源:assets.py

示例5: init

# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import auto_build [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

示例6: init_app

# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import auto_build [as 别名]
def init_app(app):
    assets = Environment(app)

    styles = Bundle(
        'main.scss',
        filters='scss',
        output='main.css',
        depends='**/*.scss'
    )

    scripts = Bundle(
        '*.js',
        filters=('slimit'),
        output='main.js'
    )

    assets.register('styles', styles)
    assets.register('scripts', scripts)

    # TODO: Move this config to an environment file
    assets.load_path = ['service/design/styles', 'service/design/scripts']
    assets.config['SASS_STYLE'] = 'compressed'
    assets.url_expire = False
    assets.auto_build = True
开发者ID:dallbee,项目名称:Bytelog,代码行数:26,代码来源:assets.py

示例7: SQLAlchemy

# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import auto_build [as 别名]
                             'sni/templates/docs/',
                             'sni/templates/podcast/']),
])
app.jinja_loader = my_loader

db = SQLAlchemy(app)

Markdown(app, extensions=['footnotes'])
pages = FlatPages(app)

manager = Manager(app)

# Scss
assets = Environment(app)
assets.url_expire = True
assets.auto_build = True
assets.append_path('sni/assets')
assets.cache = 'sni/assets/.webassets-cache'

scss = Bundle('scss/__main__.scss', filters='pyscss', output='css/main.css',
              depends=['scss/*.scss'])
assets.register('scss_all', scss)

assets.debug = False
app.config['ASSETS_DEBUG'] = False

cache = Cache(app, config={'CACHE_TYPE': 'simple'})

if not app.debug:
    import logging
    from logging.handlers import RotatingFileHandler
开发者ID:NakamotoInstitute,项目名称:nakamotoinstitute.org,代码行数:33,代码来源:__init__.py


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