コード例 #1
0
def init_app(app):
    app.config.setdefault('THEME_VARIANT', 'gouvfr')

    themes.init_themes(app, app_identifier='udata', loaders=[themes_loader])
    # Load all theme assets
    try:
        theme = app.theme_manager.themes[app.config['THEME']]
    except KeyError:
        theme = app.theme_manager.themes['gouvfr']
    prefix = '/'.join(('_themes', theme.identifier))
    app.config['STATIC_DIRS'].append((prefix, theme.static_path))

    # Override the default theme_static
    app.jinja_env.globals['theme_static'] = theme_static_with_version

    # Load manifest if necessary
    if theme.manifest:
        with app.app_context():
            assets.register_manifest('theme', theme.manifest)

    # Hook into flask security to user themed auth pages
    app.config.setdefault('SECURITY_RENDER', 'udata_gouvfr.theme:render')

    @app.context_processor
    def inject_current_theme():
        return {'current_theme': current}
コード例 #2
0
def init_app(app, views=None):
    views = views or VIEWS

    init_markdown(app)

    for view in views:
        _load_views(app, 'udata.{}.views'.format(view))

    # Load hook blueprint
    app.register_blueprint(hook)

    # Load all plugins views and blueprints
    for module in entrypoints.get_enabled('udata.views', app).values():
        _load_views(app, module)

    # Load all plugins views and blueprints
    for module in entrypoints.get_enabled('udata.front', app).values():
        front_module = module if inspect.ismodule(module) else import_module(module)
        front_module.init_app(app)

    # Load core manifest
    with app.app_context():
        assets.register_manifest('udata')
        for dist in entrypoints.get_plugins_dists(app, 'udata.views'):
            if assets.has_manifest(dist.project_name):
                assets.register_manifest(dist.project_name)
コード例 #3
0
ファイル: __init__.py プロジェクト: taniki/udata
def init_app(app, views=None):
    views = views or VIEWS

    init_markdown(app)

    from . import helpers, error_handlers  # noqa

    for view in views:
        _load_views(app, 'udata.{}.views'.format(view))

    # Load all plugins views and blueprints
    for module in entrypoints.get_enabled('udata.views', app).values():
        _load_views(app, module)

    # Load core manifest
    with app.app_context():
        assets.register_manifest('udata')
        for dist in entrypoints.get_plugins_dists(app, 'udata.views'):
            if assets.has_manifest(dist.project_name):
                assets.register_manifest(dist.project_name)

    # Optionally register debug views
    if app.config.get('DEBUG'):

        @front.route('/403/')
        def test_403():
            abort(403)

        @front.route('/404/')
        def test_404():
            abort(404)

        @front.route('/500/')
        def test_500():
            abort(500)

    # Load front only views and helpers
    app.register_blueprint(front)

    # Enable CDN if required
    if app.config['CDN_DOMAIN'] is not None:
        from flask_cdn import CDN
        CDN(app)

    # Load debug toolbar if enabled
    if app.config.get('DEBUG_TOOLBAR'):
        from flask_debugtoolbar import DebugToolbarExtension
        DebugToolbarExtension(app)
コード例 #4
0
ファイル: __init__.py プロジェクト: odtvince/udata
def init_app(app, views=None):
    views = views or VIEWS

    init_markdown(app)

    from . import helpers, error_handlers  # noqa

    for view in views:
        _load_views(app, 'udata.{}.views'.format(view))

    # Load all plugins views and blueprints
    for module in entrypoints.get_enabled('udata.views', app).values():
        _load_views(app, module)

    # Load core manifest
    with app.app_context():
        assets.register_manifest('udata')
        for dist in entrypoints.get_plugins_dists(app, 'udata.views'):
            if assets.has_manifest(dist.project_name):
                assets.register_manifest(dist.project_name)

    # Optionnaly register debug views
    if app.config.get('DEBUG'):
        @front.route('/403/')
        def test_403():
            abort(403)

        @front.route('/404/')
        def test_404():
            abort(404)

        @front.route('/500/')
        def test_500():
            abort(500)

    # Load front only views and helpers
    app.register_blueprint(front)

    # Enable CDN if required
    if app.config['CDN_DOMAIN'] is not None:
        from flask_cdn import CDN
        CDN(app)

    # Load debug toolbar if enabled
    if app.config.get('DEBUG_TOOLBAR'):
        from flask_debugtoolbar import DebugToolbarExtension
        DebugToolbarExtension(app)
コード例 #5
0
ファイル: __init__.py プロジェクト: odtvince/udata
def init_app(app):
    app.config.setdefault('THEME_VARIANT', 'default')
    themes.init_themes(app, app_identifier='udata', loaders=[themes_loader])

    # Load all theme assets
    theme = app.theme_manager.themes[app.config['THEME']]
    prefix = '/'.join(('_themes', theme.identifier))
    app.config['STATIC_DIRS'].append((prefix, theme.static_path))

    # Override the default theme_static
    app.jinja_env.globals['theme_static'] = theme_static_with_version

    # Load manifest if necessary
    if theme.manifest:
        with app.app_context():
            assets.register_manifest('theme', theme.manifest)

    # Hook into flask security to user themed auth pages
    app.config.setdefault('SECURITY_RENDER', 'udata.theme:render')

    @app.context_processor
    def inject_current_theme():
        return {'current_theme': current}
コード例 #6
0
def init_preview(state):
    for key, default in DEFAULTS.__dict__.items():
        state.app.config.setdefault(key, default)
    with state.app.app_context():
        for key, manifest in MANIFESTS.items():
            assets.register_manifest(key, filename=manifest)