コード例 #1
0
def compile_static_assets(assets):
    """Configure and build asset bundles."""
    main_style_bundle = Bundle('src/less/*.less',
                               'main_bp/homepage.less',
                               filters='less,cssmin',
                               output='dist/css/landing.css',
                               extra={'rel': 'stylesheet/css'
                                      })  # Main Stylesheets Bundle
    main_js_bundle = Bundle(
        'src/js/main.js', filters='jsmin',
        output='dist/js/main.min.js')  # Main JavaScript Bundle
    admin_style_bundle = Bundle('src/less/*.less',
                                'admin_bp/admin.less',
                                filters='less,cssmin',
                                output='dist/css/account.css',
                                extra={'rel': 'stylesheet/css'
                                       })  # Admin Stylesheets Bundle
    assets.register('main_styles', main_style_bundle)
    assets.register('main_js', main_js_bundle)
    assets.register('admin_styles', admin_style_bundle)
    if app.config[
            'FLASK_ENV'] == 'development':  # Only rebuild bundles in development
        main_style_bundle.build()
        main_js_bundle.build()
        admin_style_bundle.build()
    return assets
コード例 #2
0
def compile_static_assets(app):
    """Configure static asset bundles."""
    assets = Environment(app)
    Environment.auto_build = True
    Environment.debug = False
    # Stylesheets Bundles
    account_less_bundle = Bundle(
        'src/less/account.less',
        filters='less,cssmin',
        output='dist/css/account.css',
        extra={'rel': 'stylesheet/less'}
    )
    dashboard_less_bundle = Bundle(
        'src/less/dashboard.less',
        filters='less,cssmin',
        output='dist/css/dashboard.css',
        extra={'rel': 'stylesheet/less'}
    )
    # JavaScript Bundle
    js_bundle = Bundle(
        'src/js/main.js',
        filters='jsmin',
        output='dist/js/main.min.js'
    )
    # Register assets
    assets.register('account_less_bundle', account_less_bundle)
    assets.register('dashboard_less_bundle', dashboard_less_bundle)
    assets.register('js_all', js_bundle)
    # Build assets
    account_less_bundle.build()
    dashboard_less_bundle.build()
    js_bundle.build()
コード例 #3
0
ファイル: assets.py プロジェクト: Teluser/domitory-project
def compile_static_assets(app):
    """Configure static asset bundles."""
    assets = Environment(app)
    Environment.auto_build = True
    Environment.debug = False
    # Stylesheets Bundles
    account_less_bundle = Bundle(
        "src/less/account.less",
        filters="less,cssmin",
        output=f"dist/css/account.css",
        extra={"rel": "stylesheet/less"},
    )
    dashboard_less_bundle = Bundle(
        "src/less/dashboard.less",
        filters="less,cssmin",
        output=f"dist/css/dashboard.css",
        extra={"rel": "stylesheet/less"},
    )
    # JavaScript Bundle
    js_bundle = Bundle("src/js/main.js",
                       filters="jsmin",
                       output="dist/js/main.min.js")
    # Register assets
    assets.register("account_less_bundle", account_less_bundle)
    assets.register("dashboard_less_bundle", dashboard_less_bundle)
    assets.register("js_all", js_bundle)
    # Build assets
    account_less_bundle.build()
    dashboard_less_bundle.build()
    js_bundle.build()
コード例 #4
0
def compile_static_assets(assets):
    """
    Compile stylesheets if in development mode.
    :param assets: Flask-Assets Environment
    :type assets: Environment
    """
    assets.auto_build = True
    assets.debug = False
    less_bundle = Bundle('less/*.less',
                         filters='less,cssmin',
                         output='dist/css/styles.css',
                         extra={'rel': 'stylesheet/less'})
    assets.register('less_all', less_bundle)
    if app.config['FLASK_ENV'] == 'development':
        less_bundle.build()
    return assets


#
# def register_database(app):
#     from db import database
#     app.config('config.Config')
#     app.config["db"] = Moist_Hist(os.path.join(os.path.expanduser("~"), "moisthist.sqlite"))
コード例 #5
0
def build_assets(app):
    assets = Environment(app)

    # Automatically build and merge assets.
    Environment.auto_build = True
    Environment.debug = False

    # Miniaturize if not in debug mode.
    if DEBUG_MODE == 'False':
        css_min = 'cssmin'
        js_min = 'jsmin'
    else:
        css_min = None
        js_min = None

    css_bundle = Bundle(
        'builds/projects/japan_real_estate_choropleth/style.css',
        'builds/projects/japan_real_estate_choropleth/japan_real_estate_choropleth.css',
        'builds/media_res.css',
        'builds/projects/japan_real_estate_choropleth/japan_real_estate_choropleth_media_res.css',
        filters=css_min,
        output='dist/css/japan_real_estate_choropleth.css')

    js_bundle = Bundle(
        'builds/main.js',
        'builds/projects/japan_real_estate_choropleth/nav.js',
        'builds/projects/japan_real_estate_choropleth/japan_real_estate_choropleth.js',
        filters=js_min,
        output='dist/js/japan_real_estate_choropleth.js')

    # Register and build in development mode.
    assets.register('japan_real_estate_choropleth_css', css_bundle)
    assets.register('japan_real_estate_choropleth_js', js_bundle)

    if DEBUG_MODE == 'True':
        css_bundle.build()
        js_bundle.build()
コード例 #6
0
def compile_static_assets(app):
    """Configure static asset bundles."""
    assets = Environment(app)
    Environment.auto_build = True
    Environment.debug = True
    # Stylesheets Bundles
    account_less_bundle = Bundle('src/less/account.less',
                                 filters='less,cssmin',
                                 output='dist/css/account.css',
                                 extra={'rel': 'stylesheet/less'})
    dashboard_less_bundle = Bundle('src/less/dashboard.less',
                                   filters='less,cssmin',
                                   output='dist/css/dashboard.css',
                                   extra={'rel': 'stylesheet/less'})
    # JavaScript Bundle
    js_bundle = Bundle('src/js/main.js',
                       filters='jsmin',
                       output='dist/js/main.min.js')

    boat_js_bundle = Bundle('src/js/leaflet.js',
                            'src/js/leaflet-ruler.js',
                            'src/js/leaflet.rotatedMarker.js',
                            'src/js/main.js',
                            'src/js/init-map.js',
                            'src/js/boat-icons.js',
                            'src/js/race-map.js',
                            'src/js/sailnavsim-api.js',
                            'src/js/ws-map.js',
                            filters='jsmin',
                            output='dist/js/boat.min.js')

    boat_css_bundle = Bundle('src/css/leaflet-ruler.css',
                             'src/css/leaflet.css',
                             output='dist/css/boat.min.css')

    # Register assets
    assets.register('account_less_bundle', account_less_bundle)
    assets.register('dashboard_less_bundle', dashboard_less_bundle)
    assets.register('js_all', js_bundle)
    assets.register('boat_js_bundle', boat_js_bundle)

    # Build assets
    account_less_bundle.build()
    dashboard_less_bundle.build()
    js_bundle.build()
    boat_js_bundle.build()
