sites-conformes-header-logo 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 sites-conformes-header-logo contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,59 @@
1
+ Metadata-Version: 2.4
2
+ Name: sites-conformes-header-logo
3
+ Version: 0.1.0
4
+ Summary: Replace the sites-conformes header service title text with a logo image.
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Framework :: Django
12
+ Classifier: Framework :: Wagtail
13
+ Requires-Dist: django>=5.0
14
+ Requires-Dist: wagtail>=6.0
15
+ Requires-Dist: sites-conformes>=4.0
16
+ Requires-Python: >=3.12
17
+ Project-URL: Homepage, https://github.com/incubateur-ademe/sites-conformes-header-logo
18
+ Project-URL: Repository, https://github.com/incubateur-ademe/sites-conformes-header-logo
19
+ Project-URL: Changelog, https://github.com/incubateur-ademe/sites-conformes-header-logo/blob/main/CHANGELOG.md
20
+ Project-URL: Issues, https://github.com/incubateur-ademe/sites-conformes-header-logo/issues
21
+ Description-Content-Type: text/markdown
22
+
23
+ # sites-conformes-header-logo
24
+
25
+ Remplace le texte du titre de service (`fr-header__service-title`) du
26
+ header [sites-conformes](https://github.com/betagouv/sites-conformes) par
27
+ un logo image, quand un logo est configuré.
28
+
29
+ **Non conforme DSFR** : le [référentiel DSFR](https://www.systeme-de-design.gouv.fr/version-courante/fr/composants/en-tete)
30
+ prévoit un titre de service textuel, pas une image libre. C'est un choix
31
+ assumé pour ce site (cf. le ticket associé) - si aucun logo n'est
32
+ configuré, le rendu retombe sur le texte standard, donc l'installation de
33
+ ce package est sans risque pour les sites qui n'en ont pas besoin.
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ uv add sites-conformes-header-logo
39
+ ```
40
+
41
+ Ce package surcharge `sites_conformes_core/blocks/header.html`, que le
42
+ package `sites_conformes` fournit lui-même (dans `sites_conformes/templates/`,
43
+ pas `sites_conformes/core/templates/`). Comme pour `sites-conformes-footer-partners`,
44
+ il doit être placé **avant** `sites_conformes` dans `INSTALLED_APPS` :
45
+
46
+ ```python
47
+ INSTALLED_APPS = [
48
+ ...,
49
+ "sites_conformes_header_logo",
50
+ "sites_conformes",
51
+ "sites_conformes.core",
52
+ ...,
53
+ ]
54
+ ```
55
+
56
+ Ensuite, dans l'admin Wagtail, sous **Réglages → Logo du header**,
57
+ renseignez le logo et son texte alternatif (obligatoire, doit reprendre le
58
+ nom du service). Sans logo configuré, le header affiche le titre textuel
59
+ habituel.
@@ -0,0 +1,37 @@
1
+ # sites-conformes-header-logo
2
+
3
+ Remplace le texte du titre de service (`fr-header__service-title`) du
4
+ header [sites-conformes](https://github.com/betagouv/sites-conformes) par
5
+ un logo image, quand un logo est configuré.
6
+
7
+ **Non conforme DSFR** : le [référentiel DSFR](https://www.systeme-de-design.gouv.fr/version-courante/fr/composants/en-tete)
8
+ prévoit un titre de service textuel, pas une image libre. C'est un choix
9
+ assumé pour ce site (cf. le ticket associé) - si aucun logo n'est
10
+ configuré, le rendu retombe sur le texte standard, donc l'installation de
11
+ ce package est sans risque pour les sites qui n'en ont pas besoin.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ uv add sites-conformes-header-logo
17
+ ```
18
+
19
+ Ce package surcharge `sites_conformes_core/blocks/header.html`, que le
20
+ package `sites_conformes` fournit lui-même (dans `sites_conformes/templates/`,
21
+ pas `sites_conformes/core/templates/`). Comme pour `sites-conformes-footer-partners`,
22
+ il doit être placé **avant** `sites_conformes` dans `INSTALLED_APPS` :
23
+
24
+ ```python
25
+ INSTALLED_APPS = [
26
+ ...,
27
+ "sites_conformes_header_logo",
28
+ "sites_conformes",
29
+ "sites_conformes.core",
30
+ ...,
31
+ ]
32
+ ```
33
+
34
+ Ensuite, dans l'admin Wagtail, sous **Réglages → Logo du header**,
35
+ renseignez le logo et son texte alternatif (obligatoire, doit reprendre le
36
+ nom du service). Sans logo configuré, le header affiche le titre textuel
37
+ habituel.
@@ -0,0 +1,37 @@
1
+ [project]
2
+ name = "sites-conformes-header-logo"
3
+ version = "0.1.0"
4
+ description = "Replace the sites-conformes header service title text with a logo image."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ classifiers = [
9
+ "Development Status :: 3 - Alpha",
10
+ "Intended Audience :: Developers",
11
+ "Operating System :: OS Independent",
12
+ "Programming Language :: Python :: 3",
13
+ "Framework :: Django",
14
+ "Framework :: Wagtail",
15
+ ]
16
+ requires-python = ">=3.12"
17
+ dependencies = [
18
+ "django>=5.0",
19
+ "wagtail>=6.0",
20
+ "sites-conformes>=4.0",
21
+ ]
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/incubateur-ademe/sites-conformes-header-logo"
25
+ Repository = "https://github.com/incubateur-ademe/sites-conformes-header-logo"
26
+ Changelog = "https://github.com/incubateur-ademe/sites-conformes-header-logo/blob/main/CHANGELOG.md"
27
+ Issues = "https://github.com/incubateur-ademe/sites-conformes-header-logo/issues"
28
+
29
+ [dependency-groups]
30
+ dev = ["ruff>=0.15"]
31
+
32
+ [build-system]
33
+ requires = ["uv_build>=0.9,<0.13"]
34
+ build-backend = "uv_build"
35
+
36
+ [tool.uv.build-backend]
37
+ module-name = "sites_conformes_header_logo"
@@ -0,0 +1,39 @@
1
+ [project]
2
+ name = "sites-conformes-header-logo"
3
+ version = "0.1.0"
4
+ description = "Replace the sites-conformes header service title text with a logo image."
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ classifiers = [
9
+ "Development Status :: 3 - Alpha",
10
+ "Intended Audience :: Developers",
11
+ "Operating System :: OS Independent",
12
+ "Programming Language :: Python :: 3",
13
+ "Framework :: Django",
14
+ "Framework :: Wagtail",
15
+ ]
16
+ requires-python = ">=3.12"
17
+ dependencies = [
18
+ "django>=5.0",
19
+ "wagtail>=6.0",
20
+ "sites-conformes>=4.0",
21
+ ]
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/incubateur-ademe/sites-conformes-header-logo"
25
+ Repository = "https://github.com/incubateur-ademe/sites-conformes-header-logo"
26
+ Changelog = "https://github.com/incubateur-ademe/sites-conformes-header-logo/blob/main/CHANGELOG.md"
27
+ Issues = "https://github.com/incubateur-ademe/sites-conformes-header-logo/issues"
28
+
29
+ [dependency-groups]
30
+ dev = [
31
+ "ruff>=0.15",
32
+ ]
33
+
34
+ [build-system]
35
+ requires = ["uv_build>=0.9,<0.13"]
36
+ build-backend = "uv_build"
37
+
38
+ [tool.uv.build-backend]
39
+ module-name = "sites_conformes_header_logo"
@@ -0,0 +1,8 @@
1
+ from django.apps import AppConfig
2
+ from django.utils.translation import gettext_lazy as _
3
+
4
+
5
+ class SitesConformesHeaderLogoConfig(AppConfig):
6
+ default_auto_field = "django.db.models.BigAutoField"
7
+ name = "sites_conformes_header_logo"
8
+ verbose_name = _("Header logo")
@@ -0,0 +1,56 @@
1
+ # Translations for the sites_conformes_header_logo app.
2
+ msgid ""
3
+ msgstr ""
4
+ "Project-Id-Version: PACKAGE VERSION\n"
5
+ "Report-Msgid-Bugs-To: \n"
6
+ "POT-Creation-Date: 2026-07-29 15:17+0200\n"
7
+ "PO-Revision-Date: 2026-07-29 15:17+0200\n"
8
+ "Last-Translator: \n"
9
+ "Language-Team: French\n"
10
+ "Language: fr\n"
11
+ "MIME-Version: 1.0\n"
12
+ "Content-Type: text/plain; charset=UTF-8\n"
13
+ "Content-Transfer-Encoding: 8bit\n"
14
+ "Plural-Forms: nplurals=2; plural=(n > 1);\n"
15
+
16
+ #: apps.py:8 models.py:44
17
+ msgid "Header logo"
18
+ msgstr "Logo du header"
19
+
20
+ #: models.py:20
21
+ msgid "Required when a logo is set."
22
+ msgstr "Obligatoire si un logo est renseigné."
23
+
24
+ #: models.py:28
25
+ msgid "Logo"
26
+ msgstr "Logo"
27
+
28
+ #: models.py:31
29
+ msgid "Alt text"
30
+ msgstr "Texte alternatif"
31
+
32
+ #: models.py:35
33
+ msgid "Required if a logo is set. Must be the service's name."
34
+ msgstr "Obligatoire si un logo est renseigné. Doit être le nom du service."
35
+
36
+ #: templates/sites_conformes_core/blocks/header.html:9
37
+ msgid "Home page"
38
+ msgstr "Accueil"
39
+
40
+ #: templates/sites_conformes_core/blocks/header.html:61
41
+ #: templates/sites_conformes_core/blocks/header.html:86
42
+ msgid "Search"
43
+ msgstr "Rechercher"
44
+
45
+ #: templates/sites_conformes_core/blocks/header.html:65
46
+ #: templates/sites_conformes_core/blocks/header.html:110
47
+ msgid "Close"
48
+ msgstr "Fermer"
49
+
50
+ #: templates/sites_conformes_core/blocks/header.html:95
51
+ msgid "Menu"
52
+ msgstr "Menu"
53
+
54
+ #: templates/sites_conformes_core/blocks/header.html:115
55
+ msgid "Main menu"
56
+ msgstr "Menu principal"
@@ -0,0 +1,29 @@
1
+ # Generated by Django 6.0.7 on 2026-07-29 13:13
2
+
3
+ import django.db.models.deletion
4
+ from django.db import migrations, models
5
+
6
+
7
+ class Migration(migrations.Migration):
8
+
9
+ initial = True
10
+
11
+ dependencies = [
12
+ ('wagtailcore', '0097_baselogentry_uuid_action_timestamp_indexes'),
13
+ ('wagtailimages', '0027_image_description'),
14
+ ]
15
+
16
+ operations = [
17
+ migrations.CreateModel(
18
+ name='HeaderLogoSettings',
19
+ fields=[
20
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
21
+ ('alt', models.CharField(blank=True, default='', help_text="Required if a logo is set. Must be the service's name.", max_length=200, verbose_name='Alt text')),
22
+ ('logo', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image', verbose_name='Logo')),
23
+ ('site', models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, to='wagtailcore.site')),
24
+ ],
25
+ options={
26
+ 'verbose_name': 'Header logo',
27
+ },
28
+ ),
29
+ ]
@@ -0,0 +1,20 @@
1
+ # Generated by Django 6.0.7 on 2026-10-16 11:26
2
+
3
+ import django.db.models.deletion
4
+ from django.db import migrations, models
5
+
6
+
7
+ class Migration(migrations.Migration):
8
+
9
+ dependencies = [
10
+ ('sites_conformes_customimages', '0002_copy_wagtail_images'),
11
+ ('sites_conformes_header_logo', '0001_initial'),
12
+ ]
13
+
14
+ operations = [
15
+ migrations.AlterField(
16
+ model_name='headerlogosettings',
17
+ name='logo',
18
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='sites_conformes_customimages.customimage', verbose_name='Logo'),
19
+ ),
20
+ ]
@@ -0,0 +1,44 @@
1
+ from django.core.exceptions import ValidationError
2
+ from django.db import models
3
+ from django.utils.translation import gettext_lazy as _
4
+ from wagtail.admin.panels import FieldPanel
5
+ from wagtail.contrib.settings.models import BaseSiteSetting, register_setting
6
+ from wagtail.images import get_image_model_string
7
+
8
+
9
+ @register_setting(icon="site")
10
+ class HeaderLogoSettings(BaseSiteSetting):
11
+ """Replaces the header's text service title with a logo image, when set.
12
+
13
+ Not DSFR-conformant (the header's service title is meant to be text),
14
+ but falls back to the standard text title when no logo is configured.
15
+ """
16
+
17
+ def clean(self):
18
+ super().clean()
19
+ if self.logo and not self.alt:
20
+ raise ValidationError({"alt": _("Required when a logo is set.")})
21
+
22
+ logo = models.ForeignKey(
23
+ get_image_model_string(),
24
+ null=True,
25
+ blank=True,
26
+ on_delete=models.SET_NULL,
27
+ related_name="+",
28
+ verbose_name=_("Logo"),
29
+ )
30
+ alt = models.CharField(
31
+ _("Alt text"),
32
+ max_length=200,
33
+ blank=True,
34
+ default="",
35
+ help_text=_("Required if a logo is set. Must be the service's name."),
36
+ )
37
+
38
+ panels = [
39
+ FieldPanel("logo"),
40
+ FieldPanel("alt"),
41
+ ]
42
+
43
+ class Meta:
44
+ verbose_name = _("Header logo")
@@ -0,0 +1,125 @@
1
+ {% extends "dsfr/header.html" %}
2
+ {% load i18n static wagtailcore_tags wagtailimages_tags wagtail_dsfr_tags wagtail_dsfr_menus_tags %}
3
+
4
+ {% block brand %}
5
+ <p class="fr-logo">{{ settings.sites_conformes_core.CmsDsfrConfig.header_brand_html|safe }}</p>
6
+ {% endblock brand %}
7
+
8
+ {% block service_title %}
9
+ {% translate "Home page" as home_page %}
10
+ {% with header_logo=settings.sites_conformes_header_logo.HeaderLogoSettings %}
11
+ <a href="{% root_url %}"
12
+ title="{{ home_page }} — {{ settings.sites_conformes_core.CmsDsfrConfig.site_title }}">
13
+ {% if header_logo.logo %}
14
+ {% image header_logo.logo height-80 as header_logo_img %}{# 2.5rem, twice for HiDPI screens #}
15
+ <img src="{{ header_logo_img.url }}"
16
+ width="{{ header_logo_img.width }}"
17
+ height="{{ header_logo_img.height }}"
18
+ alt="{{ header_logo.alt }}"
19
+ style="max-height: 2.5rem; max-width: 100%; height: auto; width: auto;" />
20
+ {% else %}
21
+ <p class="fr-header__service-title">
22
+ {% if settings.sites_conformes_core.CmsDsfrConfig.site_title|slice:"-2:" == "fr" %}
23
+ {{ settings.sites_conformes_core.CmsDsfrConfig.site_title|slice:":-2" }}<em>fr</em>
24
+ {% else %}
25
+ {{ settings.sites_conformes_core.CmsDsfrConfig.site_title }}
26
+ {% endif %}
27
+ {% if settings.sites_conformes_core.CmsDsfrConfig.beta_tag %}
28
+ <span class="fr-badge fr-badge--sm fr-badge--green-emeraude">BETA</span>
29
+ {% endif %}
30
+ </p>
31
+ {% endif %}
32
+ </a>
33
+ {% endwith %}
34
+ {% endblock service_title %}
35
+
36
+ {% block service_tagline %}
37
+ {{ settings.sites_conformes_core.CmsDsfrConfig.site_tagline }}
38
+ {% endblock service_tagline %}
39
+
40
+ {% block operator_logo %}
41
+ {% if settings.sites_conformes_core.CmsDsfrConfig.operator_logo_file %}
42
+ {% image settings.sites_conformes_core.CmsDsfrConfig.operator_logo_file width-320 format-webp preserve-svg as logo_img %}{# 10rem at most, twice for HiDPI screens #}
43
+
44
+ <div class="fr-header__operator">
45
+ <img class="fr-responsive-img"
46
+ src="{{ logo_img.url }}"
47
+ width="{{ logo_img.width }}"
48
+ height="{{ logo_img.height }}"
49
+ alt="{{ settings.sites_conformes_core.CmsDsfrConfig.operator_logo_alt }}"
50
+ {% if settings.sites_conformes_core.CmsDsfrConfig.operator_logo_width >= 1 %}style="max-width:{{ settings.sites_conformes_core.CmsDsfrConfig.operator_logo_width|floatformat:"1u" }}rem;"{% endif %} />
51
+ </div>
52
+ {% endif %}
53
+ {% endblock operator_logo %}
54
+
55
+ {% block header_tools %}
56
+ {% if request %}
57
+ {% top_menu %}
58
+ {% language_selector %}
59
+ {% endif %}
60
+ {% include "sites_conformes_core/blocks/user_menu.html" %}
61
+ {% endblock header_tools %}
62
+
63
+ {% block header_search %}
64
+ {% translate "Search" as search_label %}
65
+ {% if settings.sites_conformes_core.CmsDsfrConfig.search_bar %}
66
+ <div class="fr-header__search fr-modal" id="modal-search">
67
+ <div class="fr-container fr-container-lg--fluid">
68
+ {% translate "Close" as close_label %}
69
+ <button class="fr-btn--close fr-btn"
70
+ aria-controls="modal-search"
71
+ title="{{ close_label }}">{{ close_label }}</button>
72
+ <form action="{% url 'cms_search' %}" method="get">
73
+ <div class="fr-search-bar" id="search-bar" role="search">
74
+ <label class="fr-label" for="query">{{ search_label }}</label>
75
+ <input class="fr-input"
76
+ placeholder="{{ search_label }}"
77
+ type="search"
78
+ id="query"
79
+ name="q">
80
+ <button class="fr-btn" title="{{ search_label }}">{{ search_label }}</button>
81
+ </div>
82
+ </form>
83
+ </div>
84
+ </div>
85
+ {% endif %}
86
+ {% endblock header_search %}
87
+
88
+ {% block burger_menu %}
89
+ {% translate "Search" as search_label %}
90
+ <nav role=navigation class="fr-header__navbar">
91
+ {% if settings.sites_conformes_core.CmsDsfrConfig.search_bar %}
92
+ <button class="fr-btn--search fr-btn"
93
+ data-fr-opened="false"
94
+ aria-controls="modal-search"
95
+ id="fr-btn-search-mobile"
96
+ title="{{ search_label }}">{{ search_label }}</button>
97
+ {% endif %}
98
+ {% translate "Menu" as menu_label %}
99
+ <button class="fr-btn--menu fr-btn"
100
+ data-fr-opened="false"
101
+ aria-controls="fr-menu-mobile"
102
+ id="fr-btn-menu-mobile"
103
+ title="{{ menu_label }}">{{ menu_label }}</button>
104
+ </nav>
105
+ {% endblock burger_menu %}
106
+
107
+ {% block main_menu %}
108
+ {% if request %}
109
+ <div class="fr-header__menu fr-modal"
110
+ id="fr-menu-mobile"
111
+ aria-labelledby="fr-btn-menu-mobile">
112
+ <div class="fr-container">
113
+ {% translate "Close" as close_label %}
114
+ <button type="button"
115
+ class="fr-btn--close fr-btn"
116
+ aria-controls="fr-menu-mobile">{{ close_label }}</button>
117
+ <div class="fr-header__menu-links"></div>
118
+ {% translate "Main menu" as main_menu_label %}
119
+ <nav class="fr-nav" id="fr-navigation" aria-label="{{ main_menu_label }}">
120
+ {% main_menu %}
121
+ </nav>
122
+ </div>
123
+ </div>
124
+ {% endif %}
125
+ {% endblock main_menu %}