Move assets in frontend.
This commit is contained in:
parent
1db40c80b6
commit
76205812a0
@ -15,9 +15,9 @@
|
|||||||
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
|
along with Accountant. If not, see <http://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
from flask import Flask, redirect, url_for
|
from flask import Flask, redirect, url_for
|
||||||
|
|
||||||
from flask.ext.sqlalchemy import SQLAlchemy
|
from flask.ext.sqlalchemy import SQLAlchemy
|
||||||
from flask.ext.bower import Bower
|
from flask.ext.bower import Bower
|
||||||
from flask.ext.assets import Environment
|
|
||||||
|
|
||||||
# The app
|
# The app
|
||||||
app = Flask(__name__, static_folder=None)
|
app = Flask(__name__, static_folder=None)
|
||||||
@ -29,25 +29,22 @@ app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
|
|||||||
|
|
||||||
db = SQLAlchemy(app)
|
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 .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(frontend, url_prefix='/app')
|
||||||
app.register_blueprint(api, url_prefix='/api')
|
app.register_blueprint(api, url_prefix='/api')
|
||||||
|
|
||||||
|
|
||||||
app.config['BOWER_COMPONENTS_ROOT'] = "../bower_components"
|
app.config['BOWER_COMPONENTS_ROOT'] = "../bower_components"
|
||||||
app.config['BOWER_TRY_MINIFIED'] = not app.debug
|
app.config['BOWER_TRY_MINIFIED'] = not app.debug
|
||||||
|
|
||||||
bower = Bower(app)
|
bower = Bower(app)
|
||||||
|
|
||||||
assets = Environment(app)
|
assets.init_app(app)
|
||||||
|
|
||||||
assets.register('frontend_js', frontend_js)
|
|
||||||
assets.register('frontend_css', frontend_css)
|
|
||||||
|
|
||||||
|
|
||||||
|
# Redirect / to frontend index.
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
return redirect(url_for('frontend.index'))
|
return redirect(url_for('frontend.index'))
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from flask import Blueprint, render_template
|
from flask import Blueprint, render_template
|
||||||
|
|
||||||
from flask.ext.assets import Environment, Bundle
|
from flask.ext.assets import Environment, Bundle
|
||||||
|
|
||||||
blueprint = Blueprint(
|
blueprint = Blueprint(
|
||||||
@ -8,12 +9,19 @@ blueprint = Blueprint(
|
|||||||
static_folder='static'
|
static_folder='static'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Local asset management
|
||||||
|
frontend_js = Bundle(
|
||||||
frontend_js = Bundle('frontend/js/app.js', 'frontend/js/accounts.js',
|
'frontend/js/app.js',
|
||||||
'frontend/js/operations.js', 'frontend/js/scheduler.js')
|
'frontend/js/accounts.js',
|
||||||
|
'frontend/js/operations.js',
|
||||||
|
'frontend/js/scheduler.js'
|
||||||
|
)
|
||||||
frontend_css = Bundle('frontend/css/main.css')
|
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('/', defaults={'path': 'accounts'})
|
||||||
@blueprint.route('/<path:path>')
|
@blueprint.route('/<path:path>')
|
||||||
|
Loading…
Reference in New Issue
Block a user