Skip to content

Commit

Permalink
up custom #493
Browse files Browse the repository at this point in the history
  • Loading branch information
joelclems committed Sep 29, 2023
1 parent 386c4f9 commit dc13eb5
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- develop
- feat/custom
release:
types: [published]

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 18 additions & 6 deletions atlas/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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="/<lang_code>", name="multi_lg"
)
app.register_blueprint(main_blueprint, url_prefix="/<lang_code>", name="multi_lg")
app.register_blueprint(main_blueprint)

from atlas.atlasAPI import api
Expand All @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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
)/
)
'''

0 comments on commit dc13eb5

Please sign in to comment.