def __init__(self): project_dir = os.path.abspath( os.path.dirname(os.path.dirname(__file__))) app_dir = os.path.join(project_dir, 'app') public_dir = os.path.join(project_dir, 'public') self.gears = Environment(public_dir, fingerprinting=False, manifest_path=False) self.gears.finders.register( ExtFinder([app_dir], ['.coffee', '.scss', '.handlebars', '.js', '.css'], [ 'app.handlebars', 'partials/header.handlebars', 'partials/footer.handlebars' ])) self.gears.compilers.register('.scss', LibsassCompiler.as_handler()) self.gears.compilers.register('.coffee', CoffeeScriptCompiler.as_handler()) self.gears.compilers.register('.handlebars', CustomHandlebarsCompiler.as_handler()) if env.is_prod(): self.gears.compressors.register('text/css', CleanCSSCompressor.as_handler()) self.gears.register_defaults()
def __init__(self): project_dir = os.path.abspath( os.path.dirname(os.path.dirname(__file__))) app_dir = os.path.join(project_dir, 'app') public_dir = os.path.join(project_dir, 'public') self.gears = Environment(public_dir, public_assets=[self._public_assets], fingerprinting=False, manifest_path=False) self.gears.finders.register( ExtFinder([app_dir], ['.coffee', '.scss', '.handlebars'])) self.gears.compilers.register('.scss', SCSSCompiler.as_handler()) self.gears.compilers.register('.coffee', CoffeeScriptCompiler.as_handler()) self.gears.compilers.register('.handlebars', CustomHandlebarsCompiler.as_handler()) if env.is_prod(): self.gears.compressors.register('application/javascript', UglifyJSCompressor.as_handler()) self.gears.compressors.register('text/css', CleanCSSCompressor.as_handler()) self.gears.register_defaults()
def __init__(self): project_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) app_dir = os.path.join(project_dir, 'app') public_dir = os.path.join(project_dir, 'public') self.gears = Environment(public_dir, public_assets=[self._public_assets]) self.gears.finders.register(ExtFinder([app_dir], ['.coffee', '.scss', '.handlebars'])) self.gears.compilers.register('.scss', SCSSCompiler.as_handler()) self.gears.compilers.register('.coffee', CoffeeScriptCompiler.as_handler()) self.gears.compilers.register('.handlebars', CustomHandlebarsCompiler.as_handler()) if env.is_prod(): self.gears.compressors.register('application/javascript', UglifyJSCompressor.as_handler()) self.gears.compressors.register('text/css', CleanCSSCompressor.as_handler()) self.gears.register_defaults()
def __init__(self): project_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) app_dir = os.path.join(project_dir, 'app') public_dir = os.path.join(project_dir, 'public') self.gears = Environment(public_dir, fingerprinting=False, manifest_path=False) self.gears.finders.register(ExtFinder( [app_dir], ['.coffee', '.scss', '.handlebars', '.js', '.css'], ['app.handlebars', 'partials/header.handlebars', 'partials/footer.handlebars'] )) self.gears.compilers.register('.scss', LibsassCompiler.as_handler()) self.gears.compilers.register('.coffee', CoffeeScriptCompiler.as_handler()) self.gears.compilers.register('.handlebars', CustomHandlebarsCompiler.as_handler()) if env.is_prod(): self.gears.compressors.register('text/css', CleanCSSCompressor.as_handler()) self.gears.register_defaults()
def __init__(self): project_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) app_dir = os.path.join(project_dir, "app") public_dir = os.path.join(project_dir, "public") self.gears = Environment(public_dir, fingerprinting=False, manifest_path=False) self.gears.finders.register( ExtFinder( [app_dir], [".coffee", ".scss", ".handlebars", ".js", ".css"], ["app.handlebars", "partials/header.handlebars", "partials/footer.handlebars"], ) ) self.gears.compilers.register(".scss", SCSSCompiler.as_handler()) self.gears.compilers.register(".coffee", CoffeeScriptCompiler.as_handler()) self.gears.compilers.register(".handlebars", CustomHandlebarsCompiler.as_handler()) if env.is_prod(): self.gears.compressors.register("text/css", CleanCSSCompressor.as_handler()) self.gears.register_defaults()
super(RegexConverter, self).__init__(url_map) self.regex = items[0] app.url_map.converters['regex'] = RegexConverter gears = Gears( compilers={ '.styl': StylusCompiler.as_handler(), '.less': LESSCompiler.as_handler(), '.coffee': CoffeeScriptCompiler.as_handler(), '.sass': SASSCompiler.as_handler(), '.scss': SASSCompiler.as_handler() }, compressors={ 'text/css': CleanCSSCompressor.as_handler(), 'text/javascript': UglifyJSCompressor.as_handler() }, ) gears.init_app(app) db = SQLAlchemy(app) login_manager = LoginManager() login_manager.init_app(app) login_manager.login_view = 'login' # admin = Admin(app) babel = Babel(app) thumb = Thumbnail(app) mail = Mail(app) # rq = RQ(app)
from flask import Flask, render_template from flask_gears import Gears from gears_stylus import StylusCompiler from gears_clean_css import CleanCSSCompressor app = Flask(__name__) gears = Gears( compilers={'.styl': StylusCompiler.as_handler()}, compressors={'text/css': CleanCSSCompressor.as_handler()}, ) gears.init_app(app) @app.route('/') def index(): return render_template('index.html') if __name__ == '__main__': app.run(debug=True)
from gears.compressors import SlimItCompressor from gears_stylus import StylusCompiler from gears_clean_css import CleanCSSCompressor from gears_coffeescript import CoffeeScriptCompiler gears = Gears() _compilers = { '.styl': StylusCompiler.as_handler(), '.coffee': CoffeeScriptCompiler.as_handler() } _compressors = { "text/css": CleanCSSCompressor.as_handler(), "application/javascript": SlimItCompressor.as_handler() } def setup_gears(app): gears.init_app(app) setup_gears_environment(app) setup_compressors(app) setup_compilers(app) def gears_environment(app): return app.extensions['gears']['environment']