From 17922e5db4da36b7ae9b89b2e91fe4974a64243c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9l=C3=A8ne=20Jonin?= Date: Thu, 25 Jan 2024 16:45:10 +0100 Subject: [PATCH 1/9] Update card component for more genericity --- _includes/components/card.njk | 38 ++++++++++++++++++--------------- _includes/previousnextlinks.njk | 37 +++++++++++--------------------- content/fr/blog/posts/carte.md | 6 +++--- 3 files changed, 37 insertions(+), 44 deletions(-) diff --git a/_includes/components/card.njk b/_includes/components/card.njk index 66fa65b7..1bbf5265 100644 --- a/_includes/components/card.njk +++ b/_includes/components/card.njk @@ -1,5 +1,5 @@ {% if not card %}{% set card = params %}{% endif %} -
+
{% set cardUrl = card.url | locale_url or card.externalUrl %} @@ -37,20 +37,24 @@ {% endif %}
-
- {% if card.badges %} -
    - {% for badge in card.badges %} -
  • {{ badge }}

  • - {% endfor %} -
- {% endif %} - {% if card.image.path %} -
{% imageSync card.image.path, card.image.alt %}
- {% elif card.image.src %} -
- {{ card.image.alt }} -
- {% endif %} -
+ {% if card.badges or card.image %} +
+ {% if card.badges %} +
    + {% for badge in card.badges %} +
  • {{ badge }}

  • + {% endfor %} +
