diff --git a/src/app.py b/src/app.py index 431c2d7..da958c6 100644 --- a/src/app.py +++ b/src/app.py @@ -1,5 +1,4 @@ import logging -import os import dash_bootstrap_components as dbc from dash import Dash, dcc, html, page_container, page_registry @@ -8,47 +7,11 @@ from flask import send_from_directory load_dotenv() -domain_name = ( - "test.decp.info" if os.getenv("DEVELOPMENT").lower() == "true" else "decp.info" -) -image_url = f"https://{domain_name}/assets/decp.info.png" -title = "decp.info - exploration des marchés publics français" -description = ( - "Explorez et analysez les données des marchés publics français avec cet outil libre et gratuit. " - "Pour une commande publique accessible à toutes et tous." -) - app = Dash( external_stylesheets=[dbc.themes.SIMPLEX], title="decp.info", use_pages=True, compress=True, - meta_tags=[ - { - "property": "og:image", - "content": image_url, - }, - { - "name": "twitter:image", - "content": image_url, - }, - { - "property": "og:title", - "content": title, - }, - { - "name": "twitter:title", - "content": title, - }, - { - "property": "og:description", - "content": description, - }, - { - "name": "twitter:description", - "content": description, - }, - ], ) # COSMO (belle font, blue), # UNITED (rouge, ubuntu font), @@ -71,7 +34,7 @@ logging.basicConfig( app.index_string = """ - + {%metas%} {%title%} diff --git a/src/pages/about.py b/src/pages/about.py index f7eae51..b44a7ee 100644 --- a/src/pages/about.py +++ b/src/pages/about.py @@ -3,18 +3,25 @@ import os from dash import dcc, html, register_page from src.figures import get_sources_tables +from src.utils import meta_content -title = "À propos" +name = "À propos" register_page( - __name__, path="/a-propos", title=f"decp.info - {title}", name=title, order=5 + __name__, + path="/a-propos", + title=meta_content["title"], + name=name, + description=meta_content["description"], + image_url=meta_content["image_url"], + order=5, ) layout = [ html.Div( className="container", children=[ - html.H2(title), + html.H2(name), dcc.Markdown( """Outil d'exploration libre et gratuit des données de marchés publics, développé par Colin Maudry. diff --git a/src/pages/acheteur.py b/src/pages/acheteur.py index 4d54052..1b3f202 100644 --- a/src/pages/acheteur.py +++ b/src/pages/acheteur.py @@ -10,13 +10,16 @@ from src.utils import ( get_annuaire_data, get_departement_region, lf, + meta_content, ) register_page( __name__, path_template="/acheteurs/", - title="decp.info - acheteur", + title=meta_content["title"], name="Acheteur", + description=meta_content["description"], + image_url=meta_content["image_url"], order=5, ) diff --git a/src/pages/home.py b/src/pages/home.py index d4df7c1..48dd24e 100644 --- a/src/pages/home.py +++ b/src/pages/home.py @@ -10,6 +10,7 @@ from src.utils import ( filter_table_data, format_number, lf, + meta_content, sort_table_data, ) @@ -18,9 +19,16 @@ update_date = datetime.fromtimestamp(update_date).strftime("%d/%m/%Y") schema = lf.collect_schema() - -title = "Tableau" -register_page(__name__, path="/", title="decp.info", name=title, order=1) +name = "Tableau" +register_page( + __name__, + path="/", + title=meta_content["title"], + name=name, + description=meta_content["description"], + image_url=meta_content["image_url"], + order=1, +) datatable = html.Div( className="marches_table", diff --git a/src/pages/statistiques.py b/src/pages/statistiques.py index 877457d..a55b8c8 100644 --- a/src/pages/statistiques.py +++ b/src/pages/statistiques.py @@ -1,12 +1,18 @@ from dash import dcc, html, register_page from src.figures import get_barchart_sources, get_map_count_marches -from src.utils import lf +from src.utils import lf, meta_content -title = "Statistiques" +name = "Statistiques" register_page( - __name__, path="/statistiques", title=f"decp.info - {title}", name=title, order=3 + __name__, + path="/statistiques", + title=meta_content["title"], + name=name, + description=meta_content["description"], + image_url=meta_content["image_url"], + order=3, ) @@ -14,7 +20,7 @@ layout = [ html.Div( className="container", children=[ - html.H2(title), + html.H2(name), dcc.Loading( overlay_style={"visibility": "visible", "filter": "blur(2px)"}, id="loading-statistques", diff --git a/src/pages/titulaire.py b/src/pages/titulaire.py index 590d823..b0d1aa6 100644 --- a/src/pages/titulaire.py +++ b/src/pages/titulaire.py @@ -10,13 +10,16 @@ from src.utils import ( get_annuaire_data, get_departement_region, lf, + meta_content, ) register_page( __name__, path_template="/titulaires/", - title="decp.info - titulaire", - name="Fournisseur", + title=meta_content["title"], + name="Titulaire", + description=meta_content["description"], + image_url=meta_content["image_url"], order=5, ) @@ -245,7 +248,7 @@ def get_last_marches_table(data) -> html.Div: "whiteSpace": "normal", }, { - "if": {"column_id": "acheteur_nom"}, + "if": {"column_id": " acheteur_nom"}, "minWidth": "200px", "textAlign": "left", "overflow": "hidden", diff --git a/src/utils.py b/src/utils.py index 980c6fe..454780c 100644 --- a/src/utils.py +++ b/src/utils.py @@ -227,3 +227,14 @@ def sort_table_data(lff: pl.LazyFrame, sort_by: list) -> pl.LazyFrame: lf = get_decp_data() departements = get_departements() +domain_name = ( + "test.decp.info" if os.getenv("DEVELOPMENT").lower() == "true" else "decp.info" +) +meta_content = { + "image_url": f"https://{domain_name}/assets/decp.info.png", + "title": "decp.info - exploration des marchés publics français", + "description": ( + "Explorez et analysez les données des marchés publics français avec cet outil libre et gratuit. " + "Pour une commande publique accessible à toutes et tous." + ), +}