コード例 #7
0
def compile_assets(app):
    """Configure authorization asset bundles."""
    assets = Environment(app)
    Environment.auto_build = True
    Environment.debug = False
    less_bundle = Bundle('less/*.less',
                         filters='less,cssmin',
                         output='dist/css/styles.css',
                         extra={'rel': 'stylesheet/less'})
    js_bundle = Bundle('js/*.js',
                       filters='jsmin',
                       output='dist/js/main.js')
    assets.register('less_all', less_bundle)
    assets.register('js_all', js_bundle)
    if app.config['FLASK_ENV'] == 'development':
        less_bundle.build(force=True)
        js_bundle.build()
    else:
        less_bundle.build(force=False)
        js_bundle.build()
コード例 #8
0
def compile_static_assets(app):

    #Configures static asset bundles.
    assets = Environment(app)
    Environment.auto_build = True
    Environment.debug = False

    # Stylesheets Bundles
    dashboard_less_bundle = Bundle('src/less/dashboard.less',
                                   filters='less,cssmin',
                                   output=f'dist/css/dashboard.css',
                                   extra={'rel': 'stylesheet/less'})

    login_less_bundle = Bundle('src/less/login.less',
                               filters='less,cssmin',
                               output=f'dist/css/login.css',
                               extra={'rel': 'stylesheet/less'})

    signup_less_bundle = Bundle('src/less/signup.less',
                                filters='less,cssmin',
                                output=f'dist/css/signup.css',
                                extra={'rel': 'stylesheet/less'})

    # JavaScript Bundle
    js_bundle = Bundle('src/js/main.js',
                       filters='jsmin',
                       output='dist/js/main.min.js')

    # Registers assets
    assets.register('dashboard_less_bundle', dashboard_less_bundle)
    assets.register('login_less_bundle', login_less_bundle)
    assets.register('signup_less_bundle', signup_less_bundle)
    assets.register('js_all', js_bundle)

    # Builds assets
    dashboard_less_bundle.build()
    login_less_bundle.build()
    signup_less_bundle.build()
    js_bundle.build()
コード例 #9
0
def compile_static_assets(assets):
    """Create stylesheet bundles."""
    assets.auto_build = True
    assets.debug = False
    common_less_bundle = Bundle(
        'src/less/*.less',
        filters='less,cssmin',
        output='dist/css/style.css',
        extra={'rel': 'stylesheet/less'}
    )
    home_less_bundle = Bundle(
        'home_bp/less/home.less',
        filters='less,cssmin',
        output='dist/css/home.css',
        extra={'rel': 'stylesheet/less'}
    )
    profile_less_bundle = Bundle(
        'profile_bp/less/profile.less',
        filters='less,cssmin',
        output='dist/css/profile.css',
        extra={'rel': 'stylesheet/less'}
    )
    product_less_bundle = Bundle(
        'products_bp/less/products.less',
        filters='less,cssmin',
        output='dist/css/products.css',
        extra={'rel': 'stylesheet/less'}
    )
    assets.register('common_less_bundle', common_less_bundle)
    assets.register('home_less_bundle', home_less_bundle)
    assets.register('profile_less_bundle', profile_less_bundle)
    assets.register('product_less_bundle', product_less_bundle)
    if app.config['FLASK_ENV'] == 'development':
        common_less_bundle.build()
        home_less_bundle.build()
        profile_less_bundle.build()
        product_less_bundle.build()
    return assets
コード例 #10
0
def compile_static_assets(assets):
    """Create stylesheet bundles."""
    assets.auto_build = True
    assets.debug = False
    common_style_bundle = Bundle(
        "src/less/*.less",
        filters="less,cssmin",
        output="dist/css/style.css",
        extra={"rel": "stylesheet/less"},
    )
    home_style_bundle = Bundle(
        "home_bp/less/home.less",
        filters="less,cssmin",
        output="dist/css/home.css",
        extra={"rel": "stylesheet/less"},
    )
    profile_style_bundle = Bundle(
        "profile_bp/less/profile.less",
        filters="less,cssmin",
        output="dist/css/profile.css",
        extra={"rel": "stylesheet/less"},
    )
    product_style_bundle = Bundle(
        "products_bp/less/products.less",
        filters="less,cssmin",
        output="dist/css/products.css",
        extra={"rel": "stylesheet/less"},
    )
    assets.register("common_style_bundle", common_style_bundle)
    assets.register("home_style_bundle", home_style_bundle)
    assets.register("profile_style_bundle", profile_style_bundle)
    assets.register("product_style_bundle", product_style_bundle)
    if app.config["FLASK_ENV"] == "development":
        common_style_bundle.build()
        home_style_bundle.build()
        profile_style_bundle.build()
        product_style_bundle.build()
    return assets
コード例 #11
0
def compile_main_assets(app):
    """Configure landing asset bundles."""
    assets = Environment(app)
    Environment.auto_build = True
    Environment.debug = False
    # Stylesheets Bundle
    css_bundle = Bundle(
        'bower_components/startbootstrap-sb-admin/vendor/fontawesome-free/css/all.min.css',
        'bower_components/startbootstrap-sb-admin/css/sb-admin-2.css',
        'bower_components/startbootstrap-sb-admin/vendor/datatables/dataTables.bootstrap4.min.css',
        filters='cssmin',
        output='dist/css/main.css',
        extra={'rel': 'stylesheet/less'}
    )
    # JavaScript Bundle
    js_bundle = Bundle(
        'bower_components/jquery/dist/jquery.js',
        'bower_components/startbootstrap-sb-admin/js/sb-admin-2.js',
        'bower_components/startbootstrap-sb-admin/vendor/bootstrap/js/bootstrap.bundle.js',
        'bower_components/startbootstrap-sb-admin/vendor/jquery-easing/jquery.easing.min.js',
        'bower_components/startbootstrap-sb-admin/vendor/datatables/jquery.dataTables.min.js',
        'bower_components/startbootstrap-sb-admin/vendor/datatables/dataTables.bootstrap4.min.js',
        'bower_components/startbootstrap-sb-admin/js/demo/datatables-demo.js',
        filters='jsmin',
        output='dist/js/main.min.js'
    )
    dashboard_bundle = Bundle(
        'bower_components/startbootstrap-sb-admin/vendor/chart.js/Chart.min.js',
        'bower_components/startbootstrap-sb-admin/js/demo/chart-area-demo.js',
        'bower_components/startbootstrap-sb-admin/js/demo/chart-pie-demo.js',
        filters='jsmin',
        output='dist/js/dashboard.min.js'
    )
    # Register assets
    assets.register('css_all', css_bundle)
    assets.register('js_all', js_bundle)
    assets.register('dashboard_all', dashboard_bundle)
    # Build assets in development mode
    if app.config['FLASK_ENV'] == 'development':
        css_bundle.build(force=True)
        js_bundle.build()
        dashboard_bundle.build()
