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 eb15231
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 8 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
23 changes: 23 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@
CHANGELOG
=========

1.6.1 (unreleased)
------------------

🚀 **Nouveautés**

- Ajout d'un linter pour le code python (``black``)
- possibilité de surcoucher les éléments du dossier ``static`` en les plaçant dans le dossier ``custom``
-par exemple mettre un nouveau picto pour les mammifères : ``custom/images/picto_Mammiferes.png``
**Note de version**

- apache:
- Si l'application n'est pas à la racine du serveur la configuration apache devient:

::

<Location /atlas>
ProxyPass http://127.0.0.1:8080/atlas
ProxyPassReverse http://127.0.0.1:8080/atlas
</Location>




1.6.0 (2023-09-15)
------------------

Expand Down
4 changes: 2 additions & 2 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ Pour rendre l'application consultable comme un sous répertoire du serveur (http

# Configuration GeoNature-atlas
<Location /atlas>
ProxyPass http://127.0.0.1:8080
ProxyPassReverse http://127.0.0.1:8080
ProxyPass http://127.0.0.1:8080/atlas
ProxyPassReverse http://127.0.0.1:8080/atlas
</Location>
#FIN Configuration GeoNature-atlas

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 eb15231

Please sign in to comment.