Skip to content

Commit

Permalink
feat(profiles): add stats to profiles banners
Browse files Browse the repository at this point in the history
  • Loading branch information
nfroidure committed Aug 25, 2023
1 parent 2999aaf commit 426d631
Show file tree
Hide file tree
Showing 61 changed files with 71 additions and 13 deletions.
19 changes: 17 additions & 2 deletions bin/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { join as pathJoin } from "path";
import { tmpdir } from "node:os";
import childProcess from "node:child_process";
import { promisify } from "node:util";
import type { WritterStats } from "../src/utils/writters";

const exec = promisify(childProcess.exec);

Expand All @@ -22,8 +23,9 @@ async function run() {
for (const file of files) {
const writter = JSON.parse(
await fs.readFile(pathJoin("contents", "writters", file), "utf-8")
);
) as WritterStats;
let portraitData = defaultPortrait;
console.warn(`♻️ - Generating profile banner for ${writter.name}`);

try {
portraitData = `data:image/png;base64,${await fs.readFile(
Expand All @@ -41,8 +43,21 @@ async function run() {
await fs.writeFile(
tempFile,
svgTemplate
.replace(
/\{x\}/gm,
writter.presencesStats
? (
(writter.presencesStats["cm-douai"].present /
writter.presencesStats["cm-douai"].total) *
100
).toFixed(0)
: "-"
)
.replace(/\{name\}/gm, writter.name)
.replace("{image}", portraitData)
.replace(/\{kw1\}/gm, writter.words?.[0]?.word || "-")
.replace(/\{kw2\}/gm, writter.words?.[1]?.word || "-")
.replace(/\{kw3\}/gm, writter.words?.[2]?.word || "-")
.replace(/\{image\}/gm, portraitData)
);
await exec(
`inkscape --without-gui --export-png=${pathJoin(
Expand Down
Binary file modified public/images/banners/agnes-dupuis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/anissa-bouchaboun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/anne-colin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/anne-sophie-audegond.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/annick-louvion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/auriane-ait-lasri.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/avida-oulahcene.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/brigitte-bonnaffe-leriche.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/bruno-bufquin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/carolle-divrechy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/chantal-rybak.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/coline-craeye.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/cyril-carbonnel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/eric-lemaitre.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/francois-guiffard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/francoise-prouvost.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/franz-quatreboeufs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/frederic-chereau.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/gerard-bailliet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/guy-cannie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/guy-caruyer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/guy-lagache.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/hocine-mazy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/isabelle-chatelain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/jackie-avenel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/banners/jacques-vernier.png
Binary file modified public/images/banners/jamila-mekki.png
Binary file modified public/images/banners/jean-christophe-leclercq.png
Binary file modified public/images/banners/jean-marie-dupire.png
Binary file modified public/images/banners/jean-michel-leroy.png
Binary file modified public/images/banners/jean-pierre-divrechy.png
Binary file modified public/images/banners/jessy-kaboul.png
Binary file modified public/images/banners/karine-doyen-carbonnel.png
Binary file modified public/images/banners/katia-bittner.png
Binary file modified public/images/banners/khadija-ahantat.png
Binary file modified public/images/banners/marie-delattre.png
Binary file modified public/images/banners/marie-delecambre.png
Binary file modified public/images/banners/marie-helene-quatreboeufs-niklikowski.png
Binary file modified public/images/banners/maxime-decupper-laud.png
Binary file modified public/images/banners/michael-doziere.png
Binary file modified public/images/banners/mohamed-felouki.png
Binary file modified public/images/banners/mohamed-kheraki.png
Binary file modified public/images/banners/monique-amghar.png
Binary file added public/images/banners/nadia-bony.png
Binary file modified public/images/banners/nathalie-apers.png
Binary file modified public/images/banners/nora-cherki.png
Binary file modified public/images/banners/odile-hage.png
Binary file modified public/images/banners/rene-lavarde.png
Binary file modified public/images/banners/salima-boukentar.png
Binary file modified public/images/banners/sebastien-lanclu.png
Binary file modified public/images/banners/stephanie-stiernon.png
Binary file modified public/images/banners/thibaut-francois.png
Binary file modified public/images/banners/virginie-malolepszy.png
Binary file modified public/images/banners/xavier-thierry.png
Binary file modified public/images/banners/yves-piquot.png
Binary file added public/images/banners/yvette-wattebled.png
Binary file modified public/images/banners/yvon-sipieter.png
61 changes: 52 additions & 9 deletions public/images/profile.svg
2 changes: 1 addition & 1 deletion src/pages/elu-es/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const entriesToBaseListingMetadata = (
? stats.writtings[stats.writtings.length - 1].date
: new Date().toISOString(),
title: `${stats.name}`,
description: `Fiche de l'élu·e ${stats.name}`,
description: `Fiche de l'élu·e ${stats.name} : présence, tribunes et autres statistiques.`,
stats,
...(presences ? { presences } : {}),
...(presencesStats ? { presencesStats } : {}),
Expand Down
2 changes: 1 addition & 1 deletion src/pages/groupes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const entriesToBaseListingMetadata = (
id: stats.id,
date: stats.writtings[stats.writtings.length - 1].date,
title: `${stats.name} (${stats.partyAbbr})`,
description: `Fiche du groupe ${stats.name} - ${stats.party}.`,
description: `Fiche du groupe ${stats.name} - ${stats.party} : présence, tribunes et autres statistiques.`,
stats,
illustration: {
url: `images/groups/${stats.logo}`,
Expand Down

0 comments on commit 426d631

Please sign in to comment.