コード例 #12
0
ファイル: assets.py プロジェクト: alpdal/Clustify
def compile_static_assets(assets):
    """Configure and build asset bundles."""
    main_style_bundle_landing = Bundle(
        'src/less/home.less',
        filters='less,cssmin',
        output='dist/css/home.css',
        extra={'rel': 'stylesheet/css'})  # Home Page Stylesheets Bundle
    main_style_bundle_app = Bundle('src/less/app.less',
                                   filters='less,cssmin',
                                   output='dist/css/app.css',
                                   extra={'rel': 'stylesheet/css'
                                          })  # App Pages Stylesheets Bundle
    main_js_bundle = Bundle(
        'src/js/main.js', filters='jsmin',
        output='dist/js/main.min.js')  # Main JavaScript Bundle

    assets.register('main_styles_landing', main_style_bundle_landing)
    assets.register('main_styles_app', main_style_bundle_app)
    assets.register('main_js', main_js_bundle)

    main_style_bundle_landing.build()
    main_style_bundle_app.build()
    main_js_bundle.build()
コード例 #13
0
def compile_static_assets(assets):
    """Configure and build asset bundles."""
    """Configure and build asset bundles."""
    assets.debug = False

    # Stylesheets Bundles
    main_style_bundle = Bundle('src/less/*.less',
                               'main_bp/homepage.less',
                               filters='less,cssmin',
                               output='dist/css/landing.css',
                               extra={'rel': 'stylesheet/css'})

    auth_style_bundle = Bundle('src/less/*.less',
                               'auth_bp/account.less',
                               filters='less,cssmin',
                               output='dist/css/aulanding.css',
                               extra={'rel': 'stylesheet/less'})

    admin_style_bundle = Bundle('src/less/*.less',
                                filters='less,cssmin',
                                output='dist/css/admlanding.css',
                                extra={'rel': 'stylesheet/less'})

    # Register assets
    assets.register('main_styles', main_style_bundle)
    assets.register('auth_styles', auth_style_bundle)
    assets.register('admin_styles', admin_style_bundle)

    # Build assets
    if app.config[
            'FLASK_ENV'] == 'development':  # Only rebuild bundles in development
        main_style_bundle.build()
        auth_style_bundle.build()
        admin_style_bundle.build()

    return assets
コード例 #14
0
    access_token_params=None,
    authorize_url="https://osu.ppy.sh/oauth/authorize",
    authorize_params=None,
    api_base_url="https://osu.ppy.sh/api/v2/",
    client_kwargs={"scope": "identify public"},
)

########## Assets

assets = Environment(app)
assets.debug = True
css = Bundle("src/main.css", output="dist/main.css", filters="postcss")
js = Bundle("src/*.js", output="dist/main.js")
assets.register("css", css)
assets.register("js", js)
css.build()
js.build()

########## Routes


@app.route("/")
def index():
    tournaments = Tournament.query.all()
    return render_template("index.html", tournaments=tournaments)


@app.route("/login")
def login():
    redirect_uri = url_for("authorize", _external=True)
    return oauth.osu.authorize_redirect(redirect_uri)
コード例 #15
0
ファイル: __init__.py プロジェクト: SalasC2/enodo_app
import os
from flask import Flask
from flask_assets import Environment, Bundle

app = Flask(__name__)

js = Bundle("js/map.js", 
            output='gen/main.js')

assets = Environment(app)
assets.register("main.js", js)
js.build()

from app import routes
コード例 #16
0
def create_app(config_filename="config"):
    """Flask application factory.

    This is the flask application factory for this project. It loads the
    other submodules used to runs the collectives website. It also creates
    the blueprins and init apps.

    :param config_filename: name of the application config file.
    :type config_filename: string

    :return: A flask application for collectives
    :rtype: :py:class:`flask.Flask`
    """
    app = Flask(__name__, instance_relative_config=True)
    app.wsgi_app = ReverseProxied(app.wsgi_app)

    # Config options - Make sure you created a 'config.py' file.
    app.config.from_object(config_filename)
    app.config.from_pyfile("config.py")
    # To get one variable, tape app.config['MY_VARIABLE']

    fileConfig(app.config["LOGGING_CONFIGURATION"],
               disable_existing_loggers=False)

    # Initialize plugins
    models.db.init_app(app)
    auth.login_manager.init_app(app)  # app is a Flask object
    api.marshmallow.init_app(app)
    profile.images.init_app(app)
    extranet.api.init_app(app)
    payline.api.init_app(app)

    app.context_processor(jinja.helpers_processor)

    _migrate = Migrate(app, models.db)

    with app.app_context():
        # Initialize asset compilation
        assets = Environment(app)

        filters = "libsass"
        if app.config["ENV"] == "production":
            filters = "libsass, cssmin"
            assets.auto_build = False
            assets.debug = False
        scss = Bundle(
            "css/all.scss",
            filters=filters,
            depends=("/static/css/**/*.scss"),
            output="dist/css/all.css",
        )

        assets.register("scss_all", scss)
        scss.build()

        # Register blueprints
        app.register_blueprint(root.blueprint)
        app.register_blueprint(profile.blueprint)
        app.register_blueprint(api.blueprint)
        app.register_blueprint(administration.blueprint)
        app.register_blueprint(auth.blueprint)
        app.register_blueprint(event.blueprint)
        app.register_blueprint(payment.blueprint)
        app.register_blueprint(technician.blueprint)
        app.register_blueprint(activity_supervison.blueprint)

        # Error handling
        app.register_error_handler(werkzeug.exceptions.NotFound,
                                   error.not_found)
        app.register_error_handler(werkzeug.exceptions.InternalServerError,
                                   error.server_error)

        forms.configure_forms(app)
        forms.csrf.init_app(app)
        # Initialize DB
        # models.db.create_all()

        populate_db(app)

        if app.config["STATISTICS_ENABLED"]:
            Statistics(
                app,
                models.db,
                models.Request,
                access.technician_required_f,
                disable_f=statistics.disable_f,
            )

        return app
