本文整理汇总了Python中flask_assets.Environment.register方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.register方法的具体用法?Python Environment.register怎么用?Python Environment.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask_assets.Environment
的用法示例。
在下文中一共展示了Environment.register方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_app
# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import register [as 别名]
def init_app(app):
webassets = Environment(app)
webassets.register('css_all', css_all)
webassets.register('js_vendor', js_vendor)
webassets.manifest = 'cache' if not app.debug else False
webassets.cache = not app.debug
webassets.debug = app.debug
示例2: create_app
# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import register [as 别名]
def create_app(object_name='bosphorus.settings', env='dev'):
app = create_barebones_app(object_name, env)
# Import and register the different asset bundles
assets_env = Environment()
assets_env.init_app(app)
assets_loader = PythonAssetsLoader(assets)
for name, bundle in assets_loader.load_bundles().iteritems():
assets_env.register(name, bundle)
# register our blueprints
from controllers.main import main
from controllers.user import user
from controllers.studies import studies
from controllers.person import person
from controllers.protocol import protocol
from utils import proxy
app.register_blueprint(main)
app.register_blueprint(user)
app.register_blueprint(person)
app.register_blueprint(studies)
app.register_blueprint(protocol)
app.register_blueprint(proxy)
return app
示例3: register_assets
# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import register [as 别名]
def register_assets(app):
assets = Environment(app)
assets.url = app.static_url_path
assets.directory = app.static_folder
assets.append_path('assets')
scss = Bundle('scss/main.scss', filters='pyscss', output='main.css', depends=('scss/*.scss'))
assets.register('scss_all', scss)
示例4: init_app
# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import register [as 别名]
def init_app(self, app):
env = Environment(app)
env.url_expire = True
env.register('css_app', css_app)
env.register('js_app', js_app)
env.manifest = 'cache' if not app.debug else False
env.cache = not app.debug
env.debug = app.debug
示例5: init_app
# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import register [as 别名]
def init_app(app):
webassets = Environment(app)
webassets.url = app.static_url_path
webassets.register('js_lodjers', js_lodjers)
webassets.register('js_mixpanel', js_mixpanel)
webassets.register('css_lodjers', css_lodjers)
webassets.manifest = 'cache' if not app.debug else False
webassets.cache = not app.debug
webassets.debug = app.debug
示例6: InvenioAssets
# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import register [as 别名]
class InvenioAssets(object):
"""Invenio asset extension."""
def __init__(self, app=None, **kwargs):
r"""Extension initialization.
:param app: An instance of :class:`~flask.Flask`.
:param \**kwargs: Keyword arguments are passed to ``init_app`` method.
"""
self.env = Environment()
self.collect = Collect()
if app:
self.init_app(app, **kwargs)
def init_app(self, app, entry_point_group='invenio_assets.bundles',
**kwargs):
"""Initialize application object.
:param app: An instance of :class:`~flask.Flask`.
:param entry_point_group: A name of entry point group used to load
``webassets`` bundles.
.. versionchanged:: 1.0.0b2
The *entrypoint* has been renamed to *entry_point_group*.
"""
self.init_config(app)
self.env.init_app(app)
self.collect.init_app(app)
if entry_point_group:
self.load_entrypoint(entry_point_group)
app.extensions['invenio-assets'] = self
def init_config(self, app):
"""Initialize configuration.
:param app: An instance of :class:`~flask.Flask`.
"""
app.config.setdefault('REQUIREJS_BASEURL', app.static_folder)
app.config.setdefault('COLLECT_STATIC_ROOT', app.static_folder)
app.config.setdefault('COLLECT_STORAGE', 'flask_collect.storage.link')
app.config.setdefault(
'COLLECT_FILTER', partial(collect_staticroot_removal, app))
def load_entrypoint(self, entry_point_group):
"""Load entrypoint.
:param entry_point_group: A name of entry point group used to load
``webassets`` bundles.
.. versionchanged:: 1.0.0b2
The *entrypoint* has been renamed to *entry_point_group*.
"""
for ep in pkg_resources.iter_entry_points(entry_point_group):
self.env.register(ep.name, ep.load())
示例7: init_assets
# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import register [as 别名]
def init_assets(app):
app.config['ASSETS_DEBUG'] = settings.DEBUG
webassets = Environment(app)
webassets.config['PYSCSS_STATIC_ROOT'] = join(STATIC_FOLDER, 'scss')
webassets.config['PYSCSS_STATIC_URL'] = join(STATIC_FOLDER, 'css/main.css')
webassets.register('css', css_bundle)
webassets.register('coffee', coffee_bundle)
webassets.register('js', js_bundle)
webassets.register('swagger_js', swagger_js)
webassets.register('swagger_css', swagger_css)
示例8: register_assets
# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import register [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
示例9: init_app
# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import register [as 别名]
def init_app(app):
"""
Initilize assets.
:param app:
"""
webassets = Environment(app)
webassets.url = app.static_url_path
webassets.register('css_all', css_all)
webassets.manifest = 'cache' if not app.debug else False
webassets.cache = not app.debug
webassets.debug = app.debug
示例10: prepare
# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import register [as 别名]
def prepare(app):
web_assets = Environment(app)
web_assets.register('css_all', *prepare_css())
web_assets.register('js_all', *prepare_js())
is_debugging = app.debug
web_assets.manifest = 'cache' if not is_debugging else False
web_assets.cache = not is_debugging
web_assets.debug = is_debugging
return app
示例11: init
# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import register [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)
示例12: register_assets
# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import register [as 别名]
def register_assets(app):
"""Register Webassets in the app"""
_create_code_css(app)
assets = Environment(app)
bundle = Bundle('style/main.less', 'style/code.css',
filters='less,cleancss',
output='css/main.%(version)s.css')
assets.register('css', bundle)
app.add_url_rule(
'/static/fonts/bootstrap/<path:filename>',
'bootstrap_fonts',
bootstrap_fonts)
示例13: init_app
# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import register [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'))
示例14: register_assets
# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import register [as 别名]
def register_assets(app):
bundles = {
'home_js': Bundle('style/js/jquery.min.js',
'style/js/bootstrap.min.js',
'style/honmaple.js',
output='style/assets/home.js',
filters='jsmin'),
'home_css': Bundle('style/css/bootstrap.min.css',
'style/honmaple.css',
output='style/assets/home.css',
filters='cssmin')
}
assets = Environment(app)
assets.register(bundles)
示例15: init_app
# 需要导入模块: from flask_assets import Environment [as 别名]
# 或者: from flask_assets.Environment import register [as 别名]
def init_app(app):
webassets = Environment(app)
webassets.register('css_bootstrap', css_bootstrap)
#webassets.register('css_local', css_local)
#webassets.register('js_local', js_local)
#webassets.register('js_jquery', js_jquery)
webassets.register('js_bootstrap', js_bootstrap)
#webassets.register('js_angular', js_angular)
#webassets.register('js_coffee', js_coffee)
webassets.manifest = 'cache' if not app.debug else False
webassets.cache = not app.debug
webassets.debug = app.debug