diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8607a8e5..b7d9e456 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,6 +4,7 @@ on: push: branches: - develop + - feat/custom release: types: [published] diff --git a/.gitignore b/.gitignore index 31d2e625..b9f47a69 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ atlas/static/custom/territoire.json atlas/static/custom/glossaire.json atlas/static/custom/custom.css atlas/static/custom/maps-custom.js +atlas/static/custom/images/picto*.png static/custom/territoire.json static/custom/glossaire.json diff --git a/atlas/app.py b/atlas/app.py index 69c3f8a2..8675d248 100644 --- a/atlas/app.py +++ b/atlas/app.py @@ -5,6 +5,9 @@ from flask_sqlalchemy import SQLAlchemy from flask_babel import Babel, format_date, gettext, ngettext, get_locale from werkzeug.middleware.proxy_fix import ProxyFix +from werkzeug.middleware.shared_data import SharedDataMiddleware +from werkzeug.middleware.dispatcher import DispatcherMiddleware +from werkzeug.wrappers import Response from atlas.configuration.config_parser import valid_config_from_dict from atlas.configuration.config_schema import AtlasConfig, SecretSchemaConf @@ -34,9 +37,7 @@ def create_app(): app.config.from_prefixed_env(prefix="ATLAS") config_valid = valid_config_from_dict(copy.copy(app.config), AtlasConfig) - config_secret_valid = valid_config_from_dict( - copy.copy(app.config), SecretSchemaConf - ) + config_secret_valid = valid_config_from_dict(copy.copy(app.config), SecretSchemaConf) app.config.update(config_valid) app.config.update(config_secret_valid) @@ -59,9 +60,7 @@ def get_locale(): from atlas.atlasRoutes import main as main_blueprint if app.config["MULTILINGUAL"]: - app.register_blueprint( - main_blueprint, url_prefix="/", name="multi_lg" - ) + app.register_blueprint(main_blueprint, url_prefix="/", name="multi_lg") app.register_blueprint(main_blueprint) from atlas.atlasAPI import api @@ -72,6 +71,19 @@ def get_locale(): os.environ["SCRIPT_NAME"] = app.config["APPLICATION_ROOT"].rstrip("/") app.wsgi_app = ProxyFix(app.wsgi_app, x_host=1) + app.wsgi_app = SharedDataMiddleware( + app.wsgi_app, + { + app.static_url_path: f"{atlas_static_folder}/custom", + }, + ) + + if app.config["APPLICATION_ROOT"] != "/": + app.wsgi_app = DispatcherMiddleware( + Response("Not Found", status=404), + {app.config["APPLICATION_ROOT"].rstrip("/"): app.wsgi_app}, + ) + @app.context_processor def inject_config(): configuration = copy.copy(app.config) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..fdf7478a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,21 @@ +[tool.black] +line-length = 99 +exclude =''' +( + /( + \.eggs # exclude a few common directories in the + | \.git # root of the project + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist + | node_modules + | venv + | dependencies + )/ +) +'''