コード例 #17
0
def compile_assets(assets):
    """Create stylesheet bundles"""
    assets.auto_build = True
    assets.debug = False

    user_views_css_bundle = Bundle('user_views/user_views.css',
                                   output='gen/user_views.css',
                                   extra={'rel': 'stylesheet/css'})
    search_js = Bundle('search_views/search.js',
                       output='gen/search.js',
                       filters='jsmin')
    search_css = Bundle('search_views/search.css',
                        output='gen/search.css',
                        filters='cssmin')

    # auth_css = Bundle(
    #     'auth_bp/auth.css',
    #     output='gen/auth.css',
    #     filters='cssmin'
    # )

    auth_js = Bundle('auth_bp/auth.js', output='gen/auth.js', filters='jsmin')

    view_profile_js = Bundle('user_views/view_profile.js',
                             output='gen/user_views.js',
                             filters='jsmin')

    user_feed_js = Bundle('user_views/user_feed.js',
                          output='gen/user_feed.js',
                          filters='jsmin')

    route_details_js = Bundle('route_views/route_details.js',
                              output="gen/route_views.js",
                              filters='jsmin')

    location_js = Bundle('user_views/location.js',
                         output="gen/location.js",
                         filters="jsmin")

    assets.register('user_views_css_bundle', user_views_css_bundle)
    assets.register('search_js', search_js)
    assets.register('search_css', search_css)
    # assets.register('auth_css', auth_css)
    assets.register('auth_js', auth_js)
    assets.register('view_profile_js', view_profile_js)
    assets.register('route_details_js', route_details_js)
    assets.register('user_feed_js', user_feed_js)
    assets.register('location_js', location_js)
    if app.config['FLASK_ENV'] == 'development':
        search_js.build()
        search_css.build()
        # auth_css.build()
        auth_js.build()
        view_profile_js.build()
        route_details_js.build()
        user_feed_js.build()
        location_js.build()
    return assets
コード例 #18
0
ファイル: core.py プロジェクト: shreezus/pybossa
def setup_assets(app):
    """Setup assets."""
    from flask_assets import Environment, Bundle
    assets = Environment(app)
    all_assets = [{
        'name':
        'js_base',
        'args': [
            'js/vendor/jquery-2.2.3.js', 'js/vendor/bootstrap.js',
            'js/vendor/modernizr.min.js', 'js/flashmessages.js',
            'js/vendor/cookieconsent.min.js'
        ],
        'kwargs': {
            'filters': 'jsmin',
            'output': 'js/gen/default.min.js'
        }
    }, {
        'name': 'js_multi',
        'args': ['js/vendor/multi.js'],
        'kwargs': {
            'filters': 'jsmin',
            'output': 'js/gen/multi.min.js'
        }
    }, {
        'name': 'js_enrich',
        'args': ['js/vendor/jsgrid.min.js'],
        'kwargs': {
            'filters': 'jsmin',
            'output': 'js/gen/enrichment.min.js'
        }
    }, {
        'name':
        'js_project_new',
        'args':
        ['js/forms.js', 'js/vendor/select2.min.js', 'js/project_forms.js'],
        'kwargs': {
            'filters': 'jsmin',
            'output': 'js/gen/projects_new.min.js'
        }
    }, {
        'name':
        'js_full',
        'args': [
            'js/vendor/jquery-2.2.3.js', 'js/vendor/bootstrap.js',
            'js/vendor/modernizr.min.js', 'js/flashmessages.js',
            'js/vendor/cookieconsent.min.js', 'js/pybossa/pybossa.js',
            'js/pybossa-player/dist/pybossa-player.min.js'
        ],
        'kwargs': {
            'filters': 'jsmin',
            'output': 'js/gen/full.min.js'
        }
    }, {
        'name':
        'js_taskpresentereditor',
        'args': [
            'vendor/codemirror/codemirror.js',
            'vendor/codemirror/mode/xml/xml.js',
            'vendor/codemirror/mode/javascript/javascript.js',
            'vendor/codemirror/mode/css/css.js',
            'vendor/codemirror/mode/htmlmixed/htmlmixed.js',
            'vendor/codemirror/addons/search/search.js',
            'vendor/codemirror/addons/search/searchcursor.js',
            'vendor/codemirror/addons/search/jump-to-line.js',
            'vendor/codemirror/addons/edit/closebrackets.js',
            'vendor/codemirror/addons/edit/closetag.js',
            'vendor/codemirror/addons/edit/continuelist.js',
            'vendor/codemirror/addons/edit/matchbrackets.js',
            'vendor/codemirror/addons/edit/matchtags.js',
            'vendor/codemirror/addons/edit/trailingspace.js',
            'vendor/codemirror/addons/fold/xml-fold.js',
            'vendor/codemirror/addons/display/fullscreen.js',
            'vendor/codemirror/addons/dialog/dialog.js'
        ],
        'kwargs': {
            'filters': 'jsmin',
            'output': 'js/gen/pybossa.taskpresentereditor.min.js'
        }
    }, {
        'name': 'js_annotationguidelineeditor',
        'args': ['vendor/summernote/summernote.min.js'],
        'kwargs': {
            'output': 'js/gen/pybossa.js_annotationguidelineeditor.min.js'
        }
    }, {
        'name':
        'js_taskbrowse',
        'args': [
            "js/vendor/jquery-ui-1.12.1.min.js", "js/vendor/select2.min.js",
            "vendor/slider/js/bootstrap-slider.js", "js/tasks_browse.js"
        ],
        'kwargs': {
            'filters': 'jsmin',
            'output': 'js/gen/taskbrowse.min.js'
        }
    }, {
        'name':
        'js_projects_update',
        'args': [
            'js/vendor/cropper.min.js', 'js/image_crop.js',
            'js/vendor/select2.min.js', 'js/vendor/jquery-ui-1.12.1.min.js',
            'js/project_forms.js'
        ],
        'kwargs': {
            'filters': 'jsmin',
            'output': 'js/gen/projects_update.min.js'
        }
    }, {
        'name': 'css_pybossa',
        'args': ['sass/_pybossa.scss'],
        'kwargs': {
            'filters': 'libsass',
            'output': 'css/gen/pybossa.min.css',
            'depends': 'sass/**/*.scss'
        }
    }, {
        'name': 'css_multi',
        'args': ['css/multi.css'],
        'kwargs': {
            'output': 'css/gen/multi.min.css',
        }
    }, {
        'name': 'css_enrich',
        'args': ["css/jsgrid.min.css", "css/jsgrid-theme.min.css"],
        'kwargs': {
            'output': 'css/gen/enrichment.min.css'
        }
    }, {
        'name': 'css_blpstrap3_style',
        'args': ["css/bootstrap.blpstrap3.css"],
        'kwargs': {
            'output': 'css/gen/bootstrap.blpstrap3.css'
        }
    }, {
        'name':
        'css_taskbrowse',
        'args': [
            'vendor/slider/css/slider.css', 'css/task_browse.css',
            'css/select2.min.css'
        ],
        'kwargs': {
            'output': 'css/gen/taskbrowse.min.css'
        }
    }]

    for conf in all_assets:
        args = conf.get('args') or []
        kwargs = conf.get('kwargs') or []
        bundle = Bundle(*args, **kwargs)
        assets.register(conf['name'], bundle)
        bundle.build(force=True)
