Icônes PNG de l'écran d'accueil (make icons)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
342829bf93
commit
888aec1003
@@ -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
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 352 B |
Binary file not shown.
|
After Width: | Height: | Size: 234 B |
Binary file not shown.
|
After Width: | Height: | Size: 302 B |
Binary file not shown.
|
After Width: | Height: | Size: 279 B |
@@ -10,6 +10,7 @@
|
||||
<title>IA-Fit</title>
|
||||
<link rel="manifest" href="manifest.webmanifest">
|
||||
<link rel="icon" href="icons/icon.svg" type="image/svg+xml">
|
||||
<link rel="apple-touch-icon" href="icons/apple-touch-icon.png">
|
||||
<link rel="preload" href="fonts/barlow-condensed-bold.woff2" as="font" type="font/woff2" crossorigin>
|
||||
<script src="ui/theme.js"></script>
|
||||
<link rel="stylesheet" href="styles/fonts.css">
|
||||
|
||||
@@ -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" }
|
||||
]
|
||||
|
||||
@@ -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 <dossier des icônes>
|
||||
// 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(`<style>html,body{margin:0}img{display:block;width:${size}px;height:${size}px}</style>` +
|
||||
`<img src="data:image/svg+xml;base64,${svg}" alt="">`);
|
||||
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);
|
||||
});
|
||||
@@ -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/.
|
||||
|
||||
Reference in New Issue
Block a user