~homeworkprod/byceps

d29cbb41481c02bc579c88f7bf2db08baceb4300 — Jochen Kupperschmidt 2 years ago 577d254
Inline `STATIC_URL_PREFIX_*` config values
3 files changed, 8 insertions(+), 13 deletions(-)

M app.py
M byceps/application.py
M byceps/config.py
M app.py => app.py +4 -4
@@ 38,9 38,9 @@ def _generate_static_files_exports():
    """Yield static files exports."""
    # global, brand-specific, and party-specific files
    for url_path, config_key in [
        (config.STATIC_URL_PREFIX_GLOBAL, 'PATH_GLOBAL'),
        (config.STATIC_URL_PREFIX_BRAND, 'PATH_BRAND'),
        (config.STATIC_URL_PREFIX_PARTY, 'PATH_PARTY'),
        ('/global', 'PATH_GLOBAL'),
        ('/brand', 'PATH_BRAND'),
        ('/party', 'PATH_PARTY'),
    ]:
        path = app.config.get(config_key)
        if path:


@@ 50,7 50,7 @@ def _generate_static_files_exports():
    if config.get_site_mode(app).is_public():
        site_id = config.get_current_site_id(app)
        site_files_path = Path('sites') / site_id / 'static'
        yield config.STATIC_URL_PREFIX_SITE, str(site_files_path)
        yield '/site', str(site_files_path)


if app.env == 'development':

M byceps/application.py => byceps/application.py +4 -4
@@ 183,10 183,10 @@ def _get_blueprints_debug():
def _add_static_file_url_rules(app):
    """Add URL rules to for static files."""
    for rule_prefix, endpoint in [
        (config.STATIC_URL_PREFIX_GLOBAL, 'global_file'),
        (config.STATIC_URL_PREFIX_BRAND, 'brand_file'),
        (config.STATIC_URL_PREFIX_PARTY, 'party_file'),
        (config.STATIC_URL_PREFIX_SITE, 'site_file'),
        ('/global', 'global_file'),
        ('/brand', 'brand_file'),
        ('/party', 'party_file'),
        ('/site', 'site_file'),
    ]:
        rule = rule_prefix + '/<path:filename>'
        app.add_url_rule(

M byceps/config.py => byceps/config.py +0 -5
@@ 11,11 11,6 @@ from enum import Enum
from flask import current_app


STATIC_URL_PREFIX_GLOBAL = '/global'
STATIC_URL_PREFIX_BRAND = '/brand'
STATIC_URL_PREFIX_PARTY = '/party'
STATIC_URL_PREFIX_SITE = '/site'

EXTENSION_KEY = 'byceps_config'
KEY_SITE_MODE = 'site_mode'
KEY_SITE_ID = 'site_id'