コード例 #19
0
ファイル: assets.py プロジェクト: GreenBlackSky/flask_stuff
def pack_js(assets):
    js_bundle = Bundle('src/js/script.js',
                       filters='jsmin',
                       output='dst/js/script.min.js')
    assets.register('js_assets', js_bundle)
    js_bundle.build()
コード例 #20
0
ファイル: appInit.py プロジェクト: mwhitman189/Kokeshi
def create_app():

    import os
    from os import environ
    import psycopg2
    from flask import Flask
    from flask_sqlalchemy import SQLAlchemy
    from flask_migrate import Migrate
    from flask_heroku import Heroku
    from flask_admin.contrib.sqla import ModelView
    from flask_wtf.csrf import CSRFProtect
    from flask import render_template, request, redirect, jsonify, url_for, flash, session
    from sqlalchemy.orm import relationship, sessionmaker
    from models import User, Order, Customer, Role, OrderDetails, Product, Supplier, Payment, Shipper, users_schema, orders_schema, products_schema, customers_schema, order_details_schema, suppliers_schema, payments_schema, shippers_schema, MyAdminIndexView, UserAdmin, RoleAdmin
    from flask_admin import Admin
    from flask_login import UserMixin, LoginManager, current_user, login_user, logout_user
    from flask_security import SQLAlchemyUserDatastore, Security, utils, login_required
    from wtforms.fields import PasswordField
    from passlib.hash import pbkdf2_sha256
    from flask_marshmallow import Marshmallow
    import stripe
    import datetime
    from flask_mail import Mail, Message
    from decimal import Decimal
    from flask_caching import Cache
    from flask_assets import Environment, Bundle
    from PIL import Image

    APPLICATION_NAME = "Kokeshi"

    app = Flask(__name__)
    csrf.init_app(app)
    app.config.from_pyfile('config_default.cfg')
    assets = Environment(app)

    try:
        app.config.from_envvar('KOKESHI_SETTINGS')
    except:
        pass

    # Flask Security Config
    app.config['SECURITY_REGISTERABLE'] = True

    # Flask-Mail Config
    app.config.update(dict(
        MAIL_SERVER=os.environ['MAIL_SERVER'],
        MAIL_PORT=465,
        MAIL_USERNAME=os.environ['MAIL_USERNAME'],
        MAIL_USE_TLS=False,
        MAIL_USE_SSL=True,
        MAIL_PASSWORD=os.environ['MAIL_PASSWORD'],
        SECURITY_PASSWORD_HASH='pbkdf2_sha512',
        SECURITY_PASSWORD_SALT=os.environ['SECURITY_PASSWORD_SALT']
    ))

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

    # Flask-Assets config
    scss_bundle = Bundle('scss/*.scss',
                         filters='pyscss, cssmin',
                         output='css/styles.css',
                         extra={'rel': 'stylesheet/scss'},
                         )
    js_bundle = Bundle('js/*.js',
                       filters='jsmin',
                       output='js/main.min.js',
                       )
    assets.register('scss_all', scss_bundle)
    assets.register('js_all', js_bundle)
    scss_bundle.build()
    js_bundle.build()

    imagePath = "static/img/artisan-placeholder.jpg"
    outputPath = "static/img/artisan-placeholder.webp"
    quality = "80"

    im = Image.open(imagePath)
    im.save(outputPath, 'webp', quality=quality)

    app.url_map.strict_slashes = False

    # Initialize the SQLAlchemy data store and Flask-Security.
    user_datastore = SQLAlchemyUserDatastore(db, User, Role)
    security = Security(app, user_datastore)

    # Create admin views.
    admin = Admin(app, index_view=MyAdminIndexView())
    admin.add_view(UserAdmin(User, db.session))
    admin.add_view(RoleAdmin(Role, db.session))

    # Stripe payments implementation.
    STRIPE_PUBLISHABLE_KEY = 'pk_test_GM1d2F2DgrIl6jnkIwSaZ8Dd'
    stripe_keys = {
        'secret_key': os.environ['STRIPE_SECRET_KEY'],
        'publishable_key': STRIPE_PUBLISHABLE_KEY
    }

    stripe.api_key = stripe_keys['secret_key']

    #################
    # App functions #
    #################

    #######################
    # User administration #
    #######################

    # Populate the db with products and placeholder data
    """@app.before_first_request
    def before_first_request():
        db.create_all()
        user_datastore.find_or_create_role(
            name='super', description='Super User')
        user_datastore.find_or_create_role(
            name='admin', description='Administrator')
        user_datastore.find_or_create_role(
            name='artisan', description='Artisan')

        encrypted_password = utils.encrypt_password('password')

        if not user_datastore.get_user('*****@*****.**'):
            user_datastore.create_user(
                email='*****@*****.**',
                password=encrypted_password
            )
        if not user_datastore.get_user('*****@*****.**'):
            user_datastore.create_user(
                email='*****@*****.**',
                password=encrypted_password
            )
        if not user_datastore.get_user('*****@*****.**'):
            user_datastore.create_user(
                email='*****@*****.**',
                password=encrypted_password
            )

        db.session.commit()

        user_datastore.add_role_to_user('*****@*****.**', 'super')
        user_datastore.add_role_to_user('*****@*****.**', 'admin')
        user_datastore.add_role_to_user('*****@*****.**', 'artisan')
        db.session.commit()

        db_items = [
            Product(
                name="Zao Kokeshi",
                description="A traditional handcrafted Japanese Kokeshi doll, made with care to the height of the newborn child",
                price=200,
                is_available=True
            ),
            Product(
                name="Yonezawa Kokeshi",
                description="A traditional handcrafted Japanese Kokeshi doll, made with care to the height of the newborn child",
                price=200,
                is_available=True
            ),
            Product(
                name="Sagae Kokeshi",
                description="A traditional handcrafted Japanese Kokeshi doll, made with care to the height of the newborn child",
                price=200,
                is_available=True
            ),
            Product(
                name="Tendo Kokeshi",
                description="A traditional handcrafted Japanese Kokeshi doll, made with care to the height of the newborn child",
                price=200,
                is_available=True
            ),
            Product(
                name="Message",
                description="A handwritten message on the back of the kokeshi doll",
                price=50,
                is_available=True
            ),
            Supplier(
                name="Sato",
                phone="08011112222",
                email="*****@*****.**"
            ),
            Supplier(
                name="Suzuki",
                phone="08011199002",
                email="*****@*****.**"
            ),
            Supplier(
                name="Miyagi",
                phone="090000009999",
                email="*****@*****.**"
            ),
            Shipper(
                companyName="Kuro Neko",
                phone="08051516161",
                email="*****@*****.**",
                contactName="Kurosawa"
            )
        ]

        for item in db_items:
            db.session.add(item)

        db.session.commit()"""

    @app.route('/login', methods=['GET', 'POST'])
    def showLogin():
        """
        Use a custom LoginForm to validate with WTForms
        """
        form = LoginForm()
        if form.validate_on_submit():
            # Login and validate the user.
            # user should be an instance of the `User` class
            login_user(user)

            flask.flash('Logged in successfully.')

            next = flask.request.args.get('next')
            # is_safe_url should check if the url is safe for redirects.
            # See http://flask.pocoo.org/snippets/62/ for an example.
            if not is_safe_url(next):
                return flask.abort(400)

            return flask.redirect(next or flask.url_for('index'))
        return flask.render_template('login.html', form=form)

    @app.route('/logout')
    def showLogout():

        logout_user()
        flask.flash('Logged out successfully.')

        return 'Logged out'

    ##########################
    # General Administration #
    ##########################

    @app.before_request
    def force_https():
        """
        Redirect from http to https
        """
        if os.environ.get('DATABASE_URL') is not None:
            if not request.is_secure:
                url = request.url.replace('http://', 'https://', 1)
                code = 301
                return redirect(url, code=code)

    ##################
    # JSON API calls #
    ##################

    @app.route('/suppliers/JSON')
    @login_required
    def showSuppliersJSON():
        """
        Return order data in JSON
        """
        suppliers = Supplier.query.all()

        return jsonify(suppliers_schema.dump(suppliers).data)

    @app.route('/shippers/JSON')
    @login_required
    def showShippersJSON():
        """
        Return order data in JSON
        """
        shippers = Shipper.query.all()

        return jsonify(shippers_schema.dump(shippers).data)

    @app.route('/products/JSON')
    @login_required
    def showProductsJSON():
        """
        Return order data in JSON
        """
        products = Product.query.all()

        return jsonify(products_schema.dump(products).data)

    @app.route('/orders/JSON')
    @login_required
    def showOrdersJSON():
        """
        Return order data in JSON
        """
        orders = Order.query.all()

        return jsonify(orders_schema.dump(orders).data)

    @app.route('/orders/unfulfilled/JSON')
    @login_required
    def showUnfulfilledOrdersJSON():
        """
        Return unfulfilled order data in JSON
        """
        unful_orders = Order.query.filter_by(wasOrdered=False).all()

        return jsonify(orders_schema.dump(unful_orders).data)

    @app.route('/customers/JSON')
    @login_required
    def showCustomersJSON():
        """
        Return customer data in JSON
        """
        customers = Customer.query.all()

        return jsonify(customers_schema.dump(customers).data)

    #######################
    # Client facing pages #
    #######################

    @app.route('/orders')
    @login_required
    def showOrders():
        """
        Display the supplier - facing orders page. The supplier can accept
        the job, then is directed to the showAcceptOrder
        """
        unaccepted_orders = Order.query.filter_by(wasAccepted=False).all()

        session['supplier'] = current_user.email

        return render_template('auth/unassigned_orders.html', orders=unaccepted_orders)

    @app.route('/orders/<int:order_id>/accepted', methods=['GET', 'POST'])
    @login_required
    def showAcceptOrder(order_id):
        """
        Display the supplier-facing order accepted page.
        """
        order = Order.query.filter_by(orderID=order_id).first()
        supplier = Supplier.query.filter_by(
            email=session['supplier']).first()
        selected_order = Order.query.filter_by(orderID=order_id).first()
        selected_order_details = OrderDetails.query.filter_by(
            order_ID=order_id).first()
        supplier_id = supplier.supplierID

        order.wasAccepted = True
        selected_order.supplier_ID = supplier_id
        db.session.add(selected_order)
        db.session.commit()
        return render_template('auth/selected_order.html', order=selected_order_details)

    @app.route('/', methods=["GET", "POST"])
    @app.route('/home')
    @cache.cached(timeout=86400)
    def showHome():
        """
        Display the landing page.
        """
        return render_template('home.html')

    @app.route('/about')
    @cache.cached(timeout=86400)
    def showAbout():
        """
        Display the About Us page.
        """
        return render_template('about.html')

    @app.route('/design', methods=['GET', 'POST'])
    @cache.cached(timeout=86400)
    def showDesign():
        """
        Display a kokeshi designing page that, when submitted, updates the shopping cart with the order and redirects to the order page.
        """
        # Create a new cart list.
        if 'cart' not in session:
            session['cart'] = []

        if request.method == 'POST':
            # Create a customer object without an email, to attach to the cart
            # items in the session.
            customer = Customer(email="")
            db.session.add(customer)
            db.session.commit()

            # Create an order object and tie it to the customer.
            order = Order(customer_ID=customer.customerID)
            db.session.add(order)
            db.session.commit()

            product = Product.query.filter_by(
                name=request.form['item']).one()

            # Assign the order to the customer using the orderID
            customer.order_ID = order.orderID

            if request.form.get('is-message', False) == 'on':
                order_details = OrderDetails(
                    item=request.form['item'],
                    name=request.form['name'],
                    dob=request.form['dob'],
                    height=request.form['height'],
                    weight=request.form['weight'],
                    is_message=True,
                    message=request.form['message'],
                    order_ID=order.orderID,
                    customer_ID=customer.customerID,
                    product_ID=product.productID
                )

            else:
                order_details = OrderDetails(
                    item=request.form['item'],
                    name=request.form['name'],
                    dob=request.form['dob'],
                    height=request.form['height'],
                    weight=request.form['weight'],
                    is_message=False,
                    order_ID=order.orderID,
                    customer_ID=customer.customerID,
                    product_ID=product.productID
                )

            # Set the price of the item, dependent on the presence or absence of a message.
            if request.form.get('is-message', False) == 'on':
                price = 250
            else:
                price = 200

            order.price = price

            db.session.add(customer)
            db.session.add(order)
            db.session.add(order_details)
            db.session.commit()

            # Append the item to the cart.
            session['cart'].append(
                {
                    'itemID': order_details.orderDetailsID,
                    'item': order_details.item,
                    'name': order_details.name,
                    'dob': order_details.dob,
                    'height': order_details.height,
                    'weight': order_details.weight,
                    'isMessage': order_details.is_message,
                    'message': order_details.message,
                    'product': product.name,
                    'price': price,
                    'orderID': order_details.order_ID
                }
            )

            # Create a session variable to select the customer in order to append information.
            session['customer_ID'] = customer.customerID

            flash("Success! Your order for '%s kokeshi' has been added to your cart." %
                  order_details.name)

            return redirect(url_for('showOrder'))

        else:
            return render_template('design.html')

    @app.route('/setCart')
    def setCart():
        cartObj = session['cart']
        cartJSON = jsonify(cartObj)
        return cartJSON

    @app.route('/removeItem/<int:item_id>', methods=["GET", "POST"])
    def removeItem(item_id):
        """
        Remove the selected item from the cart.
        """
        # Check for the existence of an item, then convert it to an int
        if item_id is not None:
            item_id = int(item_id)

        try:
            session['cart'][:] = [d for d in session['cart']
                                  if d.get('itemID') != item_id]
        except:
            msg = "There were no items to remove"
            print(msg)
        return redirect(url_for('showOrder'))

    @app.route('/order', methods=["GET", "POST"])
    def showOrder():
        """
        Display the order page - - a list of all the items in the cart.
        """

        return render_template('order.html')

    @app.route('/checkout', methods=['GET', 'POST'])
    def showCheckout():
        """
        Display the checkout page, which displays the total and a Stripe payments button.
        """
        amount_usd = 0

        # Add up the total of all the items in the cart
        for item in session['cart']:
            amount_usd += item['price']

        # Calculate the amount in US cents for Stripe
        amount_cents = amount_usd * 100

        return render_template(
            'auth/index.html',
            key=stripe_keys['publishable_key'],
            amount_usd=amount_usd,
            amount_cents=amount_cents,
            cart=session['cart']
        )

    @app.route('/charge', methods=['GET', 'POST'])
    def charge():
        db_customer = Customer.query.filter_by(
            customerID=session['customer_ID']).one()
        # Amount in cents
        amount = 0
        items = []
        for item in session['cart']:
            # Add the item prices in cents.
            amount += item['price'] * 100
            items.append(item['item'])

        customer = stripe.Customer.create(
            email=request.form['stripeEmail'],
            source=request.form['stripeToken']
        )

        # Create a session variable with the customer's email for sending a
        # confirmation email.
        session['customer_email'] = request.form['stripeEmail']

        # Create a Stripe charge object which sends a confirmation email.
        charge = stripe.Charge.create(
            customer=customer.id,
            amount=amount,
            currency='usd',
            description='KokeMama Charge',
            receipt_email=session['customer_email']
        )

        # Attempt to add customer data from the stripe input to the customer
        # object
        try:
            db_customer.email = request.form['stripeEmail']
        except:
            print("There is no 'stripeEmail' key")
        try:
            db_customer.name = charge.source.name
        except:
            print("There is no 'stripeName' key")
        try:
            db_customer.address1 = charge.source.address_line1
        except:
            print("There is no 'stripeShippingAddressLine1' key")
        try:
            db_customer.zipCode = charge.source.address_zip
        except:
            print("There is no 'stripeShippingAddressZip' key")
        try:
            db_customer.state = charge.source.address_state
        except:
            print("There is no 'stripeShippingAddressState' key")
        try:
            db_customer.city = charge.source.address_city
        except:
            print("There is no 'stripeShippingAddressCity' key")
        try:
            db_customer.country = charge.source.address_country
        except:
            print("There is no 'stripeShippingAddressCountry' key")

        db.session.add(db_customer)
        db.session.commit()

        return redirect(url_for('showConfirm'))

    @app.route('/confirmation')
    def showConfirm():
        """
        Display the order confirmation page after an order is submitted.
        """
        # Get the customer from the db using the 'customer_ID' session variable
        db_customer = Customer.query.filter_by(
            customerID=session['customer_ID']).one()

        # Create a list of the cart items for use in the email's message body
        items = [dic['item'] for dic in session['cart'] if 'item' in dic]

        # Use the first item in the cart to obtain the 'orderID'. If None,
        # display 'design' link
        try:
            firstItem = session['cart'][0]
            orderID = firstItem['orderID']

            msg = Message(
                'Confirmation', sender='*****@*****.**', recipients=[session['customer_email']])
            msg.body = "Thank you for your order of: %s. Your order number is: %d." % (
                items, orderID)
            mail.send(msg)

            # Clear the cart after payment is received and confirmation is sent.
            session['cart'] = []

            return render_template('auth/confirmation.html')
        except:
            return redirect(url_for('showHome'))

    @app.route('/contact', methods=['GET', 'POST'])
    @cache.cached(timeout=86400)
    def showContact():
        """
        Display the contact information page.
        """
        if request.method == 'POST':
            msg = Message(
                'Contact', sender='*****@*****.**', recipients=['*****@*****.**'])
            msg.body = "Customer name: %s\n" % (
                request.form['customer-name'])
            msg.body += "Customer email: %s\n" % (
                request.form['customer-email'])
            msg.body += "Message: %s" % (request.form['customer-message'])
            mail.send(msg)

            customer = Customer(
                name=request.form['customer-name'],
                email=request.form['customer-email']
            )
            db.session.add(customer)
            db.session.commit()
            return redirect(url_for('showContactComplete'))

        else:
            return render_template('contact.html')

    @app.route('/contact/complete')
    def showContactComplete():
        """
        Show a success message for the contact form.
        """
        return render_template('auth/contact_complete.html')

    db.init_app(app)
    login_manager.init_app(app)
    migrate.init_app(app, db)
    ma.init_app(app)
    heroku.init_app(app)
    mail.init_app(app)

    # Load the current logged in user.
    @login_manager.user_loader
    def load_user(user_id):
        return User.query.get(user_id)

    return app