+ {% endif %} + {% if card.image %} + {% if card.image.path %} +
{% imageSync card.image.path, card.image.alt %}
+ {% elif card.image.src %} +
+ {{ card.image.alt }} +
+ {% endif %} + {% endif %} +
+ {% endif %}
\ No newline at end of file diff --git a/_includes/previousnextlinks.njk b/_includes/previousnextlinks.njk index 08e55973..af7ceb7a 100644 --- a/_includes/previousnextlinks.njk +++ b/_includes/previousnextlinks.njk @@ -1,3 +1,4 @@ +{% from "components/component.njk" import component with context %} {% set previousPost = currentPosts | filterCollectionLang | getPreviousCollectionItem %} {% set nextPost = currentPosts | filterCollectionLang | getNextCollectionItem %} {% if nextPost or previousPost %} @@ -6,34 +7,22 @@
{% if previousPost %}
- + {{ component("card", { + url: previousPost.url, + title: previousPost.data.title, + date: previousPost.date, + addClass: "fr-card--horizontal-tier fr-card--grey fr-card--no-border fr-card--sm" + }) }}
{% endif %} {% if nextPost %}
- + {{ component("card", { + url: nextPost.url, + title: nextPost.data.title, + date: nextPost.date, + addClass: "fr-card--horizontal-tier fr-card--grey fr-card--no-border fr-card--sm" + }) }}
{% endif %}
diff --git a/content/fr/blog/posts/carte.md b/content/fr/blog/posts/carte.md index d38e1984..17d0109d 100644 --- a/content/fr/blog/posts/carte.md +++ b/content/fr/blog/posts/carte.md @@ -24,7 +24,7 @@ Chaque composant peut être inclus dans un fichier Nunjucks `.njk` ou Markdown ` src: "/img/placeholder.16x9.png", alt: "" }, - orientation: "horizontal" + addClass: "fr-card--horizontal-tier" }) }} {% endraw %} ``` @@ -45,7 +45,7 @@ Le format complet de l'objet en paramètre est le suivant : "src | path": "string", "alt": "string" }, - "orientation": "horizontal | vertical" + "addClass": "string" } ``` @@ -70,7 +70,7 @@ Si `card.externalUrl` est utilisé, `card.url` doit être `false`. `card.urlDesc src : "/img/placeholder.16x9.png", alt: "" }, - orientation: "horizontal" + addClass: "fr-card--horizontal-tier" }) }}
From bf8ed35641b33854c7df4cf2606312d8a81765f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9l=C3=A8ne=20Jonin?= Date: Thu, 25 Jan 2024 19:06:19 +0100 Subject: [PATCH 2/9] Small code improvement --- _data/i18n/index.js | 2 +- eleventy.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_data/i18n/index.js b/_data/i18n/index.js index 5f2e284d..fa820a0b 100644 --- a/_data/i18n/index.js +++ b/_data/i18n/index.js @@ -20,5 +20,5 @@ const buildTranslations = () => { module.exports = { availableLang: langDirectories, - ...buildTranslations() + translations: buildTranslations() }; diff --git a/eleventy.config.js b/eleventy.config.js index 9f73e900..ea48342b 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -14,7 +14,7 @@ const pluginCalendar = require("@codegouvfr/eleventy-plugin-calendar"); const customMarkdownContainers = require("./markdown-custom-containers"); -const translations = require("./_data/i18n"); +const {translations} = require("./_data/i18n"); module.exports = function (eleventyConfig) { // Copy the contents of the `public` folder to the output folder From 34efdf5faafa0e270e1accc339087ef27c9b8b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9l=C3=A8ne=20Jonin?= Date: Fri, 26 Jan 2024 18:57:30 +0100 Subject: [PATCH 3/9] Update awesome --- _data/awesome | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/awesome b/_data/awesome index 0e5eb4eb..a5fe0938 160000 --- a/_data/awesome +++ b/_data/awesome @@ -1 +1 @@ -Subproject commit 0e5eb4ebe5018355fd878241d3b622d1b81389d8 +Subproject commit a5fe09385aa06f49883383aeee8f6c592a29cce3 From 18999f0e26d4d562796e892d492e1e1232c5a433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9l=C3=A8ne=20Jonin?= Date: Fri, 26 Jan 2024 18:46:36 +0100 Subject: [PATCH 4/9] Update card usage after eleventy-dsfr upgrade --- _includes/postslist.njk | 2 +- content/fr/bluehats/bsoc/2022/promotion.njk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_includes/postslist.njk b/_includes/postslist.njk index cc65c611..5285a509 100644 --- a/_includes/postslist.njk +++ b/_includes/postslist.njk @@ -13,7 +13,7 @@ path: post.data.image.path | resolvePath(post), alt: post.data.image.alt }, - orientation: "horizontal" + addClass: "fr-card--horizontal-tier" }) }} {% endall %} diff --git a/content/fr/bluehats/bsoc/2022/promotion.njk b/content/fr/bluehats/bsoc/2022/promotion.njk index f0c5ebd0..3da07928 100644 --- a/content/fr/bluehats/bsoc/2022/promotion.njk +++ b/content/fr/bluehats/bsoc/2022/promotion.njk @@ -22,7 +22,7 @@ permalink: /fr/bluehats/bsoc-promotion-2022/ path: person.imagePath, alt: person.name }, - orientation: "horizontal" + orientation: "fr-card--horizontal-tier" }) }} {% endall %} From 9d8ae0b8e7c6c5b7c3ed1ffbf11a4dd8cb0bc4d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9l=C3=A8ne=20Jonin?= Date: Fri, 26 Jan 2024 18:49:38 +0100 Subject: [PATCH 5/9] Update homepage * Fetch SILL data * Add dynamic cards --- _data/sill.js | 13 +++++++ _includes/components/card-custom-home.njk | 30 +++++++++++++++ content/fr/index.11tydata.js | 4 +- content/fr/index.njk | 47 +++++++++++++++++++++++ eleventy.config.js | 4 +- package-lock.json | 1 + package.json | 1 + public/css/index.css | 11 ++++++ 8 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 _data/sill.js create mode 100644 _includes/components/card-custom-home.njk diff --git a/_data/sill.js b/_data/sill.js new file mode 100644 index 00000000..a9365a98 --- /dev/null +++ b/_data/sill.js @@ -0,0 +1,13 @@ +const EleventyFetch = require("@11ty/eleventy-fetch"); + +module.exports = async function () { + const URL = "https://code.gouv.fr/data/sill.json"; + // const URL = "https://code.gouv.fr/sill/api/sill.json"; // To use when SILL is up + + let sill = await EleventyFetch(URL, { + duration: "2w", + type: "json" + }); + + return sill; +}; \ No newline at end of file diff --git a/_includes/components/card-custom-home.njk b/_includes/components/card-custom-home.njk new file mode 100644 index 00000000..28dfa5de --- /dev/null +++ b/_includes/components/card-custom-home.njk @@ -0,0 +1,30 @@ +{% if not card %}{% set card = params %}{% endif %} + \ No newline at end of file diff --git a/content/fr/index.11tydata.js b/content/fr/index.11tydata.js index 52e927f2..e0b1dcd4 100644 --- a/content/fr/index.11tydata.js +++ b/content/fr/index.11tydata.js @@ -2,13 +2,13 @@ module.exports = { actions: [ { url: "/fr/utiliser/", - title: "Utiliser", + title: "Pour l'administration", description: "Mieux connaître, utiliser et concevoir les logiciels libres et les communs numériques.", }, { url: false, externalUrl: "https://code.gouv.fr/public/", - title: "Publier", + title: "Par les administrations", description: "Développer et accompagner l’ouverture et la libération des codes sources de l'administration.", }, { diff --git a/content/fr/index.njk b/content/fr/index.njk index c2d36b16..66bb7f93 100644 --- a/content/fr/index.njk +++ b/content/fr/index.njk @@ -23,6 +23,53 @@ eleventyNavigation:
+ {% from "components/component.njk" import component with context %} +
+
+

Des logiciels libres pour et par les administrations

+
+
+
+
+ {% set randomSoftware = sill | random %} + {% if randomSoftware.logoUrl %} + {% set randomSoftwareImage = { + src: randomSoftware.logoUrl, + alt: "Logo de " + randomSoftware.n + } %} + {% endif %} + {{ component("card-custom-home", { + url: false, + externalUrl: "https://code.gouv.fr/sill/" + randomSoftware.n, + title: randomSoftware.n, + image: randomSoftwareImage, + detail: "Un logiciel au hasard" + }) }} +
+
+ {% set randomSourceCode = awesome.dist | values | random %} + {% if randomSourceCode.logo %} + {% set randomSourceCodeImage = { + src: randomSourceCode.logo, + alt: "Logo de " + randomSourceCode.name + } %} + {% endif %} + {{ component("card-custom-home", { + url: "/awesome/" | locale_url, + title: randomSourceCode.name, + image: randomSourceCodeImage, + detail: "Un projet au hasard" + }) }} +
+
+ {% set latestBlueHatsPost = collections.bluehats_posts | filterCollectionLang | last %} + {{ component("card-custom-home", { + url: latestBlueHatsPost.url, + title: latestBlueHatsPost.data.title, + announcement: "La dernière actualité BlueHats" + }) }} +
+
{% for tile in actions %}
diff --git a/eleventy.config.js b/eleventy.config.js index 2fa5e994..c7079ccc 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -147,9 +147,7 @@ module.exports = function (eleventyConfig) { return collection.find(post => post.fileSlug === slug); }); - eleventyConfig.addFilter("stripTags", str => { - return (str || "").replace(/<[^>]*>/g, ''); - }); + eleventyConfig.addFilter("values", object => Object.values(object)); // Customize Markdown library settings: eleventyConfig.amendLibrary("md", mdLib => { diff --git a/package-lock.json b/package-lock.json index 1ac22e4c..d1811e87 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "MIT", "devDependencies": { "@11ty/eleventy": "^2.0.1", + "@11ty/eleventy-fetch": "^4.0.0", "@11ty/eleventy-img": "^3.1.8", "@11ty/eleventy-navigation": "^0.3.5", "@11ty/eleventy-plugin-bundle": "^1.0.5", diff --git a/package.json b/package.json index a29dbf84..7f5bd838 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "homepage": "https://code.gouv.fr/", "devDependencies": { "@11ty/eleventy": "^2.0.1", + "@11ty/eleventy-fetch": "^4.0.0", "@11ty/eleventy-img": "^3.1.8", "@11ty/eleventy-navigation": "^0.3.5", "@11ty/eleventy-plugin-bundle": "^1.0.5", diff --git a/public/css/index.css b/public/css/index.css index 456a1824..4fb6725b 100644 --- a/public/css/index.css +++ b/public/css/index.css @@ -152,3 +152,14 @@ div.fr-callout__text p { .text-center { text-align: center; } + +.custom-card__img { + height: 100%; + display: flex; + justify-content: center; + align-items: center; +} + +.custom-card__img img { + width: 50%; +} From 120d21050a65e6bc1efce463484fe2966b386bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9l=C3=A8ne=20Jonin?= Date: Fri, 26 Jan 2024 18:59:41 +0100 Subject: [PATCH 6/9] Revert "Fix latest post tags" This reverts commit e1537e0a5107fdef319942e5f6254e002a8e9402. --- _data/awesome | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/awesome b/_data/awesome index a5fe0938..0e5eb4eb 160000 --- a/_data/awesome +++ b/_data/awesome @@ -1 +1 @@ -Subproject commit a5fe09385aa06f49883383aeee8f6c592a29cce3 +Subproject commit 0e5eb4ebe5018355fd878241d3b622d1b81389d8 From 4936d8172627bcec5311248bce06fb2f1b510ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9l=C3=A8ne=20Jonin?= Date: Fri, 26 Jan 2024 19:00:28 +0100 Subject: [PATCH 7/9] Fix latest post tags for real --- .../index.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/content/fr/blog/posts/de-la-transparence-a-lexplicabilite-automatisee-des-algorithmes/index.md b/content/fr/blog/posts/de-la-transparence-a-lexplicabilite-automatisee-des-algorithmes/index.md index 071e7e7a..3f0d68ac 100644 --- a/content/fr/blog/posts/de-la-transparence-a-lexplicabilite-automatisee-des-algorithmes/index.md +++ b/content/fr/blog/posts/de-la-transparence-a-lexplicabilite-automatisee-des-algorithmes/index.md @@ -6,7 +6,10 @@ image: path: ./illustration-explication-algorithmes.png alt: "Exemple d'interface pour expliquer un traitement algorithmique" hide: True -tags: explicabilité algorithmes transparence +tags: + - explicabilité + - algorithmes + - transparence --- *La transparence algorithmique ne se résume pas à la publication des codes sources. Comme le reflète la page que nous avons dédiée aux [outils aidant à expliquer les décisions administratives](https://code.gouv.fr/fr/explicabilite/), les façons de traduire du texte juridique en code source informatique sont variées. La mission logiciels libres accueille une entrée de blog invitée proposée par Denis Merigoux, Marie Alauzen, Justine Banuls, Louis Gesbert et Émile Rolley ; ils nous présentent un travail de recherche récent sur ces sujets. Les recommandations formulées dans cette entrée de blog appartiennent à son auteur.* From e5bffdc6a9dcf397fe49d86f4b9804905bff109b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9l=C3=A8ne=20Jonin?= Date: Fri, 26 Jan 2024 19:01:07 +0100 Subject: [PATCH 8/9] Update awesome --- _data/awesome | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_data/awesome b/_data/awesome index 0e5eb4eb..a5fe0938 160000 --- a/_data/awesome +++ b/_data/awesome @@ -1 +1 @@ -Subproject commit 0e5eb4ebe5018355fd878241d3b622d1b81389d8 +Subproject commit a5fe09385aa06f49883383aeee8f6c592a29cce3 From 9f92c1a157bd68b58d3b9da1aaf29a5d1bedafa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9l=C3=A8ne=20Jonin?= Date: Fri, 26 Jan 2024 19:16:27 +0100 Subject: [PATCH 9/9] Bump node version in workflows Following GitHub warning --- .github/workflows/preproduction.yml | 2 +- .github/workflows/production.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/preproduction.yml b/.github/workflows/preproduction.yml index 958875de..be10ea5d 100644 --- a/.github/workflows/preproduction.yml +++ b/.github/workflows/preproduction.yml @@ -17,7 +17,7 @@ jobs: submodules: true - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 18 cache: 'npm' - name: Build with Eleventy run: | diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index c17a58ed..8f3fc3ce 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -17,7 +17,7 @@ jobs: submodules: true - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 18 cache: 'npm' - name: Build with Eleventy run: |