def create_app(config_name): app = Flask(__name__) app.config.from_object(config[config_name]) config[config_name].init_app(app) env = assets.Environment(app) env.url = app.static_url_path # where do our SASS files live? scss = assets.Bundle('all.scss', filters='pyscss', output='all.css') env.register('scss_all', scss) from .main import main as main_blueprint app.register_blueprint(main_blueprint) return app
def create_app(config_name): app = Flask(__name__) app.config.from_object(config[config_name]) config[config_name].init_app(app) # Set up SASS compilation # NB: you may need to `sudo gem install sass` locally env = assets.Environment(app) # env.config['SASS_STYLE'] = 'compressed' # Tell assets where to look for scss files env.load_path = [os.path.join(basedir, 'assets/scss')] sass_bundle = assets.Bundle('main.scss', filters='scss', output='css/main.css') env.register('css_main', sass_bundle) bootstrap.init_app(app) mail.init_app(app) moment.init_app(app) db.init_app(app) login_manager.init_app(app) if not app.debug and not app.testing and not app.config['SSL_DISABLE']: from flask.ext.sslify import SSLify sslify = SSLify(app) from .main import main as main_blueprint app.register_blueprint(main_blueprint) from .students import students as students_blueprint app.register_blueprint(students_blueprint, url_prefix="/student") from .mentors import mentors as mentors_blueprint app.register_blueprint(mentors_blueprint, url_prefix="/mentor") from .admin import admin as admin_blueprint app.register_blueprint(admin_blueprint, url_prefix="/admin") return app
from flask.ext.sqlalchemy import SQLAlchemy from flask_httpauth import HTTPBasicAuth from werkzeug.security import generate_password_hash, check_password_hash from dashboardsly import app db = SQLAlchemy(app) app.logger.addHandler(logging.StreamHandler(sys.stdout)) app.logger.setLevel(logging.ERROR) env = assets.Environment(app) env.load_path = [os.path.join(os.path.dirname(__file__), 'sass')] env.register( 'css_all', assets.Bundle('skeleton.scss', filters='scss', output='css_all.css')) CORS(app) auth = HTTPBasicAuth() @auth.verify_password def verify_pw(username, password): if username == '': return False shortlink = request.path[1:] dashboard = Dashboard.query.get(shortlink) if dashboard is None: return True if dashboard.username != username:
app = Flask('test_dummy') app.config['DEBUG'] = True app.config['MUTATIO_PORT'] = 27018 app.config['MUTATIO_TEMPLATE_TAGS'] = ('{@', '@}') env = assets.Environment(app) env.load_path = [ os.path.join(os.path.dirname(__file__), 'static'), os.path.join(os.path.dirname(__file__), 'node_modules'), ] env.register( 'js_all', assets.Bundle('jquery/dist/jquery.min.js', 'js/bootstrap.min.js', assets.Bundle('coffee/dashboard.coffee', filters=['coffeescript']), output='js_all.js')) env.register( 'css_all', assets.Bundle( 'css/bootstrap.min.css', 'css/font-awesome.min.css', output='css_all.css', )) mutatio = Mutatio() mutatio.init_app(app) @app.route('/') def hello_world():
def init_app(app): assets_env.app = app assets_env.init_app(app) assets_env.manifest = "file:%s" % (os.path.join(STATIC_PATH, '.webassets-manifest')) cache_path = app.config['WEBASSETS_CACHE_PATH'] if not app.debug and not os.path.exists(cache_path): os.makedirs(cache_path) assets_env.cache = cache_path assets_env.load_path = STATIC_PATH assets_env.versions = 'hash:32' assets_env.auto_build = app.config['WEBASSETS_AUTO_BUILD'] assets_env.url_expire = False # Tell flask-assets where to look for our coffeescript and scss files. assets_env.load_path = [ os.path.join(os.path.dirname(__file__), 'scss'), os.path.join(os.path.dirname(__file__), 'coffee'), VENDOR_PATH ] bower_dependencies = read_bower_json() js_files = bower_dependencies.get('.js', []) js_out = 'js/js_app.%(version)s.js' if app.debug: js_out = 'js/js_app.js' coffee_files = get_coffee_files(app) if coffee_files: js_files.append( assets.Bundle( coffee_files, depends=('*.coffee'), # OTHER CONFIGS filters=['coffeescript'], output=js_out)) app.config['COMPASS_CONFIG'] = dict( encoding="utf-8", css_dir="css", fonts_dir="fonts", sass_dir="scss", images_dir="images", javascripts_dir="js", project_path=STATIC_PATH, relative_assets=True, ) js_out = 'js/js_all.%(version)s.js' if app.debug: js_out = 'js/js_all.js' if js_files: js_all_bundle = assets.Bundle(*js_files, output=js_out) else: js_all_bundle = assets.Bundle() assets_env.register('js_all', js_all_bundle) scss_files = bower_dependencies.get('.scss', []) scss_bower_out = 'css/css_bower.%(version)s.css' if app.debug: scss_bower_out = 'css/css_bower.css' scss_bower_bundle = assets.Bundle(*scss_files, depends=('_*.scss'), filters=['compass'], output=scss_bower_out) css_out = 'css/css_all.%(version)s.css' if app.debug: css_out = 'css/css_all.css' css_all_bundle = assets.Bundle('all.scss', depends=('_*.scss'), filters=['compass'], output=css_out) css_out = 'css/base.%(version)s.css' if app.debug: css_out = 'css/base.css' css_files = bower_dependencies.get('.css', []) css_base_bundle = assets.Bundle(*css_files, filters=['cssmin'], output=css_out) css_out = 'css/style.%(version)s.css' if app.debug: css_out = 'css/style.css' css_all_bundle = assets.Bundle(scss_bower_bundle, css_base_bundle, css_all_bundle, filters=['cssmin'], output=css_out) assets_env.register('css_all', css_all_bundle) if app.debug: assets_env.set_updater(TimestampUpdater()) assets_env.cache = False assets_env.auto_build = True assets_env.debug = True
app = Flask(__name__) app.secret_key = os.environ.get('SK') app.wsgi_app = ProxyFix(app.wsgi_app) dev = os.environ.get('DEV') == 'true' env = assets.Environment(app) env.load_path = [os.path.dirname(__file__)] js = glob.glob('static/js/*.js') coffee = glob.glob('static/js/*.js.coffee') order = ['libs', 'services', 'filters', 'directives', 'controllers'] for x in order: js.extend(glob.glob('static/js/{}/*.js'.format(x))) coffee.extend(glob.glob('static/js/{}/*.js.coffee'.format(x))) coffee_bundle = assets.Bundle(*coffee, filters=['coffeescript']) js.append(coffee_bundle) js_libs = [ 'node_modules/angular-sanitize/angular-sanitize.js', 'node_modules/ng-csv/build/ng-csv.js', 'node_modules/ng-file-upload/dist/ng-file-upload-shim.js', 'node_modules/ng-file-upload/dist/ng-file-upload.js', 'node_modules/angular-ui-switch/angular-ui-switch.js', 'node_modules/chart.js/Chart.js', 'node_modules/angular-chart.js/angular-chart.js', 'node_modules/angular-google-analytics/dist/angular-google-analytics.js' ] js.append(js_libs) css = [] less = []
env = assets.Environment(app) app.secret_key = '123kwqoidmk23j1oed8suj' env.config['SASS_USE_SCSS'] = True # Prepare asset bundles project_path = os.path.dirname(os.path.abspath(__file__)) env.load_path = [ os.path.join(project_path, 'js'), os.path.join(project_path, 'sass'), ] env.url_expire = True env.register( 'js_all', assets.Bundle('app.js', filters=get_filter('babel', presets='react'), output='gen/packed.js')) env.register( 'css_all', assets.Bundle( 'main.scss', filters=get_filter('sass', load_paths=[os.path.join(project_path, 'sass')]), depends= '**/*.scss', # Make sure to rebuild whenever *any* SASS file in the load path changes output='gen/css_all.css')) # Set up logging @app.before_first_request
] env.register( 'js_all', assets.Bundle( 'jquery/dist/jquery.min.js', 'bootstrap.min.js', 'd3.min.js', 'dc.js', 'crossfilter.js', 'colorbrewer.js', assets.Bundle( 'all.coffee', 'chartFunctions.coffee', 'helpers.coffee', 'listeners.coffee', 'dashboardClass.coffee', 'chartClass.coffee', #'three.coffee', #'map.coffee', #'all.coffee', filters=['coffeescript'] ), output='js_all.js' ) ) env.register( 'css_all', assets.Bundle(
# Define asset locations for search env.load_path = [ os.path.join(os.path.dirname(__file__), 'sass'), os.path.join(os.path.dirname(__file__), 'coffee'), os.path.join(os.path.dirname(__file__), 'bower_components'), ] # Register javascripts and coffeescript env.register( 'js_all', assets.Bundle( 'jquery/dist/jquery.min.js', 'semantic-ui/build/packaged/javascript/semantic.min.js', assets.Bundle( 'all.coffee', filters=['coffeescript'] ), output='js_all.js' ) ) # Register SASS and CSS env.register( 'css_all', assets.Bundle( 'all.sass', filters='sass', output='css_all.css' ), assets.Bundle(
app = Flask(__name__) app.config.from_object(BaseConfig) app.config.from_envvar(CONFIG_ENVVAR, silent=True) # The debug config is loaded at the end of this file, if it is run # directly (name == main) # Load assets (currently only the scss stylesheet) env = assets.Environment(app) env.load_path = [ os.path.join(os.path.dirname(__file__), "assets") ] style = assets.Bundle( "style.css" ) env.register("style", style) # Redis @app.before_request def connect_redis(): c = current_app.config g.redis = redis.StrictRedis(host = c["REDIS_HOST"], port = c["REDIS_PORT"], db = c["REDIS_DB"])
import os from flask import Flask, render_template from flask.ext import assets app = Flask(__name__) env = assets.Environment(app) env.register( 'styleguide_website', assets.Bundle('demo/sass/styleguide-examples.scss', filters='scss', output='demo/css/styleguide-examples.css')) # Small thing to allow source code examples in a template app.jinja_env.globals[ 'include_raw'] = lambda filename: app.jinja_loader.get_source( app.jinja_env, filename)[0] # General base styles @app.route('/') def home(): return render_template('styleguide/index.html') @app.route('/typography') def typography(): return render_template('styleguide/typography.html')
from flask.ext.bower import Bower from flask.ext import assets import os app = Flask(__name__) env = assets.Environment(app) #env = app # Tell flask-assets where to look for our coffeescript and sass files. env.load_path = [ os.path.join(os.path.dirname(__file__), 'static/bower_components'), os.path.join(os.path.dirname(__file__), 'static'), ] env.register( 'js_all', assets.Bundle( 'jquery/dist/jquery.min.js', output='built/js_all.js' ) ) env.register( 'css_all', assets.Bundle( 'css/main.css', output='built/css_all.css' ) ) Bower(app) CORS(app) api = Api(app) @app.route("/")
from flask.ext import assets app = Flask(__name__) env = assets.Environment(app) # Tell flask-assets where to look for our coffeescript and sass files. env.load_path = [ os.path.join(os.path.dirname(__file__), 'sass'), os.path.join(os.path.dirname(__file__), 'coffee'), os.path.join(os.path.dirname(__file__), 'bower_components'), ] env.register( 'js_all', assets.Bundle('jquery/dist/jquery.min.js', assets.Bundle('all.coffee', filters=['coffeescript']), output='js_all.js')) env.register('css_all', assets.Bundle('all.sass', filters='sass', output='css_all.css')) @app.route("/") def index(): return render_template('index.html') if __name__ == "__main__": app.run(debug=True)
webassets = assets.Environment(app) # In the future, we may set this to False and build assets before deployment. # Build has a minor cost in Production, so we'll optimize this when we need to # noqa See http://elsdoerfer.name/docs/webassets/environment.html#webassets.env.Environment.auto_build webassets.auto_build = True webassets.register( 'js_app', assets.Bundle( # Add new .js files here # 'js/lib.js', assets.Bundle( # Add new .coffee files here 'js/main.coffee', filters='coffeescript', output='compiled/main.js', ), filters='rjsmin', output='compiled/app.js', )) webassets.register( 'css_app', assets.Bundle( # Add new .css files here 'css/reset.css', assets.Bundle( # Add new .scss files here 'css/main.scss', filters='scss',
# Asset bundles assets = webassets.Environment(app) # Coffee Scripts scripts_path = os.path.abspath( os.path.join(app.config["BASEDIR"], "static/scripts")) coffee_scripts = [ "scripts/%s" % (f, ) for f in os.listdir(scripts_path) if f.endswith(".coffee") ] assets.register( "coffee_scripts", webassets.Bundle(*coffee_scripts, filters=("coffeescript,rjsmin" if app.config["ASSETS_MINIFY"] else "coffeescript"), output="scripts/generated.js")) # Less stylesheets styles_path = os.path.abspath( os.path.join(app.config["BASEDIR"], "static/styles")) less_stylesheets = [ "styles/%s" % (f, ) for f in os.listdir(styles_path) if f.endswith(".less") ] assets.register( "less_stylesheets", webassets.Bundle( *less_stylesheets, filters=("less,cssmin" if app.config["ASSETS_MINIFY"] else "less"),
# Tell flask-assets where to look for our javascript and css files. env.load_path = [ os.path.join(os.path.dirname(__file__), 'css'), os.path.join(os.path.dirname(__file__), 'angular'), os.path.join(os.path.dirname(__file__), 'bower_components'), os.path.join(os.path.dirname(__file__), 'graphics'), ] env.register( 'portofolio-script', assets.Bundle( 'jquery/dist/jquery.js', 'angular/angular.js', 'angular-route/angular-route.js', 'angular-ui-router/release/angular-ui-router.min.js', 'angular-bootstrap/ui-bootstrap-tpls.min.js', 'angular-ui-utils/ui-utils.js', 'angular-inview/angular-inview.js', 'angular-scrollto/angular-scrollto.js', 'portofolio.js', #filters='jsmin', output='portofolio-script.js')) env.register( 'portofolio-style', assets.Bundle( 'bootstrap/dist/css/bootstrap.min.css', 'portofolio.css', 'navbar.css', 'banner.css', 'product.css', 'projects.css',
env.config['sass_bin'] = '/usr/local/bin/sass' # Tell flask-assets where to look for our sass files. env.load_path = [ os.path.join(os.path.dirname(__file__), 'assets/stylesheets'), os.path.join(os.path.dirname(__file__), 'assets'), os.path.join(os.path.dirname(__file__), 'assets/stylesheets/stylesheets/govuk_frontend_toolkit'), os.path.join(os.path.dirname(__file__), 'assets/stylesheets/govuk_template') ] scss = get_filter('scss', as_output=True) env.register('css_all', assets.Bundle('main.scss', filters='scss', output='css_all.css')) env.register( 'css_govuk-template', assets.Bundle('govuk_template/govuk-template.scss', filters='scss', output='stylesheets/govuk-template.css', depends='*.scss')) env.register( 'css_govuk-template-ie6', assets.Bundle('govuk_template/govuk-template-ie6.scss', filters='scss', output='stylesheets/govuk-template-ie6.css', depends='*.scss'))