コード例 #21
0
from flask import Blueprint, render_template
from flask_assets import Environment, Bundle
from flask import current_app as app

main_bp = Blueprint('main_bp',
                    __name__,
                    template_folder='templates',
                    static_folder='static')
assets = Environment(app)
Environment.auto_build = True
Environment.debug = False
less_bundle = Bundle('less/*.less',
                     filters='less,cssmin',
                     output='dist/css/styles.css',
                     extra={'rel': 'stylesheet/less'})
js_bundle = Bundle('js/*.js', filters='jsmin', output='dist/js/main.js')
assets.register('less_all', less_bundle)
assets.register('js_all', js_bundle)
if app.config['FLASK_ENV'] == 'development':
    less_bundle.build(force=True)
    js_bundle.build()


@main_bp.route('/')
def home():
    """Landing page."""
    return render_template('index.html',
                           title='FollowMe',
                           template='home-template',
                           body="Insight Data Engineering NY Project")
コード例 #22
0
ファイル: app.py プロジェクト: iai-group/arXivDigest
                       'javascript/utils.js',
                       'javascript/forms.js',
                       'javascript/articlelist.js',
                       'javascript/admin.js',
                       'javascript/topics.js',
                       'javascript/semanticScholarPopup.js',
                       filters='jsmin',
                       output='generated/js/base.%(version)s.js')

