diff --git a/accountant/__init__.py b/accountant/__init__.py index 81db5cd..5affdf0 100644 --- a/accountant/__init__.py +++ b/accountant/__init__.py @@ -15,9 +15,9 @@ along with Accountant. If not, see . """ 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')) diff --git a/accountant/frontend/__init__.py b/accountant/frontend/__init__.py index ae0bfb3..bc6f952 100644 --- a/accountant/frontend/__init__.py +++ b/accountant/frontend/__init__.py @@ -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('/')