From 888aec1003f675e90e57719424d1a61e54507a57 Mon Sep 17 00:00:00 2001 From: Pierre MARTIN Date: Wed, 18 Nov 2026 15:15:08 +0100 Subject: [PATCH] =?UTF-8?q?Ic=C3=B4nes=20PNG=20de=20l'=C3=A9cran=20d'accue?= =?UTF-8?q?il=20(make=20icons)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- Makefile | 14 ++++++++++++ app/icons/apple-touch-icon.png | Bin 0 -> 352 bytes app/icons/icon-192.png | Bin 0 -> 234 bytes app/icons/icon-512.png | Bin 0 -> 302 bytes app/icons/icon-maskable-512.png | Bin 0 -> 279 bytes app/index.html | 1 + app/manifest.webmanifest | 3 +++ scripts/icons.cjs | 38 ++++++++++++++++++++++++++++++++ tests/test_site.sh | 5 +++++ 9 files changed, 61 insertions(+) create mode 100644 app/icons/apple-touch-icon.png create mode 100644 app/icons/icon-192.png create mode 100644 app/icons/icon-512.png create mode 100644 app/icons/icon-maskable-512.png create mode 100644 scripts/icons.cjs diff --git a/Makefile b/Makefile index b596339..03c8216 100644 --- a/Makefile +++ b/Makefile @@ -90,6 +90,20 @@ $(PLAYWRIGHT) $(QR_READER) &: # service worker actif), copié dans un dossier temporaire que le parcours # modifie pour publier une « deuxième version » (bandeau de mise à jour). Le # conteneur partage le réseau de l'hôte pour joindre le serveur. +# Icônes PNG de l'écran d'accueil (192, 512, maskable 512, apple-touch-icon 180), +# dessinées depuis les SVG de app/icons/ par le Chromium de l'image Playwright +# (scripts/icons.cjs), puis allégées par optipng s'il est installé. Les PNG sont +# commités : à relancer seulement quand un SVG change. +.PHONY: icons +icons: $(PLAYWRIGHT) ## Régénère les icônes PNG depuis app/icons/*.svg (Docker) + @docker run --rm --init --ipc=host -u "$$(id -u):$$(id -g)" -e HOME=/tmp \ + -v "$(CURDIR)/$(APP_DIR)/icons:/icons" -v "$(CURDIR)/scripts:/scripts:ro" \ + -v "$(CURDIR)/$(BROWSER_TOOLS):/tools:ro" \ + $(PLAYWRIGHT_IMAGE) node /scripts/icons.cjs /icons + @if command -v optipng >/dev/null; then optipng -quiet -o7 -strip all $(APP_DIR)/icons/*.png; \ + else echo "optipng absent : PNG non optimisés."; fi + @ls -l $(APP_DIR)/icons/*.png + .PHONY: test-browser test-browser: $(PLAYWRIGHT) $(QR_READER) ## Parcours Playwright de l'app, captures dans build/shots/ (Docker) @mkdir -p build/shots diff --git a/app/icons/apple-touch-icon.png b/app/icons/apple-touch-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..b094776da95a5edd62f593aa55c6f2a52222fb44 GIT binary patch literal 352 zcmeAS@N?(olHy`uVBq!ia0vp^TR@nD8Ax&oe*=;XP60k4u0WcNjg6h1or8mei<3b> zfL~l(OhKAaU5P_WnbFeHBEXqBIy$nWh_$@&9XF zK^9sbKvQmdx;TbZ+G2N=ti$4v6`1GfI%>8%t#bMhb zxj2jC+u0$K5LN$^O2p=^>%4!XU5RgJi{tbk+cUEL<4+6T!D0DWm!Wu>z?HfpFX|$ z`K0>)H7>E3OO8N^37#&FAr-gYUfsyq;vnD<$SfVPfz8`sA9MBwhNG|dw=lOCC-RCo z^1je>`G8J?`dA}E7_g#76 zsEui*xtz?t-~KWt(;q87yIso&1dY;m*Xw37fq^=+H46yL;|7__Fy||4wq5Rri3!`z OfViHnelF{r5}E*T7EpTt literal 0 HcmV?d00001 diff --git a/app/icons/icon-512.png b/app/icons/icon-512.png new file mode 100644 index 0000000000000000000000000000000000000000..d99cae18624576e6d50b7513d3bfe45045e7674d GIT binary patch literal 302 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7?_xWRHv9tCXnI`@Ck7R(w{!P`G1Y;kGC)@ zkn_OP#WAGf*4rC~d<=pD4uR84JeP;8ov?wkRrPnAwc6)wMW7-yu&1Nfb~Y0Whk$}Z z0|O&6!@^p@_SgB<8&O43)HU2@e&n!ogULJ&K@9Ccg$JH9)_JjFF&bt_4^vqV7mS0f h?!g)~X9Bqo#ElZ}a!t7Yd3G{L($m$?Wt~$(696=9KjHuY literal 0 HcmV?d00001 diff --git a/app/icons/icon-maskable-512.png b/app/icons/icon-maskable-512.png new file mode 100644 index 0000000000000000000000000000000000000000..afa51d43feb6f76fcde4355c606671fba53e8819 GIT binary patch literal 279 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7?_xWRHv9tCXnI`@Ck7R(w{!P`G1Y;kGC)@ zkaN=0#WAGf*4x{Pd<_OX4i_bPmLEP-V8zoGtQXm=$!56usqIaZm)nK4L5i_}e>Yye zme`@?(7?dR#KIw<0Ag%rv$;Dp{M!s}2p296WJDM&NGp7C?y>Q+`K1UAAQcAn4$mv~ oP|N{qJfJU)q7aK4fI)boFyt=akR{0Pj^lxc~qF literal 0 HcmV?d00001 diff --git a/app/index.html b/app/index.html index 5c2d4a3..c941af6 100644 --- a/app/index.html +++ b/app/index.html @@ -10,6 +10,7 @@ IA-Fit + diff --git a/app/manifest.webmanifest b/app/manifest.webmanifest index d38f07b..924c0ab 100644 --- a/app/manifest.webmanifest +++ b/app/manifest.webmanifest @@ -10,6 +10,9 @@ "background_color": "#000000", "theme_color": "#000000", "icons": [ + { "src": "icons/icon-192.png", "sizes": "192x192", "type": "image/png", "purpose": "any" }, + { "src": "icons/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any" }, + { "src": "icons/icon-maskable-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" }, { "src": "icons/icon.svg", "sizes": "any", "type": "image/svg+xml", "purpose": "any" }, { "src": "icons/icon-maskable.svg", "sizes": "any", "type": "image/svg+xml", "purpose": "maskable" } ] diff --git a/scripts/icons.cjs b/scripts/icons.cjs new file mode 100644 index 0000000..fe8b4f5 --- /dev/null +++ b/scripts/icons.cjs @@ -0,0 +1,38 @@ +// Génère les icônes PNG de l'app à partir des SVG de app/icons/ : iOS n'accepte +// pas le SVG pour l'écran d'accueil, et Android en veut en 192 et 512 px. +// Lancé par `make icons` dans l'image Docker de Playwright (Chromium dessine le +// SVG, puis une capture à la taille exacte) : +// node icons.cjs +// Les PNG produits sont commités : on ne relance ce script que si un SVG change. + +const fs = require("node:fs"); +const path = require("node:path"); +const { chromium } = require("/tools/node_modules/playwright"); + +const dir = path.resolve(process.argv[2] ?? "app/icons"); + +/** Fichier produit, SVG source, côté en pixels. */ +const ICONS = [ + ["icon-192.png", "icon.svg", 192], + ["icon-512.png", "icon.svg", 512], + ["icon-maskable-512.png", "icon-maskable.svg", 512], + ["apple-touch-icon.png", "icon.svg", 180], +]; + +(async () => { + const browser = await chromium.launch(); + for (const [out, src, size] of ICONS) { + const page = await browser.newPage({ viewport: { width: size, height: size }, deviceScaleFactor: 1 }); + const svg = fs.readFileSync(path.join(dir, src)).toString("base64"); + await page.setContent(`` + + ``); + await page.locator("img").evaluate((img) => img.decode()); + await page.screenshot({ path: path.join(dir, out), clip: { x: 0, y: 0, width: size, height: size } }); + await page.close(); + console.log(`${out} : ${src} en ${size} px`); + } + await browser.close(); +})().catch((e) => { + console.error(e); + process.exit(1); +}); diff --git a/tests/test_site.sh b/tests/test_site.sh index c2d0d31..7289de1 100755 --- a/tests/test_site.sh +++ b/tests/test_site.sh @@ -108,6 +108,11 @@ while read -r module; do done < <(cd "$site" && find . -name '*.js' | sed 's|^\./||') check "sw.js" "text/javascript" check "manifest.webmanifest" "application/manifest\+json" +# Chaque icône du manifeste est servie avec le type qu'il déclare. +while read -r src type; do + check "$src" "${type//+/\\+}" +done < <(curl -s "$base/manifest.webmanifest" | grep -oE '"src": "[^"]+",[^}]*"type": "[^"]+"' \ + | sed -E 's/^"src": "([^"]+)".*"type": "([^"]+)"$/\1 \2/') check "__essai__/police.woff2" "font/woff2" check "version.json" "application/json" # Prompt d'accueil pour une IA qui navigue, s'il existe déjà dans app/.