css_bundle = Bundle('css/style.css',
                    filters='cssmin',
                    output='generated/css/base.%(version)s.css')

assets.register('js_base', js_bundle)
assets.register('css_base', css_bundle)
js_bundle.build()
css_bundle.build()


@app.template_filter('md_bold')
def md_bold(text):
    """Replaces **text** with bold tags."""
    return arxivdigest.core.md_bold(text)


@app.before_request
def before_request():
    """Checks authTokens before requests to check if users are logged in or not"""
    authToken = request.cookies.get("auth")
    try:
        payload = jwt.decode(authToken, jwtKey)
コード例 #23
0
# app.py

from flask import Flask, render_template, request
from flask_assets import Bundle, Environment

from todo import todos

app = Flask(__name__)

assets = Environment(app)
css = Bundle("src/main.css", output="dist/main.css", filters="postcss")
js = Bundle("src/*.js", output="dist/main.js")  # new

assets.register("css", css)
assets.register("js", js)  # new
css.build()
js.build()  # new


@app.route("/")
def homepage():
    return render_template("index.html")


@app.route("/search", methods=["POST"])
def search_todo():
    search_term = request.form.get("search")

    if not len(search_term):
        return render_template("todo.html", todos=[])
コード例 #24
0
js_main=Bundle(
    'src/js/display.js',
    filters='jsmin',
    output='dist/js/main.min.js')

css_bundle=Bundle(
    'src/css/style.css',
    filters='cssutils',
    output='dist/css/style.min.css')

assets.register('main_css', css_bundle)
assets.register('reqs_js', js_reqs_bundle)
assets.register('main_js', js_main)

css_bundle.build()
js_reqs_bundle.build()
js_main.build()

def to_usec(seconds):
    return int(seconds * 1e6)

def get_last(l, item):
    """
    find the most recent occurence of an item in an ordered list
    """
    for i, x in enumerate(reversed(l)):
        if x == item:
            return len(l) - i - 1
    raise ValueError('item not found')
コード例 #25
0
app.config['SECRET_KEY'] = 'Thisisasecret!'

# Included in order to compile the SASS styles
LESS_BIN = '/usr/bin/less'
ASSETS_DEBUG = True
ASSETS_AUTO_BUILD = True

assets = Environment(app)

style_bundle = Bundle('sass/*.scss',
                      filters='pyscss',
                      output='css/style.css',
                      extra={'rel': 'stylesheet/css'})

assets.register('main_styles', style_bundle)  # Register style bundle
style_bundle.build()  # Build LESS styles


@app.route('/')
def index():
    return 'hello! you are on the index'


@app.route('/home', defaults={'name': 'yeahdude'})
@app.route('/home/<name>', methods=['GET', 'POST'])
def home(name):
    session['username'] = name
    return render_template('home.html',
                           name=name,
                           display=None,
                           mylist=[1, 2, 3, 4, 5],
コード例 #26
0
ファイル: build_assets.py プロジェクト: njovy/319-project
from flask import Flask
from flask_assets import Environment, Bundle, ManageAssets
from flask.ext.script import Manager

app = Flask('main')
app.config.from_object('settings')

assets_env = Environment(app)
js = Bundle(Bundle('js/jquery-1.7.1.min.js'), Bundle('js/bootstrap.min.js'),
            Bundle('js/chosen.jquery.min.js', 'js/chosen.autoload.js'),
            Bundle('js/bootstrap-modal.js'), Bundle('js/jquery.datatable.js'),
            Bundle('js/boostrap-datepicker.js'),
            output='merged/merged.js')
assets_env.register('js_all', js)

css = Bundle('css/bootstrap.css', 'css/chosen.css', 'css/styles.css', 'css/datepicker.css',
             filters='cssmin', output='merged/merged.css')
assets_env.register('css_all', css)
#comment out later?
assets_env.add(js)
js.build()

assets_env.add(css)
css.build()

manager = Manager(app)
manager.add_command("assets", ManageAssets(assets_env))

if __name__ == "__main__":
    manager.run()
コード例 #27
0
app.jinja_env.auto_reload = True

env = Environment(app)
env.load_path = [
    os.path.join(os.path.dirname(__file__), 'static', 'styles'),
    os.path.join(os.path.dirname(__file__), 'static', 'scripts'),
]

# Load JavaScript files
js_files = _get_js_files(
    os.path.join(os.path.dirname(__file__), 'static', 'scripts'))

js_bundle = Bundle(
    *js_files, filters='jsmin', output='build/scripts.min.js')
env.register('js', js_bundle)

# Load CSS files
css_files = _get_css_files(
    os.path.join(os.path.dirname(__file__), 'static', 'styles'))

css_bundle = Bundle(
    *css_files, filters='scss, cssmin', output='build/styles.css')
env.register('css', css_bundle)

# Build asset bundles.
css_bundle.build(force=True, disable_cache=True)
js_bundle.build(force=True, disable_cache=True)

from app import views   # NOQA
コード例 #28
0
ファイル: assets.py プロジェクト: worldomonation/plane_stats
from flask_assets import Bundle, Environment

from plane_stats import app

style_bundle = Bundle('styles/main.css', output='gen/style.min.css')

js_bundle = Bundle('js/app.js',
                   'js/vendor/foundation.js',
                   'js/vendor/jquery.js',
                   output='gen/main.min.js')

assets = Environment(app)

assets.register('main_styles', style_bundle)
assets.register('main_js', js_bundle)
style_bundle.build()
js_bundle.build()