feat(media): carte de publication entièrement cliquable, image, auteurs et école (lot XL publications M3)
Un seul <a class="projet-carte"> par carte (nouvel onglet, rel=noopener), focus --focus-ring autour de la carte, « Découvrir » en indice visuel. Image 800x600 lazy, width/height posés, alt qui nomme le projet et ses auteurs, crédit dans la carte. Auteurs « A, B et C », école et année sur une ligne, jamais « Inconnu ». Test scripts/test-media-data.mjs ajouté à npm run test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWGVn3kY4vPBaWF9EFkZbz
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
58d8592191
commit
22692f79a7
+150
-33
@@ -8,25 +8,31 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="projets-grid">
|
||||
<article v-for="p in projets" :key="p.id" class="projet-card">
|
||||
<img v-if="p.thumb" :src="p.thumb" :alt="p.titre" class="projet-thumb" loading="lazy" />
|
||||
<div v-else class="projet-thumb projet-thumb--placeholder">📐</div>
|
||||
|
||||
<h3 style="font-weight: 600; font-size: 0.95rem; margin: 0.5rem 0 0.25rem; color: var(--nav-text);">{{ p.titre }}</h3>
|
||||
<p style="font-size: 0.8rem; color: var(--nav-text-muted); margin-bottom: 0.5rem;">
|
||||
{{ (p.auteurs || []).filter((a: string) => a !== 'Inconnu').join(', ') }}
|
||||
<template v-if="p.ecole && p.ecole !== 'Inconnu'"> · {{ p.ecole }}</template>
|
||||
<template v-if="p.annee && p.annee !== 'Inconnu'"> · {{ p.annee }}</template>
|
||||
</p>
|
||||
<p style="font-size: 0.875rem; line-height: 1.5; color: var(--nav-text); flex: 1; margin-bottom: 0.75rem;">{{ p.description }}</p>
|
||||
|
||||
<a v-if="p.url" :href="p.url" target="_blank" rel="noopener" style="color: var(--nav-primary-solid, #3b6ea5); font-weight: 600; font-size: 0.875rem; text-decoration: none;">
|
||||
Découvrir →
|
||||
<!-- Lot XL publications : toute la carte est le lien (un seul <a>), image en tête, auteurs nommés. -->
|
||||
<ul class="projets-grid" role="list">
|
||||
<li v-for="p in projets" :key="p.id">
|
||||
<a class="projet-carte" :href="p.url" target="_blank" rel="noopener">
|
||||
<img
|
||||
class="projet-carte__image"
|
||||
:src="p.illustration"
|
||||
:alt="altDe(p)"
|
||||
width="800"
|
||||
height="600"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
/>
|
||||
<span class="projet-carte__corps">
|
||||
<h3 class="projet-carte__titre">{{ p.titre }}</h3>
|
||||
<span class="projet-carte__auteurs">{{ signature(p) }}</span>
|
||||
<span v-if="meta(p)" class="projet-carte__meta">{{ meta(p) }}</span>
|
||||
<span class="projet-carte__description">{{ p.description }}</span>
|
||||
<span v-if="p.credit_illustration" class="projet-carte__credit">Image : {{ minuscule(p.credit_illustration) }}</span>
|
||||
<span v-if="p.link_status === 'broken'" class="projet-carte__alerte">Lien d'origine cassé</span>
|
||||
<span class="projet-carte__indice">Découvrir<span class="sr-only"> (nouvel onglet)</span></span>
|
||||
</span>
|
||||
</a>
|
||||
<span v-if="p.link_status === 'broken'" style="color: #e67e22; font-size: 0.8rem; display: block; margin-top: 0.25rem;">⚠ Lien d'origine cassé</span>
|
||||
</article>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p style="margin-top: 2rem; font-size: 0.875rem; color: var(--nav-text-muted);">
|
||||
Tu as un PFE engagé à partager ? <a href="mailto:contact@trans-former.fr" style="color: var(--nav-primary-solid);">Écris-moi</a>.
|
||||
@@ -35,33 +41,144 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { data: pfeData } = await useFetch<{ projets: any[] }>('/data/pfe-engages.json')
|
||||
interface Projet {
|
||||
id: string
|
||||
titre: string
|
||||
collectif?: string
|
||||
auteurs: string[]
|
||||
annee?: string | null
|
||||
ecole?: string | null
|
||||
url: string
|
||||
description: string
|
||||
illustration: string
|
||||
illustration_a_venir?: boolean
|
||||
credit_illustration?: string | null
|
||||
link_status?: string
|
||||
}
|
||||
|
||||
const { data: pfeData } = await useFetch<{ projets: Projet[] }>('/data/pfe-engages.json')
|
||||
const projets = computed(() => pfeData.value?.projets ?? [])
|
||||
|
||||
/** « A », « A et B », « A, B et C ». */
|
||||
function enumere(noms: string[]): string {
|
||||
const n = noms.filter(a => a && a !== 'Inconnu')
|
||||
return n.length < 2 ? (n[0] ?? '') : `${n.slice(0, -1).join(', ')} et ${n[n.length - 1]}`
|
||||
}
|
||||
function signature(p: Projet): string {
|
||||
const noms = enumere(p.auteurs || [])
|
||||
return p.collectif ? `${p.collectif} : ${noms}` : noms
|
||||
}
|
||||
function meta(p: Projet): string {
|
||||
return [p.ecole, p.annee].filter(v => v && v !== 'Inconnu').join(', ')
|
||||
}
|
||||
function minuscule(s: string): string {
|
||||
return s.charAt(0).toLowerCase() + s.slice(1)
|
||||
}
|
||||
function altDe(p: Projet): string {
|
||||
if (p.illustration_a_venir) return `Illustration à venir pour « ${p.titre} »`
|
||||
return `${p.credit_illustration ?? 'Illustration'} : « ${p.titre} », par ${enumere(p.auteurs || [])}`
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.projets-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||
grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
|
||||
gap: 1.25rem;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
.projet-card {
|
||||
border: 1px solid var(--nav-bg-alt, #eee);
|
||||
border-radius: 10px;
|
||||
padding: 1rem;
|
||||
.projets-grid > li {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
}
|
||||
.projet-carte {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: var(--nav-surface);
|
||||
}
|
||||
.projet-thumb {
|
||||
width: 100%;
|
||||
height: 140px;
|
||||
min-width: 0;
|
||||
min-height: 44px;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--border, var(--bg-alt));
|
||||
border-radius: var(--radius-md, 10px);
|
||||
background: var(--surface);
|
||||
color: var(--text);
|
||||
text-decoration: none;
|
||||
transition: background-color var(--dur-fast, 150ms) var(--ease-out, ease-out),
|
||||
box-shadow var(--dur-fast, 150ms) var(--ease-out, ease-out);
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.projet-carte { transition: none; }
|
||||
}
|
||||
.projet-carte:hover {
|
||||
background: var(--surface-2);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
.projet-carte:focus-visible {
|
||||
outline: 2px solid var(--focus-ring);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
.projet-carte__image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
aspect-ratio: 4 / 3;
|
||||
object-fit: cover;
|
||||
border-radius: 6px;
|
||||
background: var(--nav-bg-alt, #f5f5f5);
|
||||
background: var(--bg-alt);
|
||||
}
|
||||
.projet-carte__corps {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 2rem;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
gap: 0.35rem;
|
||||
padding: var(--space-sm, 0.75rem) var(--space-md, 1rem) var(--space-md, 1rem);
|
||||
}
|
||||
.projet-carte__titre {
|
||||
margin: 0.15rem 0 0;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 600;
|
||||
line-height: 1.35;
|
||||
}
|
||||
.projet-carte__auteurs {
|
||||
font-size: 0.85rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
/* Texte atténué : color-mix, pas --text-muted (sous AA à 0,8 rem), cf. DESIGN-SYSTEM.md */
|
||||
.projet-carte__meta,
|
||||
.projet-carte__credit {
|
||||
font-size: 0.8rem;
|
||||
color: color-mix(in srgb, var(--text) 78%, transparent);
|
||||
}
|
||||
.projet-carte__description {
|
||||
flex: 1;
|
||||
margin-top: 0.25rem;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.projet-carte__alerte {
|
||||
font-size: 0.8rem;
|
||||
color: var(--warning, #b45309);
|
||||
}
|
||||
.projet-carte__indice {
|
||||
margin-top: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: var(--nav-primary-solid);
|
||||
}
|
||||
.projet-carte:hover .projet-carte__indice {
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 3px;
|
||||
}
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
border: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
"dev": "nuxt dev",
|
||||
"generate": "nuxt generate",
|
||||
"preview": "nuxt preview",
|
||||
"test": "node scripts/test-echelles-nav.mjs && node scripts/test-figures.mjs && node scripts/test-vue-fiches.mjs && node scripts/test-submit-libre.mjs && node scripts/test-circuit-breaker.mjs && node scripts/test-bandeau.mjs && node scripts/test-outils-data.mjs && node scripts/test-citations.mjs && node scripts/test-seo.mjs && node scripts/test-y.mjs && node scripts/test-connaissances.mjs && node --test \"worker/test/*.test.js\"",
|
||||
"test": "node scripts/test-echelles-nav.mjs && node scripts/test-figures.mjs && node scripts/test-vue-fiches.mjs && node scripts/test-submit-libre.mjs && node scripts/test-circuit-breaker.mjs && node scripts/test-bandeau.mjs && node scripts/test-outils-data.mjs && node scripts/test-citations.mjs && node scripts/test-seo.mjs && node scripts/test-y.mjs && node scripts/test-connaissances.mjs && node scripts/test-media-data.mjs && node --test \"worker/test/*.test.js\"",
|
||||
"postinstall": "nuxt prepare"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Test des données de l'onglet « Publications » (/media?tab=projets, lot XL publications).
|
||||
* Six projets, auteurs nommés, jamais « Inconnu », une illustration WebP ≤ 60 Ko par projet,
|
||||
* et la carte entière comme seul lien.
|
||||
* Usage : node scripts/test-media-data.mjs
|
||||
*/
|
||||
|
||||
import { readFileSync, existsSync, statSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { dirname, join } from 'node:path'
|
||||
|
||||
const racine = join(dirname(fileURLToPath(import.meta.url)), '..')
|
||||
const echecs = []
|
||||
let n = 0
|
||||
function verifie(ok, message) {
|
||||
n++
|
||||
if (!ok) echecs.push(message)
|
||||
}
|
||||
|
||||
const { projets } = JSON.parse(readFileSync(join(racine, 'public/data/pfe-engages.json'), 'utf8'))
|
||||
verifie(Array.isArray(projets) && projets.length === 6, `six projets attendus, ${projets?.length} trouvés`)
|
||||
verifie(new Set(projets.map(p => p.id)).size === projets.length, 'identifiants en double')
|
||||
|
||||
const MAX = 60 * 1024
|
||||
for (const p of projets) {
|
||||
const id = p.id
|
||||
verifie(Array.isArray(p.auteurs) && p.auteurs.length > 0, `${id} : auteurs vides`)
|
||||
verifie((p.auteurs || []).every(a => typeof a === 'string' && a.trim()), `${id} : un auteur vide`)
|
||||
verifie(!JSON.stringify(p).includes('Inconnu'), `${id} : « Inconnu » encore présent`)
|
||||
verifie(p.ecole === null || (typeof p.ecole === 'string' && p.ecole.trim()), `${id} : école ni nulle ni renseignée`)
|
||||
verifie(typeof p.url === 'string' && /^https?:\/\//.test(p.url), `${id} : url absente`)
|
||||
verifie(typeof p.illustration === 'string' && p.illustration === `/medias/publications/${id}.webp`,
|
||||
`${id} : illustration attendue en /medias/publications/${id}.webp`)
|
||||
const fichier = join(racine, 'public', p.illustration || '')
|
||||
verifie(existsSync(fichier), `${id} : fichier ${p.illustration} absent`)
|
||||
if (existsSync(fichier)) {
|
||||
const poids = statSync(fichier).size
|
||||
verifie(poids <= MAX, `${id} : ${poids} o, au-dessus de 60 Ko`)
|
||||
const tete = readFileSync(fichier).subarray(0, 12).toString('latin1')
|
||||
verifie(tete.startsWith('RIFF') && tete.slice(8) === 'WEBP', `${id} : le fichier n'est pas un WebP`)
|
||||
}
|
||||
verifie(p.illustration_a_venir === true || (typeof p.credit_illustration === 'string' && p.credit_illustration.trim()),
|
||||
`${id} : une image tirée du projet doit porter son crédit`)
|
||||
}
|
||||
|
||||
// Seine nature urbaine : site « tous droits réservés », placeholder tant que l'auteur n'a pas donné son accord.
|
||||
const seine = projets.find(p => p.id === 'seine-nature')
|
||||
verifie(seine?.illustration_a_venir === true, 'seine-nature : placeholder obligatoire (accord de l\'auteur en attente)')
|
||||
|
||||
// Composant : la carte entière est le seul lien, plus de « Découvrir → » en second lien.
|
||||
const vue = readFileSync(join(racine, 'components/MediaTabProjets.vue'), 'utf8')
|
||||
const gabarit = vue.slice(vue.indexOf('<template>'), vue.lastIndexOf('</template>'))
|
||||
const grille = gabarit.slice(gabarit.indexOf('projets-grid'), gabarit.indexOf('</ul>'))
|
||||
verifie((grille.match(/<a\b/g) || []).length === 1, 'un seul <a> par carte dans la grille')
|
||||
verifie(/class="projet-carte"/.test(grille), 'la carte porte la classe projet-carte')
|
||||
verifie(!/[↗→·]/.test(gabarit), 'ni flèche ni point médian dans le gabarit')
|
||||
verifie(/loading="lazy"/.test(grille) && /width="800"/.test(grille) && /height="600"/.test(grille),
|
||||
'image en lazy avec width et height posés')
|
||||
|
||||
if (echecs.length) {
|
||||
for (const e of echecs) console.log(`FAIL ${e}`)
|
||||
console.log(`\n${n - echecs.length}/${n} vérifications OK — ${echecs.length} échec(s)`)
|
||||
process.exit(1)
|
||||
}
|
||||
console.log(`${n} vérifications OK`)
|
||||
Reference in New Issue
Block a user