Skip to content

Commit 7348be5

Browse files
authored
Ajout de l'URL canonique pour toutes les pages du site (#1615)
1 parent c1e88ce commit 7348be5

File tree

8 files changed

+87
-5
lines changed

8 files changed

+87
-5
lines changed

.secrets.baseline

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
"filename": "core/settings.py",
143143
"hashed_secret": "1ee34e26aeaf89c64ecc2c85efe6a961b75a50e9",
144144
"is_verified": false,
145-
"line_number": 279
145+
"line_number": 282
146146
}
147147
],
148148
"dbt/package-lock.yml": [
@@ -191,5 +191,5 @@
191191
}
192192
]
193193
},
194-
"generated_at": "2025-05-14T12:44:38Z"
194+
"generated_at": "2025-05-20T15:30:41Z"
195195
}

Procfile.all.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
services: docker compose --profile airflow up
1+
services: docker compose --profile airflow --profile lvao up
22
web: poetry run python manage.py runserver 0.0.0.0:8000
33
npm: rm -rf .parcel-cache; npm run watch

core/settings.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
cast=str,
3636
).split(","),
3737
"BASE_URL": decouple.config(
38-
"ASSISTANT_BASE_URL", default="https://quefairedemesdechets.ademe.local"
38+
"ASSISTANT_BASE_URL", default="https://quefairedemesobjets.ademe.local"
3939
),
4040
"POSTHOG_KEY": decouple.config(
4141
"ASSISTANT_POSTHOG_KEY",
@@ -86,12 +86,15 @@
8686
BASE_ALLOWED_HOSTS = [
8787
urlparse(config.get("BASE_URL")).hostname for config in [ASSISTANT, LVAO]
8888
]
89+
CANONICAL_HOST = urlparse(ASSISTANT.get("BASE_URL")).hostname
90+
8991

9092
ALLOWED_HOSTS = [
9193
*BASE_ALLOWED_HOSTS,
9294
*decouple.config("ALLOWED_HOSTS", default="", cast=str).split(","),
9395
]
9496

97+
9598
# Application definition
9699
# ----------------------
97100
INSTALLED_APPS = [
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1-
select * from {{ ref('int_acteur') }}
1+
select * from {{ ref('int_acteur') }}
2+
3+
/*
4+
A faire après avoir modifié le process de publication des tables displayed
5+
A lieu de renommer, on préfèrera faire une copie de carte -> displayed
6+
7+
Ajout des champs calculés:
8+
9+
est_parent | boolean | | |
10+
est_dans_displayedacteur | boolean | | |
11+
est_dans_revisionacteur | boolean | | |
12+
est_dans_acteur | boolean | | |
13+
location_lat | double precision | | |
14+
location_long | double precision | | |
15+
enfants_nombre | integer | | |
16+
enfants_liste | character varying[] | | |
17+
source_code | character varying(255) | | |
18+
acteur_type_code | character varying(255)
19+
20+
*/

docs/comment-faire/troubleshooting.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,43 @@ git add poetry.lock
2727
# si c'est pendant un rebase...
2828
git rebase --continue
2929
```
30+
31+
## déploiement du poste developpeur
32+
33+
### Je n'arrive pas a accéder à l'interface via une url *.local
34+
35+
L'interface sur un poste développeur doit-être accessible via les URLs:
36+
37+
- http://quefairedemesdechets.ademe.local/
38+
- http://quefairedemesobjets.ademe.local/
39+
- http://lvao.ademe.local/ : redirigé vers le site institutionnel
40+
41+
Si tel n'est pas le cas, voici quelques configuration à vérifier
42+
43+
#### /etc/hosts
44+
45+
Dans la configuration `/etc/hosts`, vérifier la présence des lignes
46+
47+
```
48+
127.0.0.1 lvao.ademe.local
49+
127.0.0.1 quefairedemesdechets.ademe.local
50+
127.0.0.1 quefairedemesobjets.ademe.local
51+
```
52+
53+
#### Vérifier la présence des certificats ssl
54+
55+
Si les certificats ne sont pas présents, les logs du serveur nginx affichent une erreur type
56+
57+
```
58+
lvao-proxy-1 | 2025/05/20 10:47:25 [emerg] 1#1: cannot load certificate "/etc/nginx/ssl/lvao.ademe.local+1.pem": BIO_new_file() failed (SSL: error:80000002:system library::No such file or directory:calling fopen(/etc/nginx/ssl/lvao.ademe.local+1.pem, r) error:10000080:BIO routines::no such file)
59+
```
60+
61+
Dans ce cas, (re-)générer les certificats
62+
63+
```
64+
make init-certs
65+
```
66+
67+
#### .env
68+
69+
Enfin, vérifier les variables d'environnement en prenant exemple sur le fichier `.env.template`

qfdmd/templatetags/qfdmd_tags.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@ def patchwork() -> dict:
2424
return {"top": produits[:10], "left": produits[10:14], "right": produits[16:19]}
2525

2626

27+
@register.inclusion_tag("seo/_canonical_url.html", takes_context=True)
28+
def canonical_url(context: dict) -> dict:
29+
canonical_url = None
30+
31+
if "request" in context:
32+
request = context["request"]
33+
path = request.build_absolute_uri(request.path)
34+
canonical_url = (
35+
path.replace(request.get_host(), settings.CANONICAL_HOST)
36+
if settings.CANONICAL_HOST != request.get_host()
37+
else None
38+
)
39+
40+
return {"canonical_url": canonical_url}
41+
42+
2743
@register.simple_tag
2844
def render_file_content(file_field: FileField) -> str:
2945
"""Renders the content of a Filefield as a safe HTML string

templates/qfdmd/base.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
content="width=device-width, initial-scale=1, shrink-to-fit=no"
1414
/>
1515
{% block title %}<title>{{ seo.title }}</title>{% endblock %}
16+
{% canonical_url %}
1617
<meta name="description" content="{% block meta_description %}{{ seo.description }}{% endblock %}">
1718
<meta property="og:image" content="{% static 'assistant/og-image.jpg' %}" />
1819
{% if block_robots %}<meta name="robots" content="noindex, nofollow" />{% endif %}

templates/seo/_canonical_url.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% if canonical_url %}
2+
<link rel="canonical" href="{{ canonical_url }}" />
3+
{% endif %}

0 commit comments

Comments
 (0)