Commit a095fa53 by PLN (Algolia)

les-femmes: chaque femme du mode WOMEN a sa fiche — 40 fiches simples (dates,…

les-femmes: chaque femme du mode WOMEN a sa fiche — 40 fiches simples (dates, pourquoi on la connaît niveau devinette de café, Wikipédia, portrait), fans en variante riche (vécu féministe du subagent), portraits téléchargés pour 64/69 slugs (licences PD/CC0/CC BY/CC BY-SA mappées à la main depuis la sortie du script), og cards régénérées avec licences
parent 4ed0f508
...@@ -254,7 +254,7 @@ export default function LesFemmesLanding({ personnages, femmes, femmesBySlug, ce ...@@ -254,7 +254,7 @@ export default function LesFemmesLanding({ personnages, femmes, femmesBySlug, ce
c.punchline, c.punchline,
avatar, avatar,
reveal, reveal,
c.femmeSlug ? `/les-femmes/${c.femmeSlug}` : null c.femmeSlug ? `/les-femmes/${c.femmeSlug}` : `/les-femmes/${c.slug}`
); );
})} })}
</ul> </ul>
......
...@@ -16,7 +16,7 @@ import style from "../style.module.css"; ...@@ -16,7 +16,7 @@ import style from "../style.module.css";
const FANS = CELEBRES.filter((c) => c.fiche); const FANS = CELEBRES.filter((c) => c.fiche);
export function generateStaticParams() { export function generateStaticParams() {
return [...FEMMES.map((f) => ({ femme: f.slug })), ...FANS.map((c) => ({ femme: c.slug }))]; return [...FEMMES.map((f) => ({ femme: f.slug })), ...CELEBRES.map((c) => ({ femme: c.slug }))];
} }
export async function generateMetadata({ params }) { export async function generateMetadata({ params }) {
...@@ -30,40 +30,41 @@ export async function generateMetadata({ params }) { ...@@ -30,40 +30,41 @@ export async function generateMetadata({ params }) {
image: femmeOg(femme.slug), image: femmeOg(femme.slug),
}); });
} }
const fan = FANS.find((c) => c.slug === slug); const celebre = CELEBRES.find((c) => c.slug === slug);
if (!fan) return {}; if (!celebre) return {};
return socialMeta({ return socialMeta({
title: `${fan.name} · Comment ça va, les femmes ?`, title: `${celebre.name} · Comment ça va, les femmes ?`,
description: fan.fiche.pourquoi, description: celebre.fiche ? celebre.fiche.pourquoi : celebre.pourquoi ?? celebre.fait,
canonicalPath: `/les-femmes/${fan.slug}`, canonicalPath: `/les-femmes/${celebre.slug}`,
image: femmeOg(fan.slug), image: femmeOg(celebre.slug),
}); });
} }
function FanPage({ fan }) { function CelebrePage({ celebre }) {
const idx = FANS.findIndex((c) => c.slug === fan.slug); const idx = CELEBRES.findIndex((c) => c.slug === celebre.slug);
const prev = idx > 0 ? FANS[idx - 1].slug : null; const prev = idx > 0 ? CELEBRES[idx - 1].slug : null;
const next = idx < FANS.length - 1 ? FANS[idx + 1].slug : null; const next = idx < CELEBRES.length - 1 ? CELEBRES[idx + 1].slug : null;
const img = getImage(fan.slug); const img = getImage(celebre.slug);
const commonsUrl = img const commonsUrl = img
? `https://commons.wikimedia.org/wiki/File:${encodeURIComponent(img.commons)}` ? `https://commons.wikimedia.org/wiki/File:${encodeURIComponent(img.commons)}`
: null; : null;
const commonsLabel = img?.commons.replace(/\.[a-z0-9]+$/i, "").replace(/_/g, " "); const commonsLabel = img?.commons.replace(/\.[a-z0-9]+$/i, "").replace(/_/g, " ");
const wikiHref = `https://fr.wikipedia.org/wiki/${encodeURIComponent(fan.fiche.wikipedia)}`; const wikiHref = celebre.wikipedia
? `https://fr.wikipedia.org/wiki/${encodeURIComponent(celebre.wikipedia)}`
: null;
return ( return (
<main className={style.root}> <main className={style.root}>
<Header femmeName={fan.name} /> <Header femmeName={celebre.name} />
<div className={style.femmeGrid}> <div className={style.femmeGrid}>
<article> <article>
<header className={style.femmeHeader}> <header className={style.femmeHeader}>
<h1 className={style.femmeName}>{fan.name}</h1> <h1 className={style.femmeName}>{celebre.name}</h1>
<p className={style.personnageRef}> <p className={style.personnageRef}>
<span className={style.badge} style={{ background: "#7b3f8c" }}> <span className={style.badge} style={{ background: "#7b3f8c" }}>
« {fan.punchline} » « {celebre.punchline} »
</span> </span>
{" — "} {celebre.dates ? <> · {celebre.dates}</> : null}
{fan.fait}
</p> </p>
</header> </header>
...@@ -71,27 +72,38 @@ function FanPage({ fan }) { ...@@ -71,27 +72,38 @@ function FanPage({ fan }) {
<div className={style.panelHead}> <div className={style.panelHead}>
<h2 className={style.panelTitle}>Pourquoi tout le monde la connaît</h2> <h2 className={style.panelTitle}>Pourquoi tout le monde la connaît</h2>
</div> </div>
<p className={style.entryText}>{fan.fiche.pourquoi}</p> <p className={style.entryText}>{celebre.fiche ? celebre.fiche.pourquoi : celebre.pourquoi}</p>
</section>
<section className={style.panel}>
<div className={style.panelHead}>
<h2 className={style.panelTitle}>La punchline</h2>
</div>
<p className={style.entryText}>
« {celebre.punchline} » : {celebre.fait}.
</p>
</section> </section>
{celebre.fiche && (
<section className={style.panel}> <section className={style.panel}>
<div className={style.panelHead}> <div className={style.panelHead}>
<h2 className={style.panelTitle}>Le vécu, côté femmes</h2> <h2 className={style.panelTitle}>Le vécu, côté femmes</h2>
</div> </div>
<p className={style.entryText}>{fan.fiche.vecu}</p> <p className={style.entryText}>{celebre.fiche.vecu}</p>
</section> </section>
)}
<nav className={style.prevNext}> <nav className={style.prevNext}>
{prev ? ( {prev ? (
<Link href={`/les-femmes/${prev}`} className={style.prev}> <Link href={`/les-femmes/${prev}`} className={style.prev}>
← {FANS.find((c) => c.slug === prev)?.name} ← {CELEBRES.find((c) => c.slug === prev)?.name}
</Link> </Link>
) : ( ) : (
<span /> <span />
)} )}
{next && ( {next && (
<Link href={`/les-femmes/${next}`} className={style.next}> <Link href={`/les-femmes/${next}`} className={style.next}>
{FANS.find((c) => c.slug === next)?.name} → {CELEBRES.find((c) => c.slug === next)?.name} →
</Link> </Link>
)} )}
</nav> </nav>
...@@ -108,7 +120,7 @@ function FanPage({ fan }) { ...@@ -108,7 +120,7 @@ function FanPage({ fan }) {
<figure className={style.portrait}> <figure className={style.portrait}>
<img <img
src={`/images/les-femmes/${img.file}`} src={`/images/les-femmes/${img.file}`}
alt={`Portrait de ${fan.name}`} alt={`Portrait de ${celebre.name}`}
loading="eager" loading="eager"
decoding="async" decoding="async"
/> />
...@@ -122,14 +134,13 @@ function FanPage({ fan }) { ...@@ -122,14 +134,13 @@ function FanPage({ fan }) {
</p> </p>
</> </>
) : ( ) : (
<span <span className={style.avatarMono} style={{ background: "#7b3f8c22", color: "#7b3f8c", aspectRatio: "4/3" }}>
className={style.avatarMono} {celebre.name.slice(0, 1)}
style={{ background: "#7b3f8c22", color: "#7b3f8c", aspectRatio: "4/3" }}
>
{fan.name.slice(0, 1)}
</span> </span>
)} )}
{wikiHref && (
<>
<h2 className={style.asideTitle}>Wikipédia</h2> <h2 className={style.asideTitle}>Wikipédia</h2>
<ul className={style.linkList}> <ul className={style.linkList}>
<li> <li>
...@@ -138,10 +149,14 @@ function FanPage({ fan }) { ...@@ -138,10 +149,14 @@ function FanPage({ fan }) {
</a> </a>
</li> </li>
</ul> </ul>
</>
)}
{celebre.fiche && (
<>
<h2 className={style.asideTitle}>Pour aller plus loin</h2> <h2 className={style.asideTitle}>Pour aller plus loin</h2>
<ul className={style.linkList}> <ul className={style.linkList}>
{fan.fiche.sources.map((s) => ( {celebre.fiche.sources.map((s) => (
<li key={s.label}> <li key={s.label}>
{s.href ? ( {s.href ? (
<a href={s.href} target="_blank" rel="noopener noreferrer"> <a href={s.href} target="_blank" rel="noopener noreferrer">
...@@ -153,6 +168,8 @@ function FanPage({ fan }) { ...@@ -153,6 +168,8 @@ function FanPage({ fan }) {
</li> </li>
))} ))}
</ul> </ul>
</>
)}
</div> </div>
</aside> </aside>
</div> </div>
...@@ -161,7 +178,7 @@ function FanPage({ fan }) { ...@@ -161,7 +178,7 @@ function FanPage({ fan }) {
prev={prev} prev={prev}
next={next} next={next}
imgSrc={img ? `/images/les-femmes/${img.file}` : null} imgSrc={img ? `/images/les-femmes/${img.file}` : null}
imgAlt={fan.name} imgAlt={celebre.name}
/> />
<Footer /> <Footer />
</main> </main>
...@@ -172,8 +189,8 @@ export default async function FemmePage({ params }) { ...@@ -172,8 +189,8 @@ export default async function FemmePage({ params }) {
const { femme: slug } = await params; const { femme: slug } = await params;
const femme = getFemme(slug); const femme = getFemme(slug);
if (!femme) { if (!femme) {
const fan = FANS.find((c) => c.slug === slug); const celebre = CELEBRES.find((c) => c.slug === slug);
if (fan) return <FanPage fan={fan} />; if (celebre) return <CelebrePage celebre={celebre} />;
return null; return null;
} }
......
{
"olympe-de-gouges": {
"file": "olympe-de-gouges.png",
"commons": "Olympe_de_Gouges.png",
"license": "Public domain"
},
"emily-gerard": {
"file": "emily-gerard.webp",
"commons": "A-scotswoman-in-transylvania-emily-gerard_08c30aeea8.webp",
"license": "Public domain"
},
"simone-de-beauvoir": {
"file": "simone-de-beauvoir.png",
"commons": "Simone_de_Beauvoir2.png",
"license": "CC BY-SA 3.0"
},
"jeanne-d-arc": {
"file": "jeanne-d-arc.png",
"commons": "Contemporaine_afb_jeanne_d_arc.png",
"license": "?"
},
"taylor-swift": {
"file": "taylor-swift.png",
"commons": "Taylor_Swift_at_the_2023_MTV_Video_Music_Awards_(3).png",
"license": "?"
},
"laure-manaudou": {
"file": "laure-manaudou.png",
"commons": "Image_Laure_Manaudou.png",
"license": "?"
},
"serena-williams": {
"file": "serena-williams.png",
"commons": "Serena-Smiling-2020.png",
"license": "CC BY-SA 4.0"
},
"penelope": {
"file": "penelope.png",
"commons": "Odysseus_Penelope_Louvre_CA860_détourage.png",
"license": "?"
},
"jocaste-et-antigone": {
"file": "jocaste-et-antigone.jpg",
"commons": "Cabanel_Oedipus_Separating_from_Jocasta.jpg",
"license": "Public domain"
},
"sages-femmes": {
"file": "sages-femmes.jpg",
"commons": "Agnodice_engraving.jpg",
"license": "Public domain"
},
"elisabeth-de-boheme": {
"file": "elisabeth-de-boheme.jpg",
"commons": "1636_Elisabeth_of_Bohemia.jpg",
"license": "Public domain"
},
"soeurs-pascal": {
"file": "soeurs-pascal.jpg",
"commons": "Clermont-Ferrand_-_Musée_d'Art_Roger-Quilliot_-_Exposition_Les_mystères_de_Pascal_-_Jacqueline_Pascal_(anonyme_d'après_Philippe_de_Champaigne).jpg",
"license": "CC0"
},
"emilie-du-chatelet": {
"file": "emilie-du-chatelet.jpg",
"commons": "Le_Tonnelier_de_Breteuil,_Emilie.jpg",
"license": "Public domain"
},
"geoffrin-lespinasse": {
"file": "geoffrin-lespinasse.jpg",
"commons": "Jean-Marc_Nattier_-_Madame_Geoffrin.JPG",
"license": "Public domain"
},
"nannette-streicher": {
"file": "nannette-streicher.jpg",
"commons": "Nanette_Streicher_1836.jpg",
"license": "Public domain"
},
"johanna-et-adele-schopenhauer": {
"file": "johanna-et-adele-schopenhauer.jpg",
"commons": "Caroline_Bardua_-_Johanna_&_Adele_Schopenhauer_(1806).jpg",
"license": "Public domain"
},
"clemence-royer": {
"file": "clemence-royer.jpg",
"commons": "Clemence_Royer_1865_Nadar.jpg",
"license": "Public domain"
},
"flora-tristan-helene-demuth": {
"file": "flora-tristan-helene-demuth.jpg",
"commons": "Flora_Tristan_1838.JPG",
"license": "Public domain"
},
"elisabeth-forster-nietzsche": {
"file": "elisabeth-forster-nietzsche.jpg",
"commons": "Elisabeth_förster_1894a_(cropped).JPG",
"license": "Public domain"
},
"spielrein-pappenheim": {
"file": "spielrein-pappenheim.jpg",
"commons": "Sabina_Spielrein.jpg",
"license": "Public domain"
},
"marie-curie": {
"file": "marie-curie.jpg",
"commons": "Marie_Curie_c1920.jpg",
"license": "Public domain"
},
"mileva-maric": {
"file": "mileva-maric.jpg",
"commons": "Mileva_Maric.jpg",
"license": "Public domain"
},
"dora-maar-francoise-gilot": {
"file": "dora-maar-francoise-gilot.jpg",
"commons": "Ménerbes_902.jpg",
"license": "CC BY-SA 3.0"
},
"rosemonde-gerard": {
"file": "rosemonde-gerard.jpg",
"commons": "Rosemonde_Gérard.jpg",
"license": "Public domain"
},
"diotime-aspasie": {
"file": "diotime-aspasie.jpg",
"commons": "Simmler-Deotyma.jpg",
"license": "Public domain"
},
"maria-celeste": {
"file": "maria-celeste.jpg",
"commons": "A_nun,_traditionally_identified_as_Suor_Maria_Celeste,_daugh_Wellcome_L0031890.jpg",
"license": "CC BY 4.0"
},
"alexandra-david-neel": {
"file": "alexandra-david-neel.jpg",
"commons": "Alexandra_David-Neels.jpg",
"license": "CC BY 2.0"
},
"marilyn-monroe": {
"file": "marilyn-monroe.jpg",
"commons": "Monroe_1953_publicity.jpg",
"license": "Public domain"
},
"marguerite-yourcenar": {
"file": "marguerite-yourcenar.jpg",
"commons": "Marguerite_Yourcenar-Bailleul-1982.10.04.Bernhard_De_Grendel_(11).jpg",
"license": "CC BY-SA 4.0"
},
"camille-claudel": {
"file": "camille-claudel.jpg",
"commons": "Camille_nette.jpg",
"license": "CC BY-SA 4.0"
},
"mylene-farmer": {
"file": "mylene-farmer.jpg",
"commons": "Mylène_farmer_Live_2019_(cropped).jpg",
"license": "CC BY-SA 4.0"
},
"marie-antoinette": {
"file": "marie-antoinette.jpg",
"commons": "Marie-Antoinette;_koningin_der_FransenFXD.jpg",
"license": "?"
},
"lady-diana": {
"file": "lady-diana.jpg",
"commons": "Diana,_Princess_of_Wales_1997_(2).jpg",
"license": "?"
},
"jeanne-calment": {
"file": "jeanne-calment.jpg",
"commons": "JeanneCalmentaged40.jpg",
"license": "Public domain"
},
"sagan": {
"file": "sagan.jpg",
"commons": "Françoise_Sagan_1954.jpg",
"license": "?"
},
"agatha-christie": {
"file": "agatha-christie.jpg",
"commons": "Agatha_Christie_in_Nederland_(detectiveschrijfster),_bij_aankomst_op_Schiphol_me,_Bestanddeelnr_916-8898_(cropped).jpg",
"license": "?"
},
"jane-austen": {
"file": "jane-austen.jpg",
"commons": "CassandraAusten-JaneAusten(c.1810)_hires.jpg",
"license": "?"
},
"edith-piaf": {
"file": "edith-piaf.jpg",
"commons": "Piaf_Harcourt_1946_2.jpg",
"license": "?"
},
"coco-chanel": {
"file": "coco-chanel.jpg",
"commons": "Coco_Chanel_in_Los_Angeles,_1931_(cropped).jpg",
"license": "?"
},
"frida-kahlo": {
"file": "frida-kahlo.jpg",
"commons": "Frida_Kahlo,_by_Guillermo_Kahlo.jpg",
"license": "?"
},
"celine-dion": {
"file": "celine-dion.jpg",
"commons": "Céline_Dion_2012.jpg",
"license": "?"
},
"adele": {
"file": "adele.jpg",
"commons": "Adele_in_Munich.jpg",
"license": "?"
},
"lady-gaga": {
"file": "lady-gaga.jpg",
"commons": "Lady_Gaga_at_Joe_Biden's_inauguration_(cropped_5).jpg",
"license": "?"
},
"nadia-comaneci": {
"file": "nadia-comaneci.jpg",
"commons": "Nadia_Comăneci_at_Sports_Festival_2026.jpg",
"license": "?"
},
"simone-biles": {
"file": "simone-biles.jpg",
"commons": "Simone_Biles_National_Team_2024.jpg",
"license": "?"
},
"marie-jose-perec": {
"file": "marie-jose-perec.jpg",
"commons": "Marie-José_Pérec_Cannes_2016.jpg",
"license": "?"
},
"rosa-parks": {
"file": "rosa-parks.jpg",
"commons": "Rosa_Parks,_November_1956_(cropped).jpg",
"license": "?"
},
"malala-yousafzai": {
"file": "malala-yousafzai.jpg",
"commons": "Malala_Yousafzai_at_the_2024_Toronto_International_Film_Festival_5.jpg",
"license": "?"
},
"greta-thunberg": {
"file": "greta-thunberg.jpg",
"commons": "Greta_Thunberg_in_November_in_Stockholm_(cropped)(2).jpg",
"license": "?"
},
"margaret-thatcher": {
"file": "margaret-thatcher.jpg",
"commons": "Margaret_Thatcher_stock_portrait_(cropped).jpg",
"license": "?"
},
"meduse": {
"file": "meduse.jpg",
"commons": "Gorgoneion.JPG",
"license": "Public domain"
},
"cassandre": {
"file": "cassandre.jpg",
"commons": "Attic_red-figure_cup_with_Ajax_and_Cassandra_Louvre_G_458.jpg",
"license": "?"
},
"cendrillon": {
"file": "cendrillon.jpg",
"commons": "Cinderella_by_Gustav_Dore_(136548285).jpg",
"license": "?"
},
"jk-rowling": {
"file": "jk-rowling.jpg",
"commons": "J._K._Rowling_2010.jpg",
"license": "?"
},
"aya-nakamura": {
"file": "aya-nakamura.jpg",
"commons": "Aya_Nakamura.jpg",
"license": "?"
},
"michelle-obama": {
"file": "michelle-obama.jpg",
"commons": "Michelle_Obama_2013_official_portrait.jpg",
"license": "?"
},
"christiane-taubira": {
"file": "christiane-taubira.jpg",
"commons": "1601MBeek7569_(24620898645)_(cropped).jpg",
"license": "?"
},
"elisabeth-borne": {
"file": "elisabeth-borne.jpg",
"commons": "La_Première_ministre_française_Élisabeth_Borne_(cropped).jpg",
"license": "?"
},
"segolene-royal": {
"file": "segolene-royal.jpg",
"commons": "Royal_Toulouse_2012.JPG",
"license": "?"
},
"sandrine-rousseau": {
"file": "sandrine-rousseau.jpg",
"commons": "Sandrine_Rousseau_20210819_(cropped).jpg",
"license": "?"
},
"rokhaya-diallo": {
"file": "rokhaya-diallo.jpg",
"commons": "Europa21_-_2.jpg",
"license": "?"
},
"fadily-camara": {
"file": "fadily-camara.jpg",
"commons": "Fadily_Camara.jpg",
"license": "?"
}
}
\ No newline at end of file
This image diff could not be displayed because it is too large. You can view the blob instead.
...@@ -32,6 +32,47 @@ const FALLBACKS2 = [ ...@@ -32,6 +32,47 @@ const FALLBACKS2 = [
["mylene-farmer", "fr", "Mylène Farmer"], ["mylene-farmer", "fr", "Mylène Farmer"],
]; ];
const FALLBACKS3 = [
// Phase 2 : portraits des célébres (fiche simple, punchline + pourquoi)
["jeanne-d-arc", "fr", "Jeanne d'Arc"],
["marie-antoinette", "fr", "Marie-Antoinette d'Autriche"],
["cleopatre", "fr", "Cléopâtre"],
["lady-diana", "fr", "Diana Spencer"],
["jeanne-calment", "fr", "Jeanne Calment"],
["sagan", "fr", "Françoise Sagan"],
["agatha-christie", "fr", "Agatha Christie"],
["jane-austen", "en", "Jane Austen"],
["edith-piaf", "fr", "Édith Piaf"],
["coco-chanel", "fr", "Coco Chanel"],
["frida-kahlo", "en", "Frida Kahlo"],
["celine-dion", "fr", "Céline Dion"],
["adele", "fr", "Adele (chanteuse)"],
["lady-gaga", "en", "Lady Gaga"],
["taylor-swift", "en", "Taylor Swift"],
["nadia-comaneci", "en", "Nadia Comăneci"],
["simone-biles", "en", "Simone Biles"],
["marie-jose-perec", "fr", "Marie-José Pérec"],
["laure-manaudou", "fr", "Laure Manaudou"],
["serena-williams", "en", "Serena Williams"],
["rosa-parks", "en", "Rosa Parks"],
["malala-yousafzai", "fr", "Malala Yousafzai"],
["greta-thunberg", "fr", "Greta Thunberg"],
["margaret-thatcher", "en", "Margaret Thatcher"],
["meduse", "fr", "Méduse (mythologie)"],
["cassandre", "fr", "Cassandre"],
["penelope", "fr", "Pénélope"],
["cendrillon", "fr", "Cendrillon"],
["jk-rowling", "fr", "J. K. Rowling"],
["aya-nakamura", "fr", "Aya Nakamura"],
["michelle-obama", "en", "Michelle Obama"],
["christiane-taubira", "fr", "Christiane Taubira"],
["elisabeth-borne", "fr", "Élisabeth Borne"],
["segolene-royal", "fr", "Ségolène Royal"],
["sandrine-rousseau", "fr", "Sandrine Rousseau"],
["rokhaya-diallo", "fr", "Rokhaya Diallo"],
["fadily-camara", "fr", "Fadily Camara"],
];
const TARGETS = [ const TARGETS = [
["jocaste-et-antigone", "fr", "Jocaste"], ["jocaste-et-antigone", "fr", "Jocaste"],
["themistoclea-theano", "fr", "Théano"], ["themistoclea-theano", "fr", "Théano"],
...@@ -96,16 +137,14 @@ async function download(url) { ...@@ -96,16 +137,14 @@ async function download(url) {
} }
const report = []; const report = [];
const MAP_OUT = path.join(ROOT, "app", "les-femmes", "images-map.json");
const map = existsSync(MAP_OUT) ? JSON.parse(readFileSync(MAP_OUT, "utf8")) : {};
mkdirSync(OUT_DIR, { recursive: true }); mkdirSync(OUT_DIR, { recursive: true });
const ALL = [...TARGETS, ...FALLBACKS, ...FALLBACKS2]; const ALL = [...TARGETS, ...FALLBACKS, ...FALLBACKS2, ...FALLBACKS3];
for (const [slug, lang, title] of ALL) { for (const [slug, lang, title] of ALL) {
const dest = path.join(OUT_DIR, `${slug}.jpg`); const dest = path.join(OUT_DIR, `${slug}.jpg`);
if (existsSync(dest)) {
report.push({ slug, title, status: "skip (exists)" });
continue;
}
try { try {
// Action API : pageimages=name donne le nom de fichier Commons (pour le crédit). // Action API : pageimages=name donne le nom de fichier Commons (pour le crédit).
const api = `https://${lang}.wikipedia.org/w/api.php?action=query&format=json&prop=pageimages&piprop=name|original&redirects=1&titles=${encodeURIComponent(title)}`; const api = `https://${lang}.wikipedia.org/w/api.php?action=query&format=json&prop=pageimages&piprop=name|original&redirects=1&titles=${encodeURIComponent(title)}`;
...@@ -113,6 +152,12 @@ for (const [slug, lang, title] of ALL) { ...@@ -113,6 +152,12 @@ for (const [slug, lang, title] of ALL) {
if (status !== 200 || !json) throw new Error(`api status ${status}`); if (status !== 200 || !json) throw new Error(`api status ${status}`);
const pages = json.query?.pages ?? {}; const pages = json.query?.pages ?? {};
const page = Object.values(pages)[0]; const page = Object.values(pages)[0];
if (existsSync(dest)) {
// Fichier déjà là : on met juste à jour la map (commons pour le crédit).
if (page?.pageimage) map[slug] = { file: path.basename(dest), commons: page.pageimage };
report.push({ slug, title, status: "skip (exists)" });
continue;
}
if (!page?.pageimage || !page?.original?.source) { if (!page?.pageimage || !page?.original?.source) {
throw new Error("no page image"); throw new Error("no page image");
} }
...@@ -124,6 +169,7 @@ for (const [slug, lang, title] of ALL) { ...@@ -124,6 +169,7 @@ for (const [slug, lang, title] of ALL) {
const ext = mime === "image/png" ? "png" : mime === "image/webp" ? "webp" : "jpg"; const ext = mime === "image/png" ? "png" : mime === "image/webp" ? "webp" : "jpg";
const file = path.join(OUT_DIR, `${slug}.${ext}`); const file = path.join(OUT_DIR, `${slug}.${ext}`);
writeFileSync(file, buf); writeFileSync(file, buf);
map[slug] = { file: path.basename(file), commons: page.pageimage };
report.push({ report.push({
slug, slug,
title, title,
...@@ -137,6 +183,8 @@ for (const [slug, lang, title] of ALL) { ...@@ -137,6 +183,8 @@ for (const [slug, lang, title] of ALL) {
} }
} }
writeFileSync(MAP_OUT, JSON.stringify(map, null, 1));
console.table(report); console.table(report);
const failed = report.filter((r) => r.status.startsWith("FAIL")); const failed = report.filter((r) => r.status.startsWith("FAIL"));
console.log(`${report.length - failed.length}/${report.length} ok, ${failed.length} failed`); console.log(`${report.length - failed.length}/${report.length} ok, ${failed.length} failed`);
......
...@@ -158,4 +158,4 @@ if (todo.length === 0) { ...@@ -158,4 +158,4 @@ if (todo.length === 0) {
const browser = await chromium.launch(); const browser = await chromium.launch();
for (const card of todo) await finalize(browser, card); for (const card of todo) await finalize(browser, card);
await browser.close(); await browser.close();
console.log(`${todo.length} og cards écrites dans public/images/les-femmes/`); console.log(`${todo.length} og cards écrites dans public/images/og/les-femmes/`);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment