示例#1
0
def init(app):
    """
    Bundle projects assets

    :type app: flask.Flask
    """
    assets = Environment(app)
    assets.auto_build = app.config.get('ASSETS_AUTO_BUILD', True)
    files_to_watch = []

    if 'COLLECT_STATIC_ROOT' in app.config:
        assets.cache = app.config['COLLECT_STATIC_ROOT']
        collect = Collect()
        collect.init_app(app)
        collect.collect()
        app.static_folder = app.config['COLLECT_STATIC_ROOT']

    if 'JS_ASSETS' in app.config and len(app.config['JS_ASSETS']) > 0:
        files_to_watch += [
            os.path.join(app.static_folder, js_file)
            for js_file in app.config['JS_ASSETS']
        ]

        js = Bundle(*app.config['JS_ASSETS'],
                    output=app.config['JS_ASSETS_OUTPUT'],
                    filters=app.config['JS_ASSETS_FILTERS'])
        assets.register('js_all', js)

    if 'CSS_ASSETS' in app.config and len(app.config['CSS_ASSETS']) > 0:
        files_to_watch += [
            os.path.join(app.static_folder, css_file)
            for css_file in app.config['CSS_ASSETS']
        ]

        css = Bundle(*app.config['CSS_ASSETS'],
                     output=app.config['CSS_ASSETS_OUTPUT'],
                     filters=app.config['CSS_ASSETS_FILTERS'])
        assets.register('css_all', css)

    app.assets = assets
    app._base_files_to_watch = files_to_watch
示例#2
0
 def run(self):
     collect = Collect()
     collect.init_app(application)
     collect.init_script(manager)
     collect.collect(verbose=True)
示例#3
0
文件: ufa.py 项目: ufapy/ufapy.ru
import sys
from raven.contrib.flask import Sentry

sys.path.insert(0, os.path.join(os.path.realpath(os.path.dirname(__file__)), 'apps'))

from flask import Flask
from flask.ext.collect import Collect
from flask_configurations.configuration import settings

from core.views import MainPageView, AboutPageView, SchedulePageView, PlacePageView


app = Flask(__name__)
app.config.from_object(settings)

app.add_url_rule('/', view_func=MainPageView.as_view('core-main'))
app.add_url_rule('/about/', view_func=AboutPageView.as_view('core-about'))
app.add_url_rule('/schedule/', view_func=SchedulePageView.as_view('core-schedule'))
app.add_url_rule('/place/', view_func=PlacePageView.as_view('core-place'))

app.config[
    'SENTRY_DSN'] = 'http://*****:*****@sentry.redeploy.ru/48'
sentry = Sentry(app)

if not settings.__class__.__name__ == 'Development':
    collect = Collect()
    collect.init_app(app)
    collect.collect(verbose=True)

if __name__ == '__main__':
    app.run()