Move assets in frontend.

This commit is contained in:
Alexis Lahouze 2016-01-13 00:10:51 +01:00
parent 1db40c80b6
commit 76205812a0
2 changed files with 17 additions and 12 deletions

View File

@ -15,9 +15,9 @@
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
"""
from flask import Flask, redirect, url_for
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.bower import Bower
from flask.ext.assets import Environment
# The app
app = Flask(__name__, static_folder=None)
@ -29,25 +29,22 @@ app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
db = SQLAlchemy(app)
# Must be after db declaration because the blueprints may need it.
# Must be after db declaration because some components in blueprints need it.
from .api import blueprint as api
from .frontend import blueprint as frontend, frontend_js, frontend_css
from .frontend import blueprint as frontend, assets
app.register_blueprint(frontend, url_prefix='/app')
app.register_blueprint(api, url_prefix='/api')
app.config['BOWER_COMPONENTS_ROOT'] = "../bower_components"
app.config['BOWER_TRY_MINIFIED'] = not app.debug
bower = Bower(app)
assets = Environment(app)
assets.register('frontend_js', frontend_js)
assets.register('frontend_css', frontend_css)
assets.init_app(app)
# Redirect / to frontend index.
@app.route('/')
def index():
return redirect(url_for('frontend.index'))

View File

@ -1,4 +1,5 @@
from flask import Blueprint, render_template
from flask.ext.assets import Environment, Bundle
blueprint = Blueprint(
@ -8,12 +9,19 @@ blueprint = Blueprint(
static_folder='static'
)
frontend_js = Bundle('frontend/js/app.js', 'frontend/js/accounts.js',
'frontend/js/operations.js', 'frontend/js/scheduler.js')
# Local asset management
frontend_js = Bundle(
'frontend/js/app.js',
'frontend/js/accounts.js',
'frontend/js/operations.js',
'frontend/js/scheduler.js'
)
frontend_css = Bundle('frontend/css/main.css')
assets = Environment()
assets.register('frontend_js', frontend_js)
assets.register('frontend_css', frontend_css)
@blueprint.route('/', defaults={'path': 'accounts'})
@blueprint.route('/<path:path>')