def __init__(self, *args, **kwargs): ignore_filters = kwargs.pop('ignore_filters', False) or False kwargs['debug'] = False try: filters = list(kwargs.pop('filters')) except KeyError: filters = [] try: vars = kwargs.pop('vars') except KeyError: vars = {} fltr = get_filter('vars', vars=vars) if not ignore_filters: filters.extend([fltr]) else: filters = fltr kwargs.update({ 'filters': filters }) Bundle.__init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs): self.bundles = kwargs.pop('bundles', []) # for arg in args: # if isinstance(arg, BrowserBundle): # self.bundles.append(arg) Bundle.__init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs): prefix = kwargs.pop('prefix') self.compile_dir = kwargs.pop('compile_dir') self.prefix = prefix args = [os.path.join(prefix, el) for el in args] Bundle.__init__(self, *args, **kwargs)
from flaskext.assets import Bundle frontend_css = Bundle( # core css Bundle("frontend/style.css"), # Chain additional css groups here # additional css #Bundle(...), # even more css #Bundle(...), filter="cssmin", output="frontend/combine.css")
def init(app): """Initialize CSS and JavaScript asset bundles """ js_libs = Bundle("js/libs/jquery-1.6.2.min.js", "js/libs/jquery.dropkick-1.0.0.js", "js/libs/json2.js", "js/libs/underscore.js", "js/libs/backbone.js", "js/libs/swfobject.js", "js/libs/spin-1.2.2.js", filters="jsmin", output="libs.js") js_common = Bundle("js/app/tools.js", "js/app/common.js", filters="jsmin", output="common.js") js_home = Bundle("js/app/stats.js", "js/app/home.js", filters="jsmin", output="home.js") js_profile = Bundle("js/app/profile.js", filters="jsmin", output="profile.js") css_less = Bundle("css/style.less", filters="less", output="style.css", debug=False) css_main = Bundle(Bundle("css/lib/screen.css", "css/lib/dropkick.css"), css_less, filters="cssmin", output="main.css") css_ie8 = Bundle("css/ie8.css", filters="cssmin", output="ie8.css") # Admin Assets js_admin_libs = Bundle("js/libs/jquery-1.6.2.min.js", "js/libs/jquery-ui-1.8.16.min.js", "js/libs/json2.js", "js/libs/underscore.js", "js/libs/backbone.js", filters="jsmin", output="admin_libs.js") js_admin_common = Bundle("js/app/admin_tools.js", "js/app/admin.js", filters="jsmin", output="admin_common.js") css_admin_less = Bundle("css/admin.less", filters="less", output="admin.css", debug=False) css_admin_main = Bundle("css/lib/screen.css", "css/lib/smoothness/jquery-ui-1.8.16.css", css_admin_less, filters="cssmin", output="admin_main.css") assets = Environment(app) assets.debug = app.config['ENVIRONMENT'] in ['development', 'staging'] assets.register('js_libs', js_libs) assets.register('js_common', js_common) assets.register('js_home', js_home) assets.register('js_profile', js_profile) assets.register("css_main", css_main) assets.register("css_ie8", css_ie8) assets.register("js_admin_libs", js_admin_libs) assets.register("js_admin_common", js_admin_common) assets.register("css_admin_main", css_admin_main)
def _build(self, *args, **kwargs): """We just set force parameter to true and call parent _build method""" kwargs['force'] = True Bundle._build(self, *args, **kwargs)
def __init__(self, *args, **kwargs): kwargs['debug'] = False args = [os.path.join(UNDERSCORE_TEMPLATES_DIR, el) for el in args] Bundle.__init__(self, *args, **kwargs)
from coaster import configureapp from os import environ # First, make an app and config it app = Flask(__name__, instance_relative_config=True) configureapp(app, 'GEEKUP_ENV') mail = Mail() mail.init_app(app) assets = Environment(app) # Second, setup assets js = Bundle('js/libs/jquery-1.6.4.js', 'js/libs/jquery.form.js', 'js/scripts.js', filters='jsmin', output='js/packed.js') assets.register('js_all', js) # Third, after config, import the models and views import geekup.models import geekup.views if environ.get('GEEKUP_ENV') == 'prod': import geekup.loghandler # Fourth, setup admin for the models from flask.ext import admin
from app import app app.config.from_object(__name__) try: app.config.from_object('settings') except ImportError: import sys print >> sys.stderr, "Please create a settings.py with the necessary settings. See settings-sample.py." print >> sys.stderr, "You may use the site without these settings, but some features may not work." # --- Assets ------------------------------------------------------------------ assets = Environment(app) js = Bundle('js/libs/jquery-1.5.1.min.js', 'js/libs/jquery.form.js', 'js/libs/jquery.oembed.js', 'js/libs/jquery.tablesorter.min.js', 'js/scripts.js', filters='jsmin', output='js/packed.js') assets.register('js_all', js) # --- Import rest of the app -------------------------------------------------- import models, forms, views # --- Logging ----------------------------------------------------------------- file_handler = logging.FileHandler(app.config['LOGFILE']) file_handler.setLevel(logging.WARNING) app.logger.addHandler(file_handler)
import os from flask import Flask, render_template from flaskext.assets import Environment, Bundle import feedparser app = Flask(__name__) assets = Environment(app) app.debug = True app.config['LESS_PATH'] = '/usr/local/bin/lessc' js = Bundle('scripts/jquery-1.7.1.min.js', filters='jsmin', output='scripts/gen.js') assets.register('all-js', js) @app.route('/') def hello(): return render_template('index.html') if __name__ == '__main__': port = int(os.environ.get("PORT", "5000")) app.run(host='0.0.0.0', port=port)
from flask import Flask from flaskext.assets import Environment, Bundle from baseframe import baseframe, baseframe_js, baseframe_css # the flask app app = Flask(__name__, instance_relative_config=True) app.register_blueprint(baseframe) assets = Environment(app) js = Bundle(baseframe_js, 'js/leaflet.js', 'js/check_dates.js') css = Bundle( Bundle(baseframe_css, 'css/pyconindia.css', 'css/monitor.css', filters='cssmin', output='css/pyconindia-packed.css'), 'css/leaflet.css') assets.register('js_all', js) assets.register('css_all', css) # Import models and views, and register routes here from flask import render_template @app.route('/') def index():
def __init__(self, *args, **kwargs): self.browser = kwargs.pop('browser', '') self.browser_version = kwargs.pop('browser_version', '') Bundle.__init__(self, *args, **kwargs)