diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1bfdd3f --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +# Dossiers locaux / outils (jamais commités) +.freebuff/ +gestionnaire/ +FWS-Website/ + +# ── Secrets locaux ───────────────────────────────────────────────────────── +# Webhook Discord / config locale de l'API bugs (jamais commiter) +api/bugs/config.local.php + +# ── Base de données SQLite des signalements ──────────────────────────────── +# La DB vit sur le serveur, jamais dans git (données utilisateurs + privées) +api/bugs/data/*.sqlite +api/bugs/data/*.sqlite-wal +api/bugs/data/*.sqlite-shm +api/bugs/data/*.db +api/bugs/data/*.db-wal +api/bugs/data/*.db-shm +*.sqlite +*.sqlite-wal +*.sqlite-shm + +# Images des paquets envoyées via l'admin (données hébergées, pas du code) +p/assets/img/packages/ + +# Cache HTTP local du site (releases Gitea/GitHub, généré par inc/site.php) +cache/ + +# Journal des erreurs PHP (filet de sécurité inc/errors.php) +api/bugs/data/php-errors.log diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..99305ab --- /dev/null +++ b/.htaccess @@ -0,0 +1,73 @@ +# ── FWS Linux — .htaccess (performance + sécurité) ────────────────────────── + +# Le site est rendu côté serveur : page.php est le point d'entrée unique. +# (Les sous-dossiers avec leur propre index.php — admin/bugs, api — restent +# prioritaires via l'ordre de DirectoryIndex.) +DirectoryIndex index.php page.php + +# Pas de listing de répertoires (ex : /p/, /api/, /admin/) +Options -Indexes + +# ── Erreurs Apache « douces » ──────────────────────────────────────────────── +# 403 (répertoire protégé, listing désactivé…) et 404 : jamais les pages +# Apache brutes. page.php sert la page 404 du site ; le statut HTTP reste +# correct (403/404) pour les navigateurs comme pour les clients d'API. +ErrorDocument 403 /page.php?__e=403 +ErrorDocument 404 /page.php?__e=404 + +# ── Fichiers internes : traités comme introuvables ───────────────────────── +# Tout fichier PHP qui n'est pas un point d'entrée légitime (bibliothèques, +# corps de pages, config, logs…) répond 404 — on ne révèle même pas son +# existence avec un 403. Les accès directs aux corps restent sinon gérés par +# leurs shims de délégation vers page.php. +RedirectMatch 404 ^/?(inc|cache)/ +RedirectMatch 404 ^/?api/bugs/(db|discord|config\.local)\.php$ +RedirectMatch 404 ^/?admin/bugs/init\.php$ +# Corps de pages et scripts internes sous p/ (hors assets). Les index.php +# sont exclus : ils sont résolus en interne par DirectoryIndex (ex /p/dl/). +RedirectMatch 404 ^/?p/(?!assets/)(?!.*index\.php$).*\.php$ + +# Types MIME manquants (selon la config Apache du conteneur) + + AddType image/webp .webp + AddType image/avif .avif + + + + # Sécurité minimale + Header set X-Content-Type-Options "nosniff" + Header set Referrer-Policy "strict-origin-when-cross-origin" + Header set X-Frame-Options "SAMEORIGIN" + + +# ── Compression (gzip) ─────────────────────────────────────────────────────── + + AddOutputFilterByType DEFLATE text/html text/plain text/css application/javascript application/json application/xml text/xml image/svg+xml + # Ne pas compresser ce qui est déjà compressé + SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|webp|avif|zip|gz|7z|xz)$ no-gzip dont-vary + + +# ── Cache navigateur ───────────────────────────────────────────────────────── +# Le HTML est chargé en AJAX par le routeur (/?p/…) : on le revalide toujours, +# mais les fichiers statiques (css/js/img) peuvent être gardés longtemps. + + # Pages html chargées dynamiquement → revalidation (304 rapide si inchangé) + + Header set Cache-Control "no-cache" + + + # CSS / JS : 7 jours + revalidation + + Header set Cache-Control "public, max-age=604800, must-revalidate" + + + # Images : 30 jours (noms de fichiers stables) + + Header set Cache-Control "public, max-age=2592000" + + + # API + PHP : jamais de cache + + Header set Cache-Control "no-store" + + diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..1cc2239 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,59 @@ +# AGENTS.md — Instructions pour les agents IA + +> Fichier de référence pour les agents IA (Codebuff, Cursor, Claude Code, GitHub Copilot…) qui travaillent sur un dépôt de l'organisation **FWS**. Un agent doit lire ce fichier en premier : il contient les instructions à respecter. Le `README.md` présente l'organisation et le `CONTRIBUTING.md` détaille les conventions de collaboration. + +## Contexte + +- **FWS** est une organisation open source multi-projets : chaque projet choisit librement sa stack technique (sans restriction de langage). +- Projet principal : **FWS ISO** — une distribution Linux basée sur Arch Linux, pensée pour simplifier l'installation et l'usage au quotidien. +- Conventions détaillées : `CONTRIBUTING.md` (FR) / `CONTRIBUTING.en.md` (EN). + +## Règles à respecter + +### Commits + +- Messages en **anglais**, format **Conventional Commits** : `(): `. +- Types autorisés : `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`. +- Titre court et impératif ; un corps n'est ajouté que pour expliquer le **pourquoi**, pas le comment. + +### Nommage + +- Branches : `type/description` (ex. `feat/login`, `fix/typo`). +- Fichiers : **kebab-case** (ex. `my-component.ts`). +- Identifiants (variables, fonctions, classes) : **anglais**. + +### Code & commentaires + +- Commentaires en **anglais**, style « pourquoi » : pas de commentaire si le code est explicite ; documenter le non-évident (choix d'implémentation, compromis, cas limites). +- Respecter la stack technique et les conventions existantes du dépôt avant d'ajouter de nouvelles dépendances. + +### Fichiers sensibles (`.gitignore`) + +- Ne **jamais** versionner : fichiers d'environnement (`.env*`), données d'assistants de développement (`.freebuff/`), artefacts compilés (`dist/`, `build/`, `target/`, `__pycache__/`…), dépendances (`node_modules/`), secrets. +- Un `.gitignore` doit exister à la racine de chaque dépôt. + +### Tests + +- Fichiers de test : `*.test.*` ; noms de tests `describe` / `it` en anglais. +- Vérifier que les tests (et le typecheck / lint quand ils existent) passent avant de considérer une tâche terminée. + +### Issues & signalement de bugs + +- Les bugs et demandes sont suivis via les **issues** et, lorsqu'il existe, le tableau Kanban du projet. +- Une pull request qui corrige un bug référence l'issue dans son titre ou sa description (`Fixes #123`). +- Ne pas fermer ni modifier une issue sans demande explicite de l'utilisateur. + +### Commits demandés par l'utilisateur + +- Lorsque l'utilisateur demande explicitement de créer un commit, l'IA doit le faire après avoir vérifié les changements et les contrôles disponibles, sans attendre une confirmation supplémentaire. +- Le titre et le corps du commit ne doivent jamais mentionner l'IA, l'assistant, Codebuff ou l'outil utilisé. +- Ne pas ajouter l'IA comme auteur ou co-auteur dans le message du commit. + +## Bonnes pratiques pour un agent + +- Lire `AGENTS.md`, le `README.md` et le `CONTRIBUTING.md` avant d'éditer du code. +- Les commits doivent être signés. +- Faire les changements les plus petits possibles qui répondent à la demande. +- Ne pas pousser, fusionner ni publier sans demande explicite de l'utilisateur. +- Suivre les cartes du tableau Kanban lorsqu'il existe pour organiser le travail. +- En cas de doute, demander plutôt que de deviner. diff --git a/Doc/fonctionnement-onepage.md b/Doc/fonctionnement-onepage.md index cd1748e..c706842 100644 --- a/Doc/fonctionnement-onepage.md +++ b/Doc/fonctionnement-onepage.md @@ -1,154 +1,57 @@ -# Fonctionnement du JavaScript +# Fonctionnement du site (PHP) -Ce projet fonctionne comme un site statique avec un seul point d'entrée HTML. Le JavaScript sert à lire l'URL, charger le bon fichier dans `p/`, injecter son contenu dans le `main`, et reprendre aussi les styles définis dans le `` de la page chargée. +Le site est **entièrement rendu côté serveur (PHP)**. Il n'y a plus de routeur +JavaScript : chaque URL sert une page HTML complète. Les seuls scripts restants +sont des améliorations progressives (carrousel, menu déroulant, « Voir plus »). -## Principe général +## Architecture -1. `index.html` garde le header, le footer et le conteneur principal. -2. Chaque page vit dans un dossier sous `p/`. -3. Le script lit la route demandée dans l'URL. -4. Le script charge `p//index.html` avec `fetch`. -5. Le contenu de la page est injecté dans le `main`. -6. Les styles déclarés dans le `head` de cette page sont copiés dans le `head` du document courant. +1. **`page.php`** (racine) est le point d'entrée unique. Il lit la route dans + l'URL (`?p/dl/`, `?p=dl`, `?p/paquets/1/`…), inclut le corps de page + correspondant, puis assemble la coquille (header/nav/footer). +2. **`inc/site.php`** contient les helpers : connexion SQLite partagée, + paquets (base + fusion des releases Gitea), fetch HTTP avec cache fichier + (`cache/`, gitignoré), rendu Markdown (portage PHP de l'ancien + `downloads.js`), dates en français, troncature HTML. +3. **`p//index.php`** (et `p/paquets/detail.php` pour `/?p/paquets/N/`) + contiennent le corps de chaque page. Ils définissent `$title`, + `$description`, `$extraCss[]` et `$extraJs[]` avant l'affichage. +4. `index.php` à la racine délègue à `page.php` (DirectoryIndex Apache). + +## Données + +- **Paquets** : table SQLite `packages` (base `api/bugs/data/fws_bugs.sqlite`, + partagée avec le panneau d'admin). Éditables dans `/admin/bugs` (onglet + 📦 Paquets) + bouton 🔄 Gitea qui synchronise `latest` et l'historique depuis + l'API Gitea du dépôt lié. Repli automatique sur `p/paquets/packages.json` + si la base est vide. API publique conservée : `/api/packages.php`. +- **Téléchargements** : releases ISO rendues serveur — Gitea `FWS/ISO` s'il + existe, sinon GitHub (cache 10 min dans `cache/`). +- **Équipe** : rendu serveur depuis `p/equipe/creators.json`. ## Fichiers impliqués -- [index.html](../index.html) contient le chrome global du site. -- [p/assets/main-nav/app.js](../p/assets/main-nav/app.js) contient le routeur JavaScript. -- [p/index/index.html](../p/index/index.html) contient la page principale. -- [p/dl/index.html](../p/dl/index.html) contient la page DL. +- [page.php](../page.php) — front controller + coquille HTML. +- [inc/site.php](../inc/site.php) — helpers (DB, Gitea/GitHub, Markdown…). +- [index.php](../index.php) — shim vers `page.php`. +- `p/index|dl|paquets|equipe|contact/index.php`, `p/paquets/detail.php`, + `p/404.php` — corps de pages. +- [p/assets/main-nav/nav.js](../p/assets/main-nav/nav.js) — ouverture du menu + déroulant Paquets. +- [p/assets/js/note-toggle.js](../p/assets/js/note-toggle.js) — « Voir plus / + Voir moins » de la note de release. +- [p/assets/js/hero-carousel.js](../p/assets/js/hero-carousel.js) — carrousel + de l'accueil. -## Comment le script lit l'URL +## Supprimés (devenus inutiles avec le rendu serveur) -La fonction `routeFromLocation()` lit la route courante depuis plusieurs formes possibles d'URL. +- `index.html` (racine), tous les `p/**/index.html` +- `p/assets/main-nav/app.js` (routeur SPA) +- `p/assets/js/packages.js`, `downloads.js`, `creators-loader.js` -Exemples reconnus: +## Panneau admin & API (inchangés dans leur principe) -- `/?p/index/` -- `/?p/dl/` -- `/?p=contact` -- `/p/about/` - -La fonction `normalizeRoute(value)` nettoie ensuite la valeur pour obtenir une route simple comme `index`, `dl` ou `contact`. - -## Chargement du contenu - -La fonction `loadRoute(route)` fait le chargement réel. - -### Route principale - -Pour la route `index`, le script charge: - -```text -p/index/index.html -``` - -### Autres routes - -Pour une route comme `dl`, le script charge: - -```text -p/dl/index.html -``` - -Le fichier chargé doit contenir un bloc avec `data-page-content`: - -```html -
- ... -
-``` - -Le script n'injecte pas tout le document dans la page courante. Il prend seulement le contenu à l'intérieur de cet élément. - -## Injection des styles du head - -Le routeur copie maintenant aussi les balises suivantes depuis le `head` de la page chargée: - -- `link rel="stylesheet"` -- `style` - -Ces balises sont clonées dans le `head` du document principal avec un attribut de suivi `data-page-style`. - -Avant d'ajouter les nouveaux styles, le script supprime les styles injectés par la route précédente pour éviter les doublons et les conflits. - -Exemple dans une page custom: - -```html - - - - -``` - -Si cette page est chargée, le CSS est repris automatiquement. - -## Mise à jour de l'URL - -Après le chargement, le script met à jour l'URL avec l'API History. - -Exemples: - -- `index` devient `/?p/index/` -- `dl` devient `/?p/dl/` - -Le navigateur garde donc une URL partageable, sans recharger complètement la page. - -## Navigation au clic - -Le script écoute les clics sur les liens qui possèdent `data-route`. - -Quand tu cliques sur un lien: - -1. il bloque la navigation normale avec `event.preventDefault()`; -2. il lit `data-route`; -3. il appelle `render(route)`; -4. il charge la page correspondante dans le `main`; -5. il applique aussi ses styles de page. - -## Retour arrière du navigateur - -Le script écoute l'événement `popstate`. - -Cela permet de revenir en arrière ou d'avancer dans l'historique tout en rechargeant la bonne route et les bons styles. - -## Ajouter une nouvelle page - -Pour ajouter une page, crée un nouveau dossier sous `p/`. - -Exemple pour une page contact: - -```text -p/contact/index.html -``` - -Puis ajoute éventuellement un fichier CSS dans cette page via son `head`. - -Enfin, ajoute un lien dans `index.html`: - -```html -Contact -``` - -Le JavaScript n'a pas besoin d'être modifié tant que la structure reste la même. - -## Ce que ce système n'utilise pas - -Ce projet n'utilise pas: - -- Node.js, -- un bundler, -- un framework front, -- des fichiers `.html` séparés dans la racine pour chaque page. - -Tout repose sur un site statique et un routeur JavaScript léger. - -## Point important - -Le chargement via `fetch` fonctionne mieux quand le site est servi par un serveur statique, comme Five Server. - -Si tu ouvres le fichier en `file://`, le navigateur peut bloquer l'accès aux fichiers internes pour des raisons de sécurité. \ No newline at end of file +- `admin/bugs/index.php` — signalements, invitations/comptes, paquets. +- `admin/bugs/build.php` — onglet « Build ISO » (réservé au compte admin). +- `api/bugs.php` — réception des signalements (`curl` ou navigateur). +- `api/packages.php` — paquets au format JSON (consommé par des tiers). diff --git a/README.md b/README.md index 523a52b..3534320 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,75 @@ -Site statique one-page. +Site du projet FWS Linux, rendu côté serveur en PHP. -Le projet ne dépend pas de Node.js, ni d'un build, ni d'un bundler. +Aucune dépendance Node.js, aucun build, aucun bundler : `page.php` est le point +d'entrée unique et assemble chaque page (header, nav, contenu, footer). -Utilisation: +## Lancer le site en local -1. Ouvrir `index.html` dans un navigateur, ou -2. Le servir avec n'importe quel serveur statique local, comme Five Server. +Prérequis : **PHP 8** (avec les extensions `pdo_sqlite` et `sqlite3` pour les +paquets ; le site reste fonctionnel sans elles, avec un repli sur +`p/paquets/packages.json`). -Navigation: +```bash +bash tools/serve.sh # http://127.0.0.1:8080 +HOST=0.0.0.0 PORT=8080 bash tools/serve.sh # accessible depuis le réseau +``` -- `/?p/index/` charge `p/index/index.html` dans le `main` -- `/?p/dl/` charge `p/dl/index.html` dans le `main` -- Chaque sous-dossier de `p/` peut devenir une route, par exemple `p/contact/index.html` pour `/?p/contact/` -- Les balises `link rel="stylesheet"` et `style` placées dans le `head` d'une page sont injectées automatiquement -- Le header et le footer restent communs à toutes les vues +Sous Windows (cmd / PowerShell) : + +```bat +tools\serve.cmd +``` + +Ou directement, sans script : + +```bash +php -S 127.0.0.1:8080 tools/router.php +``` + +`tools/router.php` reproduit le comportement du `.htaccess` de production +(URLs propres, page 404 du site, assets, API, admin) : ce que vous voyez en +local est identique au serveur. Un simple `php -S 127.0.0.1:8080` fonctionne +aussi pour les routes `?p/…`, mais sans la page 404 personnalisée. + +> **Apache (WAMP/XAMPP, production) :** déployer le contenu du dépôt dans la +> racine web et activer `AllowOverride All` pour que `.htaccess` s'applique. +> Le site fonctionne aussi dans un sous-dossier (`/FWS-Website/`) : les URLs +> sont calculées à partir de la requête. + +## Navigation + +- `/?p/index/` — accueil +- `/?p/dl/` — téléchargements +- `/?p/paquets/`, `/?p/paquets/1/…` — paquets +- `/?p/equipe/`, `/?p/contact/` — équipe, contact +- `/?p/mentions-legales/`, `/?p/conditions/`, `/?p/confidentialite/` — légal +- Toute autre route (ou erreur Apache 403/404) affiche la **page 404 animée**, + avec Tux qui débranche un câble RJ45 d'un switch. + +Les deux formes d'URL marchent : `?p=route` et `?p/route/`. + +## Structure du projet + +``` +. +├── .htaccess # Config Apache (routing, cache, sécurité) +├── index.php # Point d'entrée alternatif → page.php +├── page.php # Front controller : coquille + résolution des routes +├── inc/ # Bibliothèque du site (données, erreurs, markdown) +├── p/ # Pages du site +│ ├── 404.php # Page 404 (scène Tux + switch) +│ ├── index/ dl/ … # Corps de chaque page (rendu serveur) +│ └── assets/ # CSS, JS, images (img/, styles/, main-nav/, js/) +├── api/bugs/ # API des signalements (SQLite) +├── admin/bugs/ # Panneau d'administration +├── cache/ # Cache HTTP local (généré, gitignoré) +├── tools/ # Outils de développement (serveur local, routeur) +└── Doc/ # Documentation du projet (Markdown) +``` + +## Documentation + +La documentation du projet est écrite en Markdown dans le dossier `Doc/` : + +- [`Doc/fonctionnement-onepage.md`](Doc/fonctionnement-onepage.md) — historique + du routeur côté client (le rendu est désormais côté serveur). diff --git a/admin/bugs/build.php b/admin/bugs/build.php new file mode 100644 index 0000000..a91d020 --- /dev/null +++ b/admin/bugs/build.php @@ -0,0 +1,558 @@ + true, + 'samesite' => 'Lax', + 'secure' => (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') === 'https'), +]); +session_start(); + +function h_build(string $s): string +{ + return htmlspecialchars($s, ENT_QUOTES, 'UTF-8'); +} + +function current_user_build(): ?array +{ + return isset($_SESSION['admin_user_id']) ? [ + 'id' => (int) $_SESSION['admin_user_id'], + 'name' => (string) $_SESSION['admin_username'], + ] : null; +} + +function csrf_token_build(): string +{ + if (empty($_SESSION['csrf'])) { + $_SESSION['csrf'] = bin2hex(random_bytes(32)); + } + return $_SESSION['csrf']; +} + +function csrf_ok_build(): bool +{ + return hash_equals($_SESSION['csrf'] ?? '', $_POST['csrf'] ?? ''); +} + +/** Lecture du token Gitea stocké localement (api/bugs/data/build/git-auth.env, jamais commité). */ +function build_gitea_auth_build(): array +{ + global $DATA; + $f = $DATA . '/git-auth.env'; + $out = ['username' => '', 'token' => '']; + if (is_file($f)) { + $s = (string) file_get_contents($f); + if (preg_match("/^FWS_GIT_USER='([^']*)'$/m", $s, $m) === 1) { + $out['username'] = $m[1]; + } + if (preg_match("/^FWS_GIT_TOKEN='([^']*)'$/m", $s, $m) === 1) { + $out['token'] = $m[1]; + } + } + return $out; +} + +/** Écriture du token Gitea (token vide → fichier retiré). */ +function build_save_gitea_auth_build(string $username, string $token): void +{ + global $DATA; + if (!is_dir($DATA)) { + @mkdir($DATA, 0775, true); + } + $f = $DATA . '/git-auth.env'; + if ($token === '') { + @unlink($f); + return; + } + $sq = static fn(string $v): string => str_replace(["\\", "'"], ["\\\\", "\\'"], $v); + file_put_contents( + $f, + "FWS_GIT_USER='" . $sq($username !== '' ? $username : 'fws') . "'\n" . + "FWS_GIT_TOKEN='" . $sq($token) . "'\n", + LOCK_EX + ); + @chmod($f, 0600); +} + +/* ── Chemins (sous api/bugs/data/, jamais commité) ── */ + +$DATA = __DIR__ . '/../../api/bugs/data/build'; +$LOG = $DATA . '/build.log'; +$PIDF = $DATA . '/build.pid'; +$RUN = __DIR__ . '/run-build.sh'; + +$user = current_user_build(); + +/** PID du process de build s'il tourne encore, sinon false. */ +function build_running_build(): int|false +{ + global $PIDF; + $pid = is_file($PIDF) ? trim((string) file_get_contents($PIDF)) : ''; + if ($pid === '' || !ctype_digit($pid)) { + return false; + } + exec('kill -0 ' . (int) $pid . ' 2>/dev/null', $out, $rc); + return $rc === 0 ? (int) $pid : false; +} + +/** Dernier code de sortie du pipeline lu dans le log (null si pas encore terminé). */ +function build_last_rc_build(): ?int +{ + global $LOG; + if (!is_file($LOG) || filesize($LOG) === 0) { + return null; + } + $tail = (string) file_get_contents($LOG, false, null, max(0, filesize($LOG) - 4096)); + if (preg_match('/Fin du pipeline \(code (-?\d+)\)/', $tail, $m) === 1) { + return (int) $m[1]; + } + return null; +} + +/* ───────────────────────── API (act=…) ───────────────────────── */ + +$act = $_GET['act'] ?? $_POST['act'] ?? ''; +$isApi = $act !== ''; + +if ($isApi) { + header('Content-Type: application/json; charset=utf-8'); + header('Cache-Control: no-store'); + + if ($user === null) { + http_response_code(401); + exit(json_encode(['ok' => false, 'error' => 'Non connecté.'])); + } + if (!fws_bugs_can_build($user['name'])) { + http_response_code(403); + exit(json_encode(['ok' => false, 'error' => 'Ce compte n’est pas autorisé à lancer des builds.'])); + } + + $running = build_running_build(); + + if ($act === 'state') { + echo json_encode(['ok' => true, 'running' => $running !== false, 'pid' => $running]); + exit; + } + + if ($act === 'auth_status') { + $a = build_gitea_auth_build(); + echo json_encode(['ok' => true, 'configured' => $a['token'] !== '', 'username' => $a['username']]); + exit; + } + + if ($act === 'tail') { + $pos = max(-1, (int) ($_GET['pos'] ?? 0)); + $size = is_file($LOG) ? (int) filesize($LOG) : 0; + $start = 0; + if ($pos === -1) { + // Premier chargement : ne ramener que la fin d'un éventuel vieux log. + $start = max(0, $size - 150000); + } elseif ($pos > 0 && $pos <= $size) { + $start = $pos; + } + $text = ''; + if ($size > $start) { + $fh = fopen($LOG, 'rb'); + if ($fh !== false) { + if ($start > 0) { + fseek($fh, $start); + } + $raw = (string) stream_get_contents($fh); + fclose($fh); + // Nettoyage : codes ANSI retirés, octets invalides ignorés. + $text = (string) preg_replace('/\x1B\[[0-9;?]*[ -\/]*[@-~]/', '', $raw); + $text = (string) preg_replace('/\x1B\][^\x07\x1B]*(\x07|\x1B\\)/', '', $text); + $text = iconv('UTF-8', 'UTF-8//IGNORE', $text); + } + } + $running = build_running_build(); + echo json_encode([ + 'ok' => true, + 'running' => $running !== false, + 'pos' => (int) $size, + 'rc' => build_last_rc_build(), + 'text' => $text, + ]); + exit; + } + + if (($_SERVER['REQUEST_METHOD'] ?? '') !== 'POST' || !csrf_ok_build()) { + http_response_code(403); + exit(json_encode(['ok' => false, 'error' => 'Jeton de sécurité invalide.'])); + } + + if ($act === 'start') { + if ($running !== false) { + http_response_code(409); + exit(json_encode(['ok' => false, 'error' => 'Un build est déjà en cours.'])); + } + exec('timeout 8 docker info >/dev/null 2>&1', $out, $drc); + if ($drc !== 0) { + http_response_code(503); + exit(json_encode(['ok' => false, 'error' => 'Moteur Docker injoignable (Docker Desktop arrêté ?).'])); + } + if (!is_dir($DATA) && !@mkdir($DATA, 0775, true)) { + http_response_code(500); + exit(json_encode(['ok' => false, 'error' => 'Impossible de créer ' . $DATA])); + } + @unlink($LOG); + @unlink($PIDF); + $cmd = 'nohup bash ' . escapeshellarg($RUN) . ' > ' . escapeshellarg($LOG) . ' 2>&1 & echo $!'; + exec($cmd, $out2, $src); + $pid = (int) ($out2[0] ?? 0); + if ($pid > 0) { + file_put_contents($PIDF, (string) $pid); + } + echo json_encode(['ok' => $src === 0 && $pid > 0, 'pid' => $pid]); + exit; + } + + if ($act === 'stop') { + exec('docker rm -f fws-iso-build >/dev/null 2>&1', $o1, $rc1); + $stopped = $running; + if ($running !== false) { + exec('kill ' . $running . ' 2>/dev/null'); + @unlink($PIDF); + } + echo json_encode(['ok' => true, 'stopped' => $stopped !== false || $rc1 === 0]); + exit; + } + + if ($act === 'clear') { + if ($running !== false) { + http_response_code(409); + exit(json_encode(['ok' => false, 'error' => 'Arrêtez d’abord le build en cours.'])); + } + @unlink($LOG); + @unlink($PIDF); + echo json_encode(['ok' => true]); + exit; + } + + if ($act === 'save_auth') { + build_save_gitea_auth_build( + trim((string) ($_POST['username'] ?? '')), + trim((string) ($_POST['token'] ?? '')) + ); + $a = build_gitea_auth_build(); + echo json_encode(['ok' => true, 'configured' => $a['token'] !== '', 'username' => $a['username']]); + exit; + } + + http_response_code(400); + exit(json_encode(['ok' => false, 'error' => 'Action inconnue.'])); +} + +/* ───────────────────────── PAGES ───────────────────────── */ + +if ($user === null) { + header('Location: index.php'); + exit; +} +$allowed = fws_bugs_can_build($user['name']); + +header('Content-Type: text/html; charset=utf-8'); +?> + + + + + +Build ISO — FWS Linux + + + +
+ +
+
+

🔨 Build ISO

+
Connecté : · dépôt : D:\FWS-ISO (branche main)
+
+
+ + + +
+
+ + + + +
+

Accès restreint

+

Votre compte () n'est pas autorisé à lancer des builds. + Seul le compte admin le peut (voir fws_bugs_can_build() dans api/bugs/db.php).

+ ← Retour aux signalements +
+ + + +
+

🔑 Accès Gitea (pour le git pull)

+

+ Le dépôt D:\FWS-ISO est privé et le build tourne dans un conteneur sans tes identifiants + Windows : crée un token dans Gitea (Settings → Applications → Generate New Token, lecture du dépôt) + puis enregistre-le ici. Il n'est stocké que sur ce serveur — jamais commité, jamais affiché dans les logs. +

+ … +
+
+ + +
+
+ + +
+ + +
+
+ +
+

🖥️ Terminal du build

+
+ État : inconnu… + · Git Bash lancerait ici : git checkout main && git pull && bash build.sh +
+ +
Chargement du terminal…
+ +
+ + + + +
+ +

+ Le build se déroule dans un conteneur archlinux jetable (via Docker Desktop, comme + build.sh à la main) : passage sur main → git pull → bash build.sh ; + en cas d'échec de build, bash setup-aur.sh est lancé puis build.sh est relancé. + Si le checkout de main est bloqué par des modifications locales non commitées dans + D:\FWS-ISO, le build s'arrête proprement sans rien toucher. L'ISO sort dans + D:\FWS-ISO\out\. Peut prendre 30 min et plus — laissez l'onglet ouvert, les logs défilent en direct. +

+
+ + + +
+ + + diff --git a/admin/bugs/index.php b/admin/bugs/index.php new file mode 100644 index 0000000..99df77e --- /dev/null +++ b/admin/bugs/index.php @@ -0,0 +1,1313 @@ + true, + 'samesite' => 'Lax', + 'secure' => (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') === 'https'), +]); +session_start(); + +$STATUSES = [ + 'nouveau' => '🆕 Nouveau', + 'en_cours' => '🔧 En cours', + 'resolu' => '✅ Résolu', + 'ignore' => '🙈 Ignoré', +]; +$STATUS_COLORS = [ + 'nouveau' => '#38bdf8', + 'en_cours' => '#fbbf24', + 'resolu' => '#4ade80', + 'ignore' => '#94a3b8', +]; + +/* ───────────────────────── helpers ───────────────────────── */ + +function h(?string $s): string +{ + return htmlspecialchars((string) $s, ENT_QUOTES, 'UTF-8'); +} + +function current_user(): ?array +{ + return isset($_SESSION['admin_user_id']) ? [ + 'id' => (int) $_SESSION['admin_user_id'], + 'name' => (string) $_SESSION['admin_username'], + ] : null; +} + +function csrf_token(): string +{ + if (empty($_SESSION['csrf'])) { + $_SESSION['csrf'] = bin2hex(random_bytes(32)); + } + return $_SESSION['csrf']; +} + +function csrf_ok(): bool +{ + return hash_equals($_SESSION['csrf'] ?? '', $_POST['csrf'] ?? ''); +} + +function format_date(string $utc): string +{ + try { + $d = new DateTime($utc, new DateTimeZone('UTC')); + $d->setTimezone(new DateTimeZone('Europe/Paris')); + return $d->format('d/m/Y H:i'); + } catch (Throwable $e) { + return $utc; + } +} + +function excerpt(string $s, int $len = 140): string +{ + $s = trim(preg_replace('/\s+/', ' ', $s) ?? ''); + if (mb_strlen($s) <= $len) { + return $s; + } + return mb_substr($s, 0, $len - 1) . '…'; +} + +/* ── Paquets : parsing / formatage des champs « une ligne par entrée » ── */ + +function parse_pipe_lines(string $raw, int $fields): array +{ + $out = []; + foreach (preg_split('/\r?\n/', $raw) as $line) { + $line = trim($line); + if ($line === '') { + continue; + } + $parts = array_map('trim', explode('|', $line)); + $parts = array_pad($parts, $fields, ''); + $out[] = array_slice($parts, 0, $fields); + } + return $out; +} + +function links_from_lines(string $raw): array +{ + $out = []; + foreach (parse_pipe_lines($raw, 2) as $pair) { + [$label, $url] = $pair; + if ($url === '') { + $url = $label; + $label = ''; + } + if ($url === '') { + continue; + } + $out[] = ['label' => $label !== '' ? $label : $url, 'url' => $url]; + } + return $out; +} + +function changelog_from_lines(string $raw): array +{ + $out = []; + foreach (parse_pipe_lines($raw, 3) as $parts) { + [$version, $date, $notes] = $parts; + if ($version === '' && $date === '' && $notes === '') { + continue; + } + $out[] = ['version' => $version, 'date' => $date !== '' ? $date : null, 'notes' => $notes]; + } + return $out; +} + +function screens_from_lines(string $raw): array +{ + $out = []; + foreach (parse_pipe_lines($raw, 3) as $parts) { + [$src, $alt, $caption] = $parts; + if ($src === '') { + continue; + } + $out[] = ['src' => $src, 'alt' => $alt !== '' ? $alt : null, 'caption' => $caption !== '' ? $caption : null]; + } + return $out; +} + +/* ── Paquets : images (max 5, stockées sous p/assets/img/packages/) ── */ + +define('FWS_PKG_IMG_MAX', 5); + +function fws_admin_packages_img_dir(): string +{ + /* __DIR__ = admin/bugs → racine du site = deux niveaux au-dessus. */ + return dirname(__DIR__, 2) . '/p/assets/img/packages'; +} + +/** Src web « /p/assets/img/packages/… » si l'image est dans le dossier géré, sinon null. */ +function fws_admin_managed_img_web(string $src): ?string +{ + $prefix = '/p/assets/img/packages/'; + if (strncmp($src, $prefix, strlen($prefix)) !== 0) { + return null; + } + $name = basename($src); + if ($name === '' || str_contains($name, '..')) { + return null; + } + return $prefix . $name; +} + +/** Supprime une image gérée si plus aucun paquet ne la référence. */ +function fws_admin_delete_img_if_unused(PDO $pdo, string $src): void +{ + $web = fws_admin_managed_img_web($src); + if ($web === null) { + return; /* image hors du dossier géré (chemin manuel) : on n'y touche pas */ + } + $st = $pdo->prepare('SELECT COUNT(*) FROM packages WHERE screens LIKE :pat'); + $st->execute([':pat' => '%' . $web . '%']); + if ((int) $st->fetchColumn() > 0) { + return; /* encore utilisée par un autre paquet */ + } + $abs = dirname(__DIR__, 2) . $web; + if (is_file($abs)) { + @unlink($abs); + } +} + +/** Valide et stocke un upload d'image de paquet. Renvoie le src web. + * Lance RuntimeException avec un message clair si le fichier est refusé. */ +function fws_admin_store_screen_upload(array $file, string $slug): string +{ + if (($file['error'] ?? UPLOAD_ERR_NO_FILE) !== UPLOAD_ERR_OK) { + throw new RuntimeException('Envoi impossible (code ' . (string) ($file['error'] ?? '?') . ').'); + } + if (($file['size'] ?? 0) <= 0 || ($file['size'] ?? 0) > 2 * 1024 * 1024) { + throw new RuntimeException('« ' . (string) ($file['name'] ?? '?') . ' » dépasse 2 Mo.'); + } + $ext = strtolower(pathinfo((string) ($file['name'] ?? ''), PATHINFO_EXTENSION)); + $allowed = ['jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'png' => 'image/png', 'webp' => 'image/webp', 'gif' => 'image/gif']; + if (!isset($allowed[$ext])) { + throw new RuntimeException('« ' . (string) ($file['name'] ?? '?') . ' » : format non supporté (jpg, png, webp, gif).'); + } + $info = @getimagesize((string) ($file['tmp_name'] ?? '')); + if ($info === false || ($info['mime'] ?? '') !== $allowed[$ext]) { + throw new RuntimeException('« ' . (string) ($file['name'] ?? '?') . ' » n\'est pas une image valide.'); + } + $dir = fws_admin_packages_img_dir(); + if (!is_dir($dir) && !@mkdir($dir, 0775, true) && !is_dir($dir)) { + throw new RuntimeException('Impossible de créer le dossier des images.'); + } + @chmod($dir, 0777); /* bind-mount Docker : tout appartient à root */ + $base = trim(preg_replace('/[^a-zA-Z0-9-]+/', '-', $slug) ?? '', '-'); + if ($base === '') { + $base = 'paquet'; + } + $name = $base . '-' . bin2hex(random_bytes(8)) . '.' . $ext; + if (!@move_uploaded_file((string) ($file['tmp_name'] ?? ''), $dir . '/' . $name)) { + throw new RuntimeException('Échec de l\'enregistrement de « ' . (string) ($file['name'] ?? '?') . ' ».'); + } + @chmod($dir . '/' . $name, 0644); + return '/p/assets/img/packages/' . $name; +} + +function lines_from_links(array $links): string +{ + $lines = []; + foreach ($links as $l) { + $lines[] = ($l['label'] ?? '') . ' | ' . ($l['url'] ?? ''); + } + return implode("\n", $lines); +} + +function lines_from_changelog(array $cl): string +{ + $lines = []; + foreach ($cl as $e) { + $lines[] = ($e['version'] ?? '') . ' | ' . ($e['date'] ?? '') . ' | ' . ($e['notes'] ?? ''); + } + return implode("\n", $lines); +} + +function lines_from_screens(array $s): string +{ + $lines = []; + foreach ($s as $e) { + $lines[] = ($e['src'] ?? '') . ' | ' . ($e['alt'] ?? '') . ' | ' . ($e['caption'] ?? ''); + } + return implode("\n", $lines); +} + +/* ───────────────────────── actions POST ───────────────────────── */ + +$error = null; +$notice = null; +$freshInvite = ''; +/* Message ponctuel d'une action précédente (stocké en session pour la redirection) */ +$flash = $_SESSION['flash'] ?? null; +unset($_SESSION['flash']); + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $action = $_POST['action'] ?? ''; + + if ($action === 'login') { + $username = trim((string) ($_POST['username'] ?? '')); + $password = (string) ($_POST['password'] ?? ''); + try { + $pdo = fws_bugs_db(); + $st = $pdo->prepare('SELECT * FROM admin_users WHERE username = :u'); + $st->execute([':u' => $username]); + $user = $st->fetch(); + if ($user !== false && password_verify($password, $user['password_hash'])) { + session_regenerate_id(true); + $_SESSION['admin_user_id'] = (int) $user['id']; + $_SESSION['admin_username'] = (string) $user['username']; + $_SESSION['csrf'] = bin2hex(random_bytes(32)); + header('Location: index.php'); + exit; + } + $error = 'Identifiants incorrects.'; + } catch (Throwable $e) { + $error = 'Erreur base de données : ' . $e->getMessage(); + } + } elseif (current_user() !== null) { + if (!csrf_ok()) { + $error = 'Jeton de sécurité invalide, rechargez la page.'; + } elseif ($action === 'logout') { + $_SESSION = []; + session_destroy(); + header('Location: index.php'); + exit; + } elseif ($action === 'set_status') { + $id = (int) ($_POST['id'] ?? 0); + $status = (string) ($_POST['status'] ?? ''); + if (!isset($STATUSES[$status])) { + $error = 'Statut inconnu.'; + } else { + $pdo = fws_bugs_db(); + $st = $pdo->prepare('SELECT status, discord_thread_id FROM bug_reports WHERE id = :id'); + $st->execute([':id' => $id]); + $row = $st->fetch(); + $st = $pdo->prepare('UPDATE bug_reports SET status = :s WHERE id = :id'); + $st->execute([':s' => $status, ':id' => $id]); + $notice = "Signalement #$id marqué « " . $STATUSES[$status] . " »."; + + /* Prévenir Discord (best-effort) */ + if ($row !== false && !empty($row['discord_thread_id'])) { + try { + $actor = current_user()['name'] ?? ''; + fws_bugs_discord_status_change([ + 'thread_id' => (string) $row['discord_thread_id'], + 'old_status' => (string) ($row['status'] ?? ''), + 'new_status' => $status, + 'actor' => (string) $actor, + ]); + } catch (Throwable $e) { + error_log('[fws-bugs] discord statut : ' . $e->getMessage()); + } + } + header('Location: index.php?id=' . $id); + exit; + } + } elseif ($action === 'delete') { + $id = (int) ($_POST['id'] ?? 0); + $pdo = fws_bugs_db(); + $st = $pdo->prepare('DELETE FROM bug_reports WHERE id = :id'); + $st->execute([':id' => $id]); + $notice = "Signalement #$id supprimé."; + header('Location: index.php'); + exit; + } elseif ($action === 'gen_invite') { + $days = (int) ($_POST['days'] ?? 7); + if (!in_array($days, [0, 1, 7, 30, 90], true)) { + $days = 7; + } + $pdo = fws_bugs_db(); + try { + $freshInvite = fws_bugs_create_invite($pdo, (string) (current_user()['name'] ?? ''), $days); + $notice = 'Code d\'invitation généré.'; + } catch (Throwable $e) { + $error = 'Erreur : ' . $e->getMessage(); + } + } elseif ($action === 'revoke_invite') { + $inviteId = (int) ($_POST['invite_id'] ?? 0); + $pdo = fws_bugs_db(); + $st = $pdo->prepare("UPDATE invite_codes SET revoked_at = datetime('now') WHERE id = :id AND used_by IS NULL AND revoked_at IS NULL"); + $st->execute([':id' => $inviteId]); + $notice = $st->rowCount() > 0 + ? 'Code d\'invitation révoqué : il ne fonctionnera plus.' + : 'Impossible de révoquer ce code (déjà utilisé ou déjà révoqué).'; + } elseif ($action === 'change_password') { + $cur = (string) ($_POST['current_password'] ?? ''); + $new = (string) ($_POST['new_password'] ?? ''); + $confirm = (string) ($_POST['confirm_password'] ?? ''); + $uid = (int) current_user()['id']; + $pdo = fws_bugs_db(); + $st = $pdo->prepare('SELECT password_hash FROM admin_users WHERE id = :id'); + $st->execute([':id' => $uid]); + $row = $st->fetch(); + if ($row === false || !password_verify($cur, $row['password_hash'])) { + $error = 'Mot de passe actuel incorrect.'; + } elseif (strlen($new) < 8) { + $error = 'Nouveau mot de passe trop court (8 caractères minimum).'; + } elseif ($new !== $confirm) { + $error = 'Les deux nouveaux mots de passe ne correspondent pas.'; + } else { + $up = $pdo->prepare('UPDATE admin_users SET password_hash = :h WHERE id = :id'); + $up->execute([':h' => password_hash($new, PASSWORD_DEFAULT), ':id' => $uid]); + $notice = 'Mot de passe modifié avec succès.'; + } + } elseif ($action === 'pkg_save') { + $name = trim((string) ($_POST['name'] ?? '')); + if ($name === '') { + $error = 'Le nom du paquet est obligatoire.'; + } else { + $pdo = fws_bugs_db(); + + /* Captures d'écran : existantes conservées (avec légendes + éditées) + nouveaux envois, 5 maximum par paquet. */ + $pkgIdPost = (int) ($_POST['pkg_id'] ?? 0); + $oldRow = null; + if ($pkgIdPost > 0) { + $stOld = $pdo->prepare('SELECT screens FROM packages WHERE id = :id'); + $stOld->execute([':id' => $pkgIdPost]); + $oldRow = $stOld->fetch() ?: null; + } + $oldScreens = $oldRow !== null + ? (array) (json_decode((string) $oldRow['screens'], true) ?: []) + : []; + + $keep = array_fill_keys((array) ($_POST['keep_screens'] ?? []), true); + $captions = (array) ($_POST['captions'] ?? []); + $screens = []; + $removedSrcs = []; + foreach ($oldScreens as $os) { + $src = (string) ($os['src'] ?? ''); + if ($src === '' || !isset($keep[$src])) { + /* Décochée : le fichier sera supprimé APRÈS la mise à + jour en base (sinon elle le compte encore en usage). */ + if ($src !== '') { + $removedSrcs[] = $src; + } + continue; + } + $cap = isset($captions[$src]) ? trim((string) $captions[$src]) : ''; + $screens[] = [ + 'src' => $src, + 'alt' => ($os['alt'] ?? '') !== '' ? (string) $os['alt'] : $name, + 'caption' => $cap !== '' ? $cap : null, + ]; + } + + $newFiles = (array) ($_FILES['new_screens'] ?? []); + $countNew = is_array($newFiles['name'] ?? null) ? count($newFiles['name']) : 0; + + /* Indices des fichiers réellement envoyés (pas les slots vides). */ + $uploadIdx = []; + for ($i = 0; $i < $countNew; $i++) { + if ((int) ($newFiles['error'][$i] ?? UPLOAD_ERR_NO_FILE) !== UPLOAD_ERR_NO_FILE + || (string) ($newFiles['name'][$i] ?? '') !== '') { + $uploadIdx[] = $i; + } + } + + /* Limite vérifiée AVANT tout stockage : refus clair, rien n'est + écrit (ni base ni fichiers) si le total dépasse la limite. */ + if (count($screens) + count($uploadIdx) > FWS_PKG_IMG_MAX) { + $error = 'Maximum ' . FWS_PKG_IMG_MAX . ' images par paquet : ' + . count($screens) . ' conservée(s) + ' . count($uploadIdx) + . ' envoyée(s). Retirez-en d\'abord.'; + } else { + $slugPost = trim((string) ($_POST['slug'] ?? '')); + if ($slugPost === '') { + $slugPost = trim(preg_replace('/[^a-zA-Z0-9]+/', '-', $name) ?? '', '-'); + } + $storedThisRequest = []; + foreach ($uploadIdx as $i) { + try { + $src = fws_admin_store_screen_upload([ + 'name' => (string) $newFiles['name'][$i], + 'type' => (string) ($newFiles['type'][$i] ?? ''), + 'tmp_name' => (string) ($newFiles['tmp_name'][$i] ?? ''), + 'error' => (int) ($newFiles['error'][$i] ?? UPLOAD_ERR_NO_FILE), + 'size' => (int) ($newFiles['size'][$i] ?? 0), + ], $slugPost); + $storedThisRequest[] = $src; + $screens[] = ['src' => $src, 'alt' => $name, 'caption' => null]; + } catch (RuntimeException $ex) { + /* Un fichier invalide annule tout : on ne garde pas + des images déjà stockées mais non enregistrées. */ + foreach ($storedThisRequest as $tmpSrc) { + @unlink(dirname(__DIR__, 2) . $tmpSrc); + } + $error = $ex->getMessage(); + break; + } + } + } + + if ($error === null) { + fws_packages_save($pdo, [ + 'id' => $pkgIdPost, + 'slug' => (string) ($_POST['slug'] ?? ''), + 'name' => $name, + 'tagline' => (string) ($_POST['tagline'] ?? ''), + 'description' => (string) ($_POST['description'] ?? ''), + 'since' => (string) ($_POST['since'] ?? ''), + 'since_label' => (string) ($_POST['since_label'] ?? ''), + 'latest_name' => (string) ($_POST['latest_name'] ?? ''), + 'latest_date' => (string) ($_POST['latest_date'] ?? ''), + 'links' => links_from_lines((string) ($_POST['links'] ?? '')), + 'screens' => $screens, + 'changelog' => changelog_from_lines((string) ($_POST['changelog'] ?? '')), + ]); + /* La base est à jour : on peut maintenant supprimer les + fichiers décochés devenus orphelins. */ + foreach ($removedSrcs as $rsrc) { + fws_admin_delete_img_if_unused($pdo, $rsrc); + } + $wasEdit = $pkgIdPost > 0; + $_SESSION['flash'] = ['ok' => $wasEdit + ? "Paquet « $name » mis à jour." + : "Paquet « $name » créé."]; + header('Location: index.php?view=packages'); + exit; + } + } + } elseif ($action === 'pkg_delete') { + $pkgId = (int) ($_POST['pkg_id'] ?? 0); + $pdo = fws_bugs_db(); + /* On note les images du paquet, on supprime la ligne, puis on + nettoie les fichiers devenus orphelins (la base ne doit plus + les référencer au moment de la vérification). */ + $stDel = $pdo->prepare('SELECT screens FROM packages WHERE id = :id'); + $stDel->execute([':id' => $pkgId]); + $rowDel = $stDel->fetch(); + $orphanSrcs = []; + if ($rowDel !== false) { + foreach ((array) (json_decode((string) $rowDel['screens'], true) ?: []) as $os) { + $s = (string) ($os['src'] ?? ''); + if ($s !== '') { + $orphanSrcs[] = $s; + } + } + } + fws_packages_delete($pdo, $pkgId); + foreach ($orphanSrcs as $osrc) { + fws_admin_delete_img_if_unused($pdo, $osrc); + } + $_SESSION['flash'] = ['ok' => "Paquet #$pkgId supprimé."]; + header('Location: index.php?view=packages'); + exit; + } elseif ($action === 'pkg_sync_gitea') { + /* Rafraîchit latest + historique d'un paquet depuis l'API Gitea + (le dépôt est déduit de ses liens « Gitea » / « Releases »). */ + $pkgId = (int) ($_POST['pkg_id'] ?? 0); + $pdo = fws_bugs_db(); + $st = $pdo->prepare('SELECT * FROM packages WHERE id = :id'); + $st->execute([':id' => $pkgId]); + $row = $st->fetch(); + if ($row === false) { + $_SESSION['flash'] = ['err' => "Paquet #$pkgId introuvable."]; + header('Location: index.php?view=packages'); + exit; + } + $links = json_decode((string) $row['links'], true) ?: []; + $repo = null; + foreach ($links as $link) { + if (preg_match('~^https?://gitea\.nocode-var\.tech/([^/]+)/([^/]+)/?$~i', (string) ($link['url'] ?? ''), $m)) { + $repo = ['owner' => $m[1], 'name' => $m[2]]; + break; + } + } + if ($repo === null) { + $_SESSION['flash'] = ['err' => 'Aucun lien Gitea (gitea.nocode-var.tech) dans ce paquet : synchronisation impossible.']; + header('Location: index.php?view=packages'); + exit; + } + require_once __DIR__ . '/../../inc/site.php'; + $releases = fws_site_gitea_releases($repo['owner'], $repo['name']); + if ($releases === []) { + $_SESSION['flash'] = ['err' => 'Gitea ne renvoie aucune release pour ' . $repo['owner'] . '/' . $repo['name'] . '.']; + header('Location: index.php?view=packages'); + exit; + } + $first = $releases[0]; + $changelog = []; + foreach ($releases as $rel) { + $notes = trim(strip_tags((string) fws_markdown((string) ($rel['body'] ?? '')))); + if (mb_strlen($notes) > 200) { + $notes = rtrim(mb_substr($notes, 0, 200)) . '…'; + } + $changelog[] = [ + 'version' => (string) ($rel['tag_name'] ?? ''), + 'date' => isset($rel['published_at']) ? substr((string) $rel['published_at'], 0, 10) : null, + 'notes' => $notes, + ]; + } + fws_packages_save($pdo, [ + 'id' => $pkgId, + 'slug' => (string) $row['slug'], + 'name' => (string) $row['name'], + 'tagline' => (string) $row['tagline'], + 'description' => (string) $row['description'], + 'since' => (string) ($row['since'] ?? ''), + 'since_label' => (string) $row['since_label'], + 'latest_name' => (string) ($first['tag_name'] ?? ''), + 'latest_date' => isset($first['published_at']) ? substr((string) $first['published_at'], 0, 10) : '', + 'links' => $links, + 'screens' => json_decode((string) $row['screens'], true) ?: [], + 'changelog' => $changelog, + ]); + $_SESSION['flash'] = ['ok' => 'Paquet « ' . $row['name'] . ' » synchronisé depuis Gitea (' . count($releases) . ' releases).']; + header('Location: index.php?view=packages'); + exit; + } + } +} + +$user = current_user(); + +/* Message ponctuel laissé par une action (après redirection) */ +if ($flash !== null) { + if (!empty($flash['err'])) { + $error = (string) $flash['err']; + } + if (!empty($flash['ok'])) { + $notice = (string) $flash['ok']; + } +} + +/* ───────────────────────── routage vues ───────────────────────── */ + +try { + $pdo = fws_bugs_db(); +} catch (Throwable $e) { + http_response_code(500); + exit('Erreur base de données : ' . h($e->getMessage())); +} + +$view_id = (int) ($_GET['id'] ?? 0); +$view_invites = ($_GET['view'] ?? '') === 'invites' && $view_id === 0; +$view_packages = ($_GET['view'] ?? '') === 'packages' && $view_id === 0; +$edit_pkg_id = $view_packages ? (int) ($_GET['edit'] ?? 0) : 0; + +/* Compteurs pour les filtres */ +$counts = ['tous' => 0]; +foreach ($STATUSES as $k => $v) { + $counts[$k] = 0; +} +foreach ($pdo->query('SELECT status, COUNT(*) c FROM bug_reports GROUP BY status') as $row) { + $s = $row['status']; + if (isset($counts[$s])) { + $counts[$s] = (int) $row['c']; + $counts['tous'] += (int) $row['c']; + } +} + +/* ───────────────────────── affichage ───────────────────────── */ + +header('Content-Type: text/html; charset=utf-8'); +?> + + + + + +Signalements — FWS Linux + + + +
+ + + + + + + +
+
+

🐞 Signalements de bugs

+
Connecté : · Base SQLite · tester l'API
+
+
+ + + +
+
+ + + +
+
+ + 0): /* ─────────── DÉTAIL ─────────── */ + + $st = $pdo->prepare('SELECT * FROM bug_reports WHERE id = :id'); + $st->execute([':id' => $view_id]); + $r = $st->fetch(); + if ($r === false): +?> +

Signalement # introuvable.

+ ← Retour à la liste + + ← Retour à la liste +
+
+

# —

+ +
+
+ 📅 + 📦 + +
+ + +

+ + + + + + + + + + + + + + + + +
E-mail
Système
IP
User-agent
DiscordVoir le post dans le forum ↗
Discordpost créé (lien indisponible)
+ + +
+
📜 Logs :
+
+
+ + +
+ Changer le statut : + $sv): + if ($sk === $r['status']) continue; ?> +
+ + + + + +
+ + +
+ + + + +
+
+
+ + +query('SELECT * FROM invite_codes ORDER BY id DESC LIMIT 200')->fetchAll(); + $users = $pdo->query('SELECT id, username, created_at FROM admin_users ORDER BY id')->fetchAll(); + $userNames = []; + foreach ($users as $u) { + $userNames[(int) $u['id']] = (string) $u['username']; + } + $now = date('Y-m-d H:i:s'); +?> + +
+

🎟️ Générer un code d'invitation

+

Le code est à usage unique : donnez-le à la personne, elle l'utilise sur la page + admin/bugs/register.php pour créer son compte (nom + mot de passe).

+
+ + + + + +
+ +
+ 🎉 Nouveau code à donner : + + +
+ +
+ +
+

Codes générés ()

+ +

Aucun code pour l'instant.

+ +
+ + + + + + + + + + + + +
CodeCrééExpireStatutUtilisé par
+ +
+ + + + +
+ +
+
+ +
+ +
+

👥 Comptes existants ()

+

Tous les comptes peuvent consulter et traiter les signalements. Chacun peut modifier son propre mot de passe ci-dessous.

+ +

Aucun compte.

+ + + + + + + + + +
NomCréé le
+ +
+ +
+

🔑 Mon mot de passe

+

Connecté en tant que . Le nouveau mot de passe doit faire au moins 8 caractères.

+
+ + + + + + + + + +
+
+ +query('SELECT * FROM packages ORDER BY id ASC')->fetchAll(); + $editing = null; + if ($edit_pkg_id > 0) { + foreach ($pkgRows as $pr) { + if ((int) $pr['id'] === $edit_pkg_id) { + $editing = $pr; + break; + } + } + if ($editing === null) { + $edit_pkg_id = 0; + } + } + $form = $editing !== null ? $editing : [ + 'id' => 0, 'slug' => '', 'name' => '', 'tagline' => '', 'description' => '', + 'since' => null, 'since_label' => 'FWS', 'latest_name' => '', 'latest_date' => null, + 'links' => '[]', 'screens' => '[]', 'changelog' => '[]', + ]; + $fLinks = lines_from_links((array) (json_decode((string) $form['links'], true) ?: [])); + /* Captures actuelles du paquet (picker d'images). */ + $formScreensData = []; + foreach ((array) (json_decode((string) $form['screens'], true) ?: []) as $fsd) { + if (is_array($fsd) && (string) ($fsd['src'] ?? '') !== '') { + $formScreensData[] = $fsd; + } + } + $fChangelog = lines_from_changelog((array) (json_decode((string) $form['changelog'], true) ?: [])); +?> + +
+

+

← Annuler la modification

+

Les champs « une ligne par entrée » utilisent le format Label | URL (liens), + Version | Date | Notes (historique) et src | alt | légende (captures).

+
+ + + +
+
+ + +
+
+ + +
+
+ + + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + + + +
+ +
+ + + +
+ + 0): ?> +
+ + + +
+ +
+ JPG / PNG / WebP / GIF — 2 Mo max par image, images max par paquet. Elles sont servies sur tout le site (cartes, page détail, menu). + +
+
+ +
+

📦 Paquets ()

+ +

Aucun paquet. Créez le premier avec le formulaire ci-dessus.

+ +
+ + + + + + + + + + +
#NomDernière release
+ +
+
+
+ ✏️ Modifier +
+ + + + +
+
+ + + + +
+
+
+ +
+ +prepare("SELECT COUNT(*) FROM bug_reports $where"); + $st->execute($params); + $total = (int) $st->fetchColumn(); + $pages = max(1, (int) ceil($total / $perPage)); + $page = min($page, $pages); + $offset = ($page - 1) * $perPage; + + $st = $pdo->prepare( + "SELECT * FROM bug_reports $where ORDER BY id DESC LIMIT :lim OFFSET :off" + ); + $st->bindValue(':lim', $perPage, PDO::PARAM_INT); + $st->bindValue(':off', $offset, PDO::PARAM_INT); + foreach ($params as $k => $v) $st->bindValue($k, $v); + $st->execute(); + $reports = $st->fetchAll(); +?> + +
+ $c): ?> + + () + + +
+ + +

Aucun signalement pour le moment. 🎉

+ + + +
+
+

# —

+ +
+
+ 📅 + 📦 + + ✉️ +
+ +

+ +
+
+ + + 1): ?> +
+ 1): ?>← Précédent + Page / + Suivant → +
+ + + + + + + +
+ + + + diff --git a/admin/bugs/init.php b/admin/bugs/init.php new file mode 100644 index 0000000..ae5eacd --- /dev/null +++ b/admin/bugs/init.php @@ -0,0 +1,103 @@ + $arg) { + if (str_starts_with($arg, '--user=')) { + $user = substr($arg, 7); + } elseif (str_starts_with($arg, '--pass=')) { + $pass = substr($arg, 7); + } elseif ($arg === '--reset') { + $reset = true; + } +} + +echo "── Signalements FWS — gestion des comptes admin ──\n\n"; + +try { + $pdo = fws_bugs_db(); +} catch (Throwable $e) { + fwrite(STDERR, 'Erreur base de données : ' . $e->getMessage() . "\n"); + exit(1); +} + +$count = (int) $pdo->query('SELECT COUNT(*) FROM admin_users')->fetchColumn(); +echo 'Comptes admin existants : ' . $count . "\n\n"; + +/* Mode interactif */ +if ($user === null) { + $user = trim(prompt('Nom d\'utilisateur : ')); + $pass = prompt('Mot de passe (min. 8 caractères) : '); + if ($count > 0) { + $confirm = strtolower(trim(prompt('Un compte existe déjà : voulez-vous AJOUTER ce compte ? (oui/non) : '))); + if ($confirm !== 'oui' && $confirm !== 'o' && $confirm !== 'y' && $confirm !== 'yes') { + exit("Annulé.\n"); + } + } +} + +$user = trim((string) $user); +if ($user === '' || !preg_match('/^[A-Za-z0-9_.\-]{2,32}$/', $user)) { + fwrite(STDERR, "Nom d'utilisateur invalide (2 à 32 caractères : lettres, chiffres, . _ -).\n"); + exit(1); +} +if (strlen((string) $pass) < 8) { + fwrite(STDERR, "Mot de passe trop court (8 caractères minimum).\n"); + exit(1); +} + +$stmt = $pdo->prepare('SELECT id FROM admin_users WHERE username = :u'); +$stmt->execute([':u' => $user]); +$existing = $stmt->fetch(); + +$hash = password_hash((string) $pass, PASSWORD_DEFAULT); + +if ($existing !== false) { + if (!$reset) { + fwrite(STDERR, "L'utilisateur « $user » existe déjà. Utilisez --reset pour changer son mot de passe.\n"); + exit(1); + } + $up = $pdo->prepare('UPDATE admin_users SET password_hash = :h WHERE id = :id'); + $up->execute([':h' => $hash, ':id' => $existing['id']]); + echo "✅ Mot de passe de « $user » réinitialisé.\n"; +} else { + $uid = fws_bugs_next_id($pdo, 'admin_users'); + $ins = $pdo->prepare('INSERT INTO admin_users (id, username, password_hash) VALUES (:id, :u, :h)'); + $ins->execute([':id' => $uid, ':u' => $user, ':h' => $hash]); + echo "✅ Utilisateur « $user » créé (id $uid).\n"; +} + +echo "\nPanneau : https://fwslinux.fr/admin/bugs/\n"; +exit(0); diff --git a/admin/bugs/register.php b/admin/bugs/register.php new file mode 100644 index 0000000..40e8e61 --- /dev/null +++ b/admin/bugs/register.php @@ -0,0 +1,158 @@ +beginTransaction(); + try { + $hash = password_hash($password, PASSWORD_DEFAULT); + $uid = fws_bugs_next_id($pdo, 'admin_users'); + $ins = $pdo->prepare('INSERT INTO admin_users (id, username, password_hash) VALUES (:id, :u, :h)'); + $ins->execute([':id' => $uid, ':u' => $username, ':h' => $hash]); + + $claim = $pdo->prepare("UPDATE invite_codes SET used_by = :uid, used_at = datetime('now') WHERE id = :id AND used_by IS NULL"); + $claim->execute([':uid' => $uid, ':id' => (int) $invite['id']]); + if ($claim->rowCount() !== 1) { + throw new RuntimeException('Code déjà utilisé entre-temps.'); + } + $pdo->commit(); + $ok = true; + } catch (Throwable $e) { + $pdo->rollBack(); + if ($pdo->errorInfo()[1] === 19 && strpos((string) $e->getMessage(), 'UNIQUE') !== false) { + $error = 'Ce nom d\'utilisateur est déjà pris. Choisissez-en un autre.'; + } else { + error_log('[fws-bugs] inscription : ' . $e->getMessage()); + $error = 'Erreur interne lors de l\'inscription. Réessayez.'; + } + } + } + } catch (Throwable $e) { + $error = 'Erreur base de données : ' . h($e->getMessage()); + } +} + +/* Succès → retour à la page de connexion avec un message */ +if ($ok) { + header('Location: index.php?registered=1'); + exit; +} + +$fwsScheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; +$baseUrl = $fwsScheme . '://' . ($_SERVER['HTTP_HOST'] ?? 'fwslinux.fr'); +$codeValue = $submitted ? $code : ''; +$userValue = $submitted ? $username : ''; +?> + + + + + +Créer un compte — Signalements FWS + + + +
+
+

🎟️ Créer un compte

+

Tu as reçu un code d'invitation à usage unique de l'équipe FWS. + Saisis-le ci-dessous puis choisis ton nom d'utilisateur et ton mot de passe.

+ +
+ +
+ + + + + +
2 à 32 caractères : lettres, chiffres, . _ -
+ + + + + + + + + +
+ + ← Retour à la connexion +
+
+ + diff --git a/admin/bugs/run-build.sh b/admin/bugs/run-build.sh new file mode 100644 index 0000000..f7c5354 --- /dev/null +++ b/admin/bugs/run-build.sh @@ -0,0 +1,115 @@ +#!/bin/bash +# ============================================================================= +# FWS — Pipeline « Build ISO » déclenché depuis le panneau admin +# (admin/bugs/build.php → process détaché, logs dans le terminal). +# +# Exécuté DANS le conteneur web (fws-files), qui pilote le moteur Docker +# Desktop via /var/run/docker.sock. Toutes les étapes se déroulent dans un +# conteneur archlinux jetable (--privileged, exigé par mkarchiso), le dépôt +# Windows D:\FWS-ISO étant monté sur /fws — exactement le repli Docker que +# font build.sh / setup-aur.sh quand on les lance depuis Git Bash sans WSL. +# +# Étapes : +# 1. passage sur la branche « main » (abandon propre si des modifications +# locales non commitées empêchent le checkout — rien n'est jamais perdu) +# 2. git pull origin main +# 3. bash build.sh +# 4. si build.sh échoue → bash setup-aur.sh, puis relance de build.sh +# ============================================================================= +set -u + +# ── Token Gitea (optionnel) : déposé par build.php dans +# api/bugs/data/build/git-auth.env (jamais commité, jamais affiché). +# Transmis au conteneur en variable d'environnement → git l'utilise pour +# le pull sans qu'aucune donnée d'auth n'apparaisse dans les logs. +AUTH_ENV="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../api/bugs/data/build/git-auth.env" +GIT_AUTH=() +if [ -f "$AUTH_ENV" ]; then + . "$AUTH_ENV" +fi +if [ -n "${FWS_GIT_TOKEN:-}" ]; then + AUTH64="$(printf '%s:%s' "${FWS_GIT_USER:-fws}" "$FWS_GIT_TOKEN" | base64 -w0 2>/dev/null || printf '%s:%s' "${FWS_GIT_USER:-fws}" "$FWS_GIT_TOKEN" | base64)" + GIT_AUTH=( + -e GIT_CONFIG_COUNT=1 + -e GIT_CONFIG_KEY_0=http.extraheader + -e "GIT_CONFIG_VALUE_0=AUTHORIZATION: basic ${AUTH64}" + ) +fi + +IMG="docker.io/library/archlinux:latest" +NAME="fws-iso-build" +REPO_WIN='D:\FWS-ISO' # chemin Windows résolu par le moteur Docker Desktop + +now() { date '+%H:%M:%S'; } + +echo "[$(now)] ════════════ FWS — Build ISO ════════════" +echo "[$(now)] Pipeline lancé depuis le panneau admin (conteneur web)." + +rc=0 + +echo "[$(now)] docker pull ${IMG}…" +if ! docker pull "$IMG"; then + echo "[$(now)] ÉCHEC : pull de l'image archlinux impossible (Docker Desktop arrêté ou réseau coupé ?)." + rc=70 +else + # Nettoie un éventuel build précédent resté vivant (arrêt brutal). + docker rm -f "$NAME" >/dev/null 2>&1 + + echo "[$(now)] Conteneur Arch : checkout main → pull → build.sh (repli setup-aur.sh)." + docker run --rm --privileged --name "$NAME" \ + -e FWS_IN_CONTAINER=1 \ + "${GIT_AUTH[@]}" \ + -v fws-pacman-cache:/var/cache/pacman/pkg \ + -v "${REPO_WIN}:/fws" \ + -w /fws \ + "$IMG" \ + bash -lc ' + set -u + cd /fws || { echo "==> /fws introuvable : le montage D:\FWS-ISO est-il actif ?"; exit 81; } + + echo "==> Installation de git dans le conteneur (image fraîche sans git)…" + pacman -Sy --noconfirm git >/dev/null 2>&1 \ + || { echo "==> ÉCHEC : pacman -Sy git (réseau du conteneur ?)."; exit 80; } + + echo "==> Branche actuelle : $(git branch --show-current)" + echo "==> Passage sur main…" + git checkout main 2>&1 || { + echo + echo "!! Impossible de passer sur main : des modifications locales non commitées" + echo "!! dans D:\FWS-ISO empêchent le checkout (voir « git status »)." + echo "!! Committe ou stash ces modifications, puis relance le build." + exit 90 + } + echo "==> git pull (origin main)…" + GIT_TERMINAL_PROMPT=0 git pull --ff-only origin main || { + echo "!! git pull a échoué (réseau, droits, ou conflit ?)." + exit 91 + } + + echo + echo "==> bash build.sh" + if bash build.sh; then + echo "==> ✅ build.sh terminé sans erreur." + exit 0 + fi + + echo + echo "!! build.sh a échoué → lancement de setup-aur.sh, puis nouvel essai de build.sh" + if ! bash setup-aur.sh; then + echo "!! setup-aur.sh a échoué." + exit 92 + fi + echo "==> bash build.sh (2e tentative)…" + if bash build.sh; then + echo "==> ✅ build.sh (2e tentative) terminé sans erreur." + exit 0 + fi + echo "!! Nouvel échec de build.sh." + exit 93 + ' + rc=$? + docker rm -f "$NAME" >/dev/null 2>&1 || true +fi + +echo "[$(now)] ════════════ Fin du pipeline (code ${rc}) ════════════" +exit "$rc" diff --git a/api/bugs.php b/api/bugs.php new file mode 100644 index 0000000..e706bbc --- /dev/null +++ b/api/bugs.php @@ -0,0 +1,277 @@ + false, 'error' => 'Méthode non autorisée. Utilisez POST.'], JSON_UNESCAPED_UNICODE); + exit; +} + +/* Anti-spam : champ piège « website » rempli par les robots → on ignore sans le dire */ +$honeypot = trim((string) ($_POST['website'] ?? '')); +if ($honeypot !== '') { + http_response_code(201); + echo json_encode(['ok' => true, 'id' => null, 'message' => 'Merci.'], JSON_UNESCAPED_UNICODE); + exit; +} + +/* Lecture du corps : JSON ou formulaire classique */ +$rawBody = file_get_contents('php://input'); +$ct = $_SERVER['CONTENT_TYPE'] ?? ''; +$data = $_POST; + +if (stripos($ct, 'application/json') !== false) { + $decoded = json_decode($rawBody === false ? '' : $rawBody, true); + if (!is_array($decoded)) { + http_response_code(400); + echo json_encode(['ok' => false, 'error' => 'JSON invalide.'], JSON_UNESCAPED_UNICODE); + exit; + } + $data = $decoded; +} + +/* Champs acceptés, avec des alias tolérés */ +$fields = [ + 'app' => strval($data['app'] ?? $data['application'] ?? ''), + 'version' => strval($data['version'] ?? ''), + 'type' => strval($data['type'] ?? $data['category'] ?? 'bug'), + 'title' => strval($data['title'] ?? $data['subject'] ?? ''), + 'description' => strval($data['description'] ?? $data['message'] ?? $data['details'] ?? ''), + 'email' => strval($data['email'] ?? $data['contact'] ?? ''), + 'system_info' => strval($data['system_info'] ?? $data['system'] ?? $data['hardware'] ?? ''), + 'logs' => strval($data['logs'] ?? $data['log'] ?? $data['journal'] ?? ''), +]; + +/* Aucun plafond sur les champs : les logs d'installation peuvent peser + très lourd et un client curl doit pouvoir tout envoyer. */ +$title = trim($fields['title']); +$description = trim($fields['description']); +$logs = trim($fields['logs']); +$app = trim($fields['app']); +$version = trim($fields['version']); +$email = trim($fields['email']); +$systemInfo = trim($fields['system_info']); +$type = trim($fields['type']); + +/* Un signalement doit contenir au moins un peu de contenu utile */ +if ($title === '' && $description === '' && $logs === '') { + http_response_code(400); + echo json_encode([ + 'ok' => false, + 'error' => 'Contenu vide : envoyez au moins un titre, une description ou des logs.', + ], JSON_UNESCAPED_UNICODE); + exit; +} + +/* Connexion à la base (aucun anti-flood : l'API est ouverte par design) */ +try { + $pdo = fws_bugs_db(); +} catch (Throwable $e) { + error_log('[fws-bugs] ' . $e->getMessage()); + http_response_code(500); + echo json_encode(['ok' => false, 'error' => 'Erreur interne de la base de données.'], JSON_UNESCAPED_UNICODE); + exit; +} + +$ip = fws_bugs_client_ip(); + +/* Insertion — l'id repart de 1 et saute ceux déjà pris */ +try { + $bugId = fws_bugs_next_id($pdo, 'bug_reports'); + $stmt = $pdo->prepare( + 'INSERT INTO bug_reports + (id, app, version, type, title, description, email, system_info, logs, ip, user_agent) + VALUES + (:id, :app, :version, :type, :title, :description, :email, :system_info, :logs, :ip, :ua)' + ); + $stmt->execute([ + ':id' => $bugId, + ':app' => $app, + ':version' => $version, + ':type' => $type !== '' ? $type : 'bug', + ':title' => $title, + ':description' => $description, + ':email' => $email, + ':system_info' => $systemInfo, + ':logs' => $logs, + ':ip' => $ip, + ':ua' => mb_substr((string) ($_SERVER['HTTP_USER_AGENT'] ?? ''), 0, 300), + ]); +} catch (Throwable $e) { + error_log('[fws-bugs] insertion : ' . $e->getMessage()); + http_response_code(500); + echo json_encode(['ok' => false, 'error' => 'Erreur interne lors de l\'enregistrement.'], JSON_UNESCAPED_UNICODE); + exit; +} + +http_response_code(201); +echo json_encode([ + 'ok' => true, + 'id' => $bugId, + 'message' => 'Signalement enregistré. Merci !', +], JSON_UNESCAPED_UNICODE); + +/* Envoie la réponse au client tout de suite ; la notif Discord suit en arrière-plan. */ +if (function_exists('fastcgi_finish_request')) { + fastcgi_finish_request(); +} else { + flush(); +} + +/* Notification Discord (best-effort : n'affecte jamais la réponse de l'API) */ +try { + $discord = fws_bugs_discord_notify([ + 'id' => $bugId, + 'app' => $app, + 'version' => $version, + 'type' => $type !== '' ? $type : 'bug', + 'title' => $title, + 'description' => $description, + 'email' => $email, + 'system_info' => $systemInfo, + 'logs' => $logs, + 'status' => 'nouveau', + ]); + if (is_array($discord) && !empty($discord['thread_id'])) { + fws_bugs_save_discord_info($pdo, $bugId, (string) $discord['thread_id'], (string) ($discord['post_url'] ?? '')); + } +} catch (Throwable $e) { + error_log('[fws-bugs] discord : ' . $e->getMessage()); +} +exit; + +/* ──────────────────────────────────────────── */ + +function render_test_page(): void +{ + $base = htmlspecialchars(strtok($_SERVER['REQUEST_URI'] ?? '/api/bugs.php', '?'), ENT_QUOTES, 'UTF-8'); + ?> + + + + + + Envoyer un signalement — FWS Linux + + + +

🐞 Envoyer un signalement

+

Page de test — le vrai envoi est fait par l'application (curl / script) sur POST .

+
+ + + + + + + + + + +
+ + + + + / + * + * 2) bot_token (optionnel mais recommandé) : token d'un bot Discord + * https://discord.com/developers/applications → New Application → Bot → + * Reset Token → invite-le dans ton serveur avec les permissions + * « Manage Threads » et « Manage Tags ». + * Avec un bot, les tags « Nouveau / En cours / Résolu / Ignoré » sont + * créés automatiquement et mis à jour quand le statut change sur le site. + * + * 3) tags (optionnel si bot) : IDs des tags créés à la main dans Discord. + * Sans bot : crée les tags dans le canal forum puis colle ici leurs IDs + * (Activer le mode développeur Discord → réseau du navigateur, ou via un + * outil type Discord API avec le bot). + * + * 4) gitea_token (requis pour l'onglet « Build ISO ») : le dépôt + * D:\FWS-ISO est privé sur gitea.nocode-var.tech, et le build tourne dans + * un conteneur qui n'a pas tes identifiants Windows. Génère un token dans + * Gitea → Settings → Applications → Generate New Token (scope : lecture + * du dépôt / read:repository), puis colle-le ici. + * Le token n'est JAMAIS commité, ni affiché dans les logs du build. + * + * config.local.php n'est PAS commité (secret) — il est dans .gitignore. + */ +return [ + 'webhook_url' => 'https://discord.com/api/webhooks/REMPLACE_PAR_ID/REMPLACE_PAR_TOKEN', + 'bot_token' => '', + 'gitea_username' => '', // optionnel : nom du compte Gitea (défaut « fws ») + 'gitea_token' => '', // token Gitea (lecture dépôt) pour le build ISO + 'tags' => [ + 'nouveau' => '', + 'en_cours' => '', + 'resolu' => '', + 'ignore' => '', + ], +]; diff --git a/api/bugs/data/.gitignore b/api/bugs/data/.gitignore new file mode 100644 index 0000000..9188804 --- /dev/null +++ b/api/bugs/data/.gitignore @@ -0,0 +1,8 @@ +# La base de données ne doit jamais être commitée +*.sqlite +*.sqlite-wal +*.sqlite-shm +fws_bugs.sqlite + +# Logs / états de l'onglet « Build ISO » (admin/bugs/build.php) +/build/ diff --git a/api/bugs/data/.htaccess b/api/bugs/data/.htaccess new file mode 100644 index 0000000..4b81972 --- /dev/null +++ b/api/bugs/data/.htaccess @@ -0,0 +1,3 @@ +# Bloque tout accès direct (navigateur, curl…) à la base SQLite. +# Seul le code PHP du serveur (api/admin) peut lire ce répertoire. +Require all denied diff --git a/api/bugs/db.php b/api/bugs/db.php new file mode 100644 index 0000000..4eb3241 --- /dev/null +++ b/api/bugs/db.php @@ -0,0 +1,410 @@ + $v) { + if (is_array($v)) { + $out[$k] = fws_utf8_arr($v); + } elseif (is_string($v)) { + $out[$k] = fws_utf8_str($v); + } else { + $out[$k] = $v; + } + } + return $out; + } +} + +function fws_bugs_db(): PDO +{ + static $pdo = null; + if ($pdo instanceof PDO) { + return $pdo; + } + + $dir = __DIR__ . '/data'; + if (!is_dir($dir)) { + mkdir($dir, 0775, true); + } + + try { + $pdo = new PDO('sqlite:' . $dir . '/fws_bugs.sqlite'); + } catch (Throwable $e) { + /* Driver PDO SQLite absent (cas fréquent : WAMP/XAMPP où pdo_sqlite + et sqlite3 sont à activer dans php.ini). Message clair au lieu d'un + crash avec stack trace. */ + throw new RuntimeException( + 'Extension PDO SQLite indisponible : activez "extension=pdo_sqlite" et "extension=sqlite3" dans php.ini.', + 0, + $e + ); + } + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); + + /* Sur un bind-mount Docker Desktop, tout appartient à root : on rend le + fichier DB inscriptible par Apache (www-data) quoi qu'il arrive. */ + @chmod($dir . '/fws_bugs.sqlite', 0666); + @chmod($dir, 0777); + + /* Pas de WAL : sur un bind-mount Docker Desktop, les fichiers -wal/-shm + créés tantôt par root (CLI) tantôt par www-data (Apache) se marchent + dessus. Le mode journal classique + fichier 666 est plus fiable. */ + $pdo->exec('PRAGMA journal_mode = DELETE'); + $pdo->exec('PRAGMA busy_timeout = 5000'); + + fws_bugs_schema($pdo); + @chmod($dir . '/fws_bugs.sqlite', 0666); + return $pdo; +} + +function fws_bugs_schema(PDO $pdo): void +{ + $pdo->exec( + 'CREATE TABLE IF NOT EXISTS bug_reports ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + app TEXT NOT NULL DEFAULT \'\', + version TEXT NOT NULL DEFAULT \'\', + type TEXT NOT NULL DEFAULT \'bug\', + title TEXT NOT NULL DEFAULT \'\', + description TEXT NOT NULL DEFAULT \'\', + email TEXT NOT NULL DEFAULT \'\', + system_info TEXT NOT NULL DEFAULT \'\', + logs TEXT NOT NULL DEFAULT \'\', + ip TEXT NOT NULL DEFAULT \'\', + user_agent TEXT NOT NULL DEFAULT \'\', + status TEXT NOT NULL DEFAULT \'nouveau\', + created_at TEXT NOT NULL DEFAULT (datetime(\'now\')) + )' + ); + $pdo->exec('CREATE INDEX IF NOT EXISTS idx_reports_created ON bug_reports(created_at DESC)'); + $pdo->exec('CREATE INDEX IF NOT EXISTS idx_reports_status ON bug_reports(status)'); + + /* Migration : colonnes Discord (ajoutées sur les bases déjà existantes) */ + $cols = $pdo->query('PRAGMA table_info(bug_reports)')->fetchAll(); + $hasThread = false; + $hasUrl = false; + foreach ($cols as $c) { + if (($c['name'] ?? '') === 'discord_thread_id') $hasThread = true; + if (($c['name'] ?? '') === 'discord_post_url') $hasUrl = true; + } + if (!$hasThread) { + $pdo->exec("ALTER TABLE bug_reports ADD COLUMN discord_thread_id TEXT NOT NULL DEFAULT ''"); + } + if (!$hasUrl) { + $pdo->exec("ALTER TABLE bug_reports ADD COLUMN discord_post_url TEXT NOT NULL DEFAULT ''"); + } + + $pdo->exec( + 'CREATE TABLE IF NOT EXISTS admin_users ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + username TEXT NOT NULL UNIQUE, + password_hash TEXT NOT NULL, + created_at TEXT NOT NULL DEFAULT (datetime(\'now\')) + )' + ); + + /* Codes d'invitation à usage unique pour créer des comptes */ + $pdo->exec( + 'CREATE TABLE IF NOT EXISTS invite_codes ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + code TEXT NOT NULL UNIQUE, + created_by TEXT NOT NULL DEFAULT \'\', + created_at TEXT NOT NULL DEFAULT (datetime(\'now\')), + expires_at TEXT, + used_by INTEGER, + used_at TEXT, + revoked_at TEXT + )' + ); + + /* Paquets du site (données gérées depuis le panneau admin) */ + $pdo->exec( + 'CREATE TABLE IF NOT EXISTS packages ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + slug TEXT NOT NULL DEFAULT \'\', + name TEXT NOT NULL DEFAULT \'\', + tagline TEXT NOT NULL DEFAULT \'\', + description TEXT NOT NULL DEFAULT \'\', + since TEXT, + since_label TEXT NOT NULL DEFAULT \'FWS\', + latest_name TEXT NOT NULL DEFAULT \'\', + latest_date TEXT, + links TEXT NOT NULL DEFAULT \'[]\', + screens TEXT NOT NULL DEFAULT \'[]\', + changelog TEXT NOT NULL DEFAULT \'[]\', + updated_at TEXT NOT NULL DEFAULT (datetime(\'now\')) + )' + ); + + /* Schéma (re)créé : s'assurer que le fichier reste inscriptible par Apache */ + @chmod(__DIR__ . '/data/fws_bugs.sqlite', 0666); +} + +/** + * Prochain identifiant libre pour une table, en repartant de 1 : + * si l'id 1 est déjà pris, on saute au plus petit id inutilisé. + */ +function fws_bugs_next_id(PDO $pdo, string $table): int +{ + if (!in_array($table, ['bug_reports', 'admin_users', 'invite_codes', 'packages'], true)) { + throw new InvalidArgumentException('Table inconnue : ' . $table); + } + $used = []; + foreach ($pdo->query('SELECT id FROM ' . $table . ' ORDER BY id') as $row) { + $used[(int) $row['id']] = true; + } + $id = 1; + while (isset($used[$id])) { + $id++; + } + return $id; +} + +/** + * Génère un code d'invitation à usage unique (ex. « K7QM-2H4D-X9BP »). + * Alphabet sans caractères ambigus (pas de I/O/0/1). + */ +function fws_bugs_create_invite(PDO $pdo, string $createdBy, int $days): string +{ + $alphabet = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789'; + for ($attempt = 0; $attempt < 5; $attempt++) { + $raw = ''; + for ($i = 0; $i < 12; $i++) { + $raw .= $alphabet[random_int(0, strlen($alphabet) - 1)]; + } + $code = substr($raw, 0, 4) . '-' . substr($raw, 4, 4) . '-' . substr($raw, 8, 4); + $expires = $days > 0 ? date('Y-m-d H:i:s', time() + $days * 86400) : null; + try { + $id = fws_bugs_next_id($pdo, 'invite_codes'); + $st = $pdo->prepare('INSERT INTO invite_codes (id, code, created_by, expires_at) VALUES (:id, :c, :b, :e)'); + $st->execute([':id' => $id, ':c' => $code, ':b' => $createdBy, ':e' => $expires]); + return $code; + } catch (Throwable $e) { + /* collision ultra improbable → on régénère */ + } + } + throw new RuntimeException('Impossible de générer un code d\'invitation.'); +} + +/** + * Cherche un code d'invitation (insensible à la casse et aux tirets). + */ +function fws_bugs_find_invite(PDO $pdo, string $code): ?array +{ + $norm = strtoupper(str_replace(['-', ' '], '', $code)); + if ($norm === '') { + return null; + } + $st = $pdo->prepare("SELECT * FROM invite_codes WHERE REPLACE(UPPER(code), '-', '') = :c LIMIT 1"); + $st->execute([':c' => $norm]); + $row = $st->fetch(); + return $row === false ? null : $row; +} + +/** + * Enregistre le lien du post Discord créé pour un signalement. + */ +function fws_bugs_save_discord_info(PDO $pdo, int $id, string $threadId, string $postUrl): void +{ + $st = $pdo->prepare('UPDATE bug_reports SET discord_thread_id = :t, discord_post_url = :u WHERE id = :id'); + $st->execute([':t' => $threadId, ':u' => $postUrl, ':id' => $id]); +} + +/** + * IP réelle en tenant compte du proxy (X-Forwarded-For). + */ +function fws_bugs_client_ip(): string +{ + $xff = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? ''; + if ($xff !== '') { + $parts = explode(',', $xff); + $ip = trim($parts[0]); + if ($ip !== '') { + return substr($ip, 0, 64); + } + } + return substr((string) ($_SERVER['REMOTE_ADDR'] ?? ''), 0, 64); +} + +/** + * Comptes autorisés à lancer un build ISO (onglet « Build ISO » du panneau). + * Le build pilote le moteur Docker : à n'accorder qu'aux comptes de confiance. + */ +function fws_bugs_can_build(string $username): bool +{ + return in_array(strtolower(trim($username)), ['admin'], true); +} + +/* ───────────────────────── paquets du site ───────────────────────── */ + +/** + * Convertit une ligne brute de la table `packages` au format JSON + * utilisé par le site (identique à l'ancien packages.json). + */ +function fws_packages_row_to_json(array $r): array +{ + $latest = null; + if ((string) ($r['latest_name'] ?? '') !== '') { + $latest = [ + 'name' => fws_utf8_str((string) $r['latest_name']), + 'date' => ($r['latest_date'] ?? null) !== null ? fws_utf8_str((string) $r['latest_date']) : null, + ]; + } + return fws_utf8_arr([ + 'id' => (string) $r['slug'], + 'name' => (string) $r['name'], + 'tagline' => (string) $r['tagline'], + 'description' => (string) $r['description'], + 'since' => ($r['since'] ?? null) !== null ? (string) $r['since'] : null, + 'sinceLabel' => (string) ($r['since_label'] ?? 'FWS'), + 'latest' => $latest, + 'links' => json_decode((string) $r['links'], true) ?: [], + 'screens' => json_decode((string) $r['screens'], true) ?: [], + 'changelog' => json_decode((string) $r['changelog'], true) ?: [], + ]); +} + +/** + * Tous les paquets, ordonnés par id (l'ordre = la position sur le site, + * ex : /?p/paquets/1/ est l'id 1). + */ +function fws_packages_all(PDO $pdo): array +{ + $out = []; + foreach ($pdo->query('SELECT * FROM packages ORDER BY id ASC') as $r) { + $out[] = fws_packages_row_to_json($r); + } + return $out; +} + +/** + * Enregistre un paquet (insert si id = 0, sinon update). + * Les colonnes JSON (links, screens, changelog) sont passées en tableaux PHP. + */ +function fws_packages_save(PDO $pdo, array $d): int +{ + $id = (int) ($d['id'] ?? 0); + $slug = trim((string) ($d['slug'] ?? '')); + if ($slug === '') { + $slug = trim(preg_replace('/[^a-zA-Z0-9]+/', '-', (string) ($d['name'] ?? '')) ?? '', '-'); + } + $sinceLabel = trim((string) ($d['since_label'] ?? '')); + if ($sinceLabel === '') { + $sinceLabel = 'FWS'; + } + $data = [ + ':slug' => fws_utf8_str($slug), + ':name' => fws_utf8_str(trim((string) ($d['name'] ?? ''))), + ':tagline' => fws_utf8_str(trim((string) ($d['tagline'] ?? ''))), + ':description' => fws_utf8_str(trim((string) ($d['description'] ?? ''))), + ':since' => ($d['since'] ?? '') !== '' ? (string) $d['since'] : null, + ':since_label' => fws_utf8_str($sinceLabel), + ':latest_name' => fws_utf8_str(trim((string) ($d['latest_name'] ?? ''))), + ':latest_date' => ($d['latest_date'] ?? '') !== '' ? (string) $d['latest_date'] : null, + ':links' => (string) json_encode(fws_utf8_arr((array) ($d['links'] ?? [])), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), + /* 5 captures maximum par paquet (gardée de force côté serveur). */ + ':screens' => (string) json_encode(array_slice(fws_utf8_arr((array) ($d['screens'] ?? [])), 0, 5), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), + ':changelog' => (string) json_encode(fws_utf8_arr((array) ($d['changelog'] ?? [])), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), + ]; + + if ($id > 0) { + $data[':id'] = $id; + $st = $pdo->prepare( + 'UPDATE packages SET slug = :slug, name = :name, tagline = :tagline, + description = :description, since = :since, since_label = :since_label, + latest_name = :latest_name, latest_date = :latest_date, + links = :links, screens = :screens, changelog = :changelog, + updated_at = datetime(\'now\') WHERE id = :id' + ); + $st->execute($data); + return $id; + } + + $id = fws_bugs_next_id($pdo, 'packages'); + $data[':id'] = $id; + $st = $pdo->prepare( + 'INSERT INTO packages (id, slug, name, tagline, description, since, since_label, + latest_name, latest_date, links, screens, changelog) + VALUES (:id, :slug, :name, :tagline, :description, :since, :since_label, + :latest_name, :latest_date, :links, :screens, :changelog)' + ); + $st->execute($data); + return $id; +} + +/** + * Supprime un paquet (l'id pourra être réutilisé ensuite). + */ +function fws_packages_delete(PDO $pdo, int $id): void +{ + $st = $pdo->prepare('DELETE FROM packages WHERE id = :id'); + $st->execute([':id' => $id]); +} + +/** + * Import initial : si la table `packages` est vide et que l'ancien + * packages.json existe toujours, on l'importe une seule fois. + */ +function fws_packages_seed_if_empty(PDO $pdo): int +{ + $count = (int) $pdo->query('SELECT COUNT(*) FROM packages')->fetchColumn(); + if ($count > 0) { + return 0; + } + $file = dirname(__DIR__) . '/../p/paquets/packages.json'; + if (!is_file($file)) { + return 0; + } + $data = json_decode((string) file_get_contents($file), true); + if (!is_array($data)) { + return 0; + } + $n = 0; + foreach ($data as $p) { + if (!is_array($p)) { + continue; + } + fws_packages_save($pdo, [ + 'id' => 0, + 'slug' => (string) ($p['id'] ?? ''), + 'name' => (string) ($p['name'] ?? ''), + 'tagline' => (string) ($p['tagline'] ?? ''), + 'description' => (string) ($p['description'] ?? ''), + 'since' => (string) ($p['since'] ?? ''), + 'since_label' => (string) ($p['sinceLabel'] ?? 'FWS'), + 'latest_name' => (string) ($p['latest']['name'] ?? ''), + 'latest_date' => (string) ($p['latest']['date'] ?? ''), + 'links' => $p['links'] ?? [], + 'screens' => $p['screens'] ?? [], + 'changelog' => $p['changelog'] ?? [], + ]); + $n++; + } + return $n; +} diff --git a/api/bugs/discord.php b/api/bugs/discord.php new file mode 100644 index 0000000..4d67ee5 --- /dev/null +++ b/api/bugs/discord.php @@ -0,0 +1,366 @@ + '🆕 Nouveau', + 'en_cours' => '🔧 En cours', + 'resolu' => '✅ Résolu', + 'ignore' => '🙈 Ignoré', +]; + +/** + * Configuration lue depuis config.local.php (jamais commité). + * Accepte soit une simple chaîne (URL du webhook), soit un tableau : + * [ 'webhook_url' => ..., 'bot_token' => ..., 'tags' => [status => tagId] ] + */ +function fws_bugs_discord_config(): array +{ + static $cfg = null; + if ($cfg !== null) { + return $cfg; + } + $cfg = ['webhook' => '', 'bot_token' => '', 'tags' => []]; + $local = __DIR__ . '/config.local.php'; + if (is_file($local)) { + $v = require $local; + if (is_string($v)) { + $cfg['webhook'] = $v; + } elseif (is_array($v)) { + $cfg['webhook'] = (string) ($v['webhook_url'] ?? $v['webhook'] ?? ''); + $cfg['bot_token'] = (string) ($v['bot_token'] ?? ''); + $cfg['tags'] = is_array($v['tags'] ?? null) ? $v['tags'] : []; + } + } + $cfg['webhook'] = trim($cfg['webhook']); + if (strpos($cfg['webhook'], 'REMPLACE_PAR') !== false || strpos($cfg['webhook'], 'COLLE_ICI') !== false) { + $cfg['webhook'] = ''; + } + $cfg['bot_token'] = trim($cfg['bot_token']); + return $cfg; +} + +function fws_bugs_discord_enabled(): bool +{ + return fws_bugs_discord_config()['webhook'] !== ''; +} + +/** + * Appel API Discord générique (webhook ou endpoint canal avec bot). + * $auth = 'Bot xxx' pour les endpoints de canaux, '' pour le webhook. + * Retourne le JSON décodé, ou null en cas d'échec (erreur loggée). + */ +function fws_bugs_discord_api(string $method, string $url, array $payload = [], string $auth = ''): ?array +{ + $ch = curl_init($url); + $headers = [ + 'Content-Type: application/json', + 'User-Agent: FWS-Bugs/1.0 (https://fwslinux.fr)', + ]; + if ($auth !== '') { + $headers[] = 'Authorization: ' . $auth; + } + curl_setopt_array($ch, [ + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HTTPHEADER => $headers, + CURLOPT_CONNECTTIMEOUT => 4, + CURLOPT_TIMEOUT => 8, + CURLOPT_SSL_VERIFYPEER => true, + ]); + if ($method === 'GET') { + curl_setopt($ch, CURLOPT_HTTPGET, true); + } else { + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); + } + $body = curl_exec($ch); + $code = (int) curl_getinfo($ch, CURLINFO_RESPONSE_CODE); + $err = curl_error($ch); + curl_close($ch); + + if ($code < 200 || $code >= 300 || $body === false) { + error_log(sprintf( + '[fws-bugs] discord %s %s : HTTP %d %s', + $method, + preg_replace('#//[^/]+/webhooks/\d+/[^/?]+#', '//discord.com/api/webhooks//', $url) ?? $url, + $code, + $err !== '' ? $err : substr((string) $body, 0, 250) + )); + return null; + } + $decoded = json_decode((string) $body, true); + if (is_array($decoded)) { + return $decoded; + } + /* 2xx sans corps JSON (ex : 204 No Content des POST sans wait=true) = + succès : on renvoie [] pour ne pas être confondu avec un échec. */ + return []; +} + +/** + * Infos du webhook (channel_id, guild_id) via GET /webhooks/{id}/{token}. + */ +function fws_bugs_discord_webhook_info(): ?array +{ + static $info = false; + if ($info !== false) { + return $info; + } + $info = null; + $hook = fws_bugs_discord_config()['webhook']; + if ($hook === '') { + return null; + } + if (!preg_match('#/webhooks/(\d+)/([^/?]+)#', $hook, $m)) { + return null; + } + $res = fws_bugs_discord_api('GET', 'https://discord.com/api/webhooks/' . $m[1] . '/' . $m[2]); + if (is_array($res) && !empty($res['channel_id'])) { + $info = $res; + } + return $info; +} + +/** + * IDs des tags Discord pour chaque statut du site. + * Sans bot : utilise les IDs renseignés dans config.local.php. + * Avec bot : les récupère depuis le canal et les crée s'ils manquent. + * + * @return array [statut => tagId] + */ +function fws_bugs_discord_ensure_tags(): array +{ + static $tags = null; + if ($tags !== null) { + return $tags; + } + $cfg = fws_bugs_discord_config(); + + $tags = []; + foreach (($cfg['tags'] ?? []) as $k => $v) { + if (isset(FWS_BUGS_STATUS_LABELS[$k]) && is_string($v) && trim($v) !== '') { + $tags[$k] = trim($v); + } + } + if ($cfg['bot_token'] === '') { + return $tags; + } + + $info = fws_bugs_discord_webhook_info(); + $channelId = is_array($info) ? (string) ($info['channel_id'] ?? '') : ''; + if ($channelId === '') { + return $tags; + } + $bot = 'Bot ' . $cfg['bot_token']; + $channelUrl = 'https://discord.com/api/channels/' . $channelId; + + $channel = fws_bugs_discord_api('GET', $channelUrl, [], $bot); + $available = is_array($channel) ? ($channel['available_tags'] ?? []) : []; + $byName = []; + foreach ($available as $t) { + if (is_array($t) && !empty($t['name']) && !empty($t['id'])) { + $byName[(string) $t['name']] = (string) $t['id']; + } + } + + $defs = [ + 'nouveau' => ['Nouveau', '🆕'], + 'en_cours' => ['En cours', '🔧'], + 'resolu' => ['Résolu', '✅'], + 'ignore' => ['Ignoré', '🙈'], + ]; + foreach ($defs as $status => [$tagName, $emoji]) { + if (isset($tags[$status])) { + continue; + } + $tagId = $byName[$tagName] ?? ''; + if ($tagId === '') { + $created = fws_bugs_discord_api( + 'POST', + $channelUrl . '/tags', + ['name' => $tagName, 'emoji_name' => $emoji, 'moderated' => false], + $bot + ); + $tagId = is_array($created) ? (string) ($created['id'] ?? '') : ''; + } + if ($tagId !== '') { + $tags[$status] = $tagId; + } + } + return $tags; +} + +/** + * Envoie un morceau de logs dans le fil, encadré pour rester sous la limite + * Discord. Renvoie false si Discord refuse. + */ +function fws_bugs_discord_send_log_chunk(string $msgUrl, string $chunk): bool +{ + /* Pas d'en-tête « Logs (N/M) » : chaque message aligne la suite + des logs, ce qui donne un fil continu dans le post. */ + $body = str_contains($chunk, '```') ? $chunk : "```\n" . $chunk . "\n```"; + if (mb_strlen($body) > 1990) { + $body = mb_substr($body, 0, 1990); + } + return fws_bugs_discord_api('POST', $msgUrl, ['content' => $body]) !== null; +} + +/** + * Crée le post dans le canal forum et y envoie le résumé + les logs. + * Best-effort : ne renvoie jamais d'erreur. + * + * @param array $bug colonnes du signalement (app, version, type, title, + * description, email, system_info, logs, status) + * @return array|null ['thread_id' => ..., 'post_url' => ...] ou null en échec + */ +function fws_bugs_discord_notify(array $bug): ?array +{ + $cfg = fws_bugs_discord_config(); + if ($cfg['webhook'] === '') { + return null; + } + $base = rtrim($cfg['webhook'], '/'); + + $title = trim((string) ($bug['title'] ?? '')); + if ($title === '') { + $title = 'Signalement de bug'; + } + $name = mb_substr($title, 0, 95); // 100 max côté Discord + + $desc = trim((string) ($bug['description'] ?? '')); + $sys = trim((string) ($bug['system_info'] ?? '')); + $email = trim((string) ($bug['email'] ?? '')); + $status = isset(FWS_BUGS_STATUS_LABELS[$bug['status'] ?? '']) ? (string) $bug['status'] : 'nouveau'; + + $lines = []; + $lines[] = '**App :** ' . ($bug['app'] !== '' ? $bug['app'] : '—') + . ' · **Version :** ' . ($bug['version'] !== '' ? $bug['version'] : '—') + . ' · **Type :** ' . ($bug['type'] !== '' ? $bug['type'] : 'bug'); + if ($desc !== '') { + $lines[] = ''; + $lines[] = $desc; + } + if ($sys !== '') { + $lines[] = ''; + $lines[] = '**Système / matériel :**'; + $lines[] = $sys; + } + if ($email !== '') { + $lines[] = ''; + $lines[] = '**Contact :** ' . $email; + } + $summary = mb_substr(implode("\n", $lines), 0, 1800); + + /* Créer le post : le webhook doit être sur un canal FORUM. Discord crée + le post dès qu'on passe thread_name (+ tag via applied_tags), et + renvoie le message (wait=true) dont channel_id est l'id du post. */ + $payload = [ + 'content' => $summary, + 'thread_name' => $name, + ]; + $tags = fws_bugs_discord_ensure_tags(); + if (isset($tags[$status])) { + $payload['applied_tags'] = [$tags[$status]]; + } + + $first = fws_bugs_discord_api('POST', $base . '?wait=true', $payload); + $threadId = is_array($first) ? (string) ($first['channel_id'] ?? '') : ''; + if ($threadId === '') { + error_log('[fws-bugs] discord : échec création du post « ' . $name . ' »'); + return null; + } + + /* URL du post pour l'admin (guild_id via les infos du webhook) */ + $postUrl = ''; + $info = fws_bugs_discord_webhook_info(); + if (is_array($info) && !empty($info['guild_id'])) { + $postUrl = 'https://discord.com/channels/' . $info['guild_id'] . '/' . $threadId; + } + + /* ── Logs par morceaux (1900 car. max, 12 messages max) ── */ + $logs = trim((string) ($bug['logs'] ?? '')); + if ($logs !== '') { + /* L'API accepte des logs de taille illimitée : on découpe donc à la + volée et on s'arrête dès que le quota de messages est atteint, au + lieu de construire le tableau complet en mémoire. */ + $msgUrl = $base . '?thread_id=' . $threadId; + $maxMsgs = 12; + $sent = 0; + $cur = ''; + foreach (preg_split('/\r?\n/', $logs) as $line) { + if ($cur !== '' && mb_strlen($cur) + mb_strlen($line) + 1 > 1850) { + if (!fws_bugs_discord_send_log_chunk($msgUrl, $cur)) { + break; // Discord refuse → on s'arrête proprement + } + $cur = ''; + if (++$sent >= $maxMsgs) { + break; + } + } + $cur .= ($cur === '' ? '' : "\n") . $line; + } + if ($cur !== '' && $sent < $maxMsgs) { + fws_bugs_discord_send_log_chunk($msgUrl, $cur); + } + } + + return ['thread_id' => $threadId, 'post_url' => $postUrl]; +} + +/** + * Préviens Discord quand le statut d'un signalement change sur le site. + * Poste un message dans le fil, et met à jour le tag si un bot est configuré. + * + * @param array $bug id, thread_id, old_status, new_status, actor + */ +function fws_bugs_discord_status_change(array $bug): void +{ + $cfg = fws_bugs_discord_config(); + $threadId = trim((string) ($bug['thread_id'] ?? '')); + if ($cfg['webhook'] === '' || $threadId === '') { + return; + } + + $old = isset(FWS_BUGS_STATUS_LABELS[$bug['old_status'] ?? '']) ? FWS_BUGS_STATUS_LABELS[$bug['old_status']] : (string) ($bug['old_status'] ?? '?'); + $new = isset(FWS_BUGS_STATUS_LABELS[$bug['new_status'] ?? '']) ? FWS_BUGS_STATUS_LABELS[$bug['new_status']] : (string) ($bug['new_status'] ?? '?'); + $actor = trim((string) ($bug['actor'] ?? '')); + + $msg = '📌 **Statut mis à jour** : ' . $old . ' → **' . $new . '**'; + if ($actor !== '') { + $msg .= "\nPar : " . $actor; + } + fws_bugs_discord_api('POST', $cfg['webhook'] . '?thread_id=' . $threadId, ['content' => mb_substr($msg, 0, 1900)]); + + /* Mise à jour du tag : possible seulement avec un bot (MANAGE_THREADS) */ + if ($cfg['bot_token'] !== '') { + $info = fws_bugs_discord_webhook_info(); + $channelId = is_array($info) ? (string) ($info['channel_id'] ?? '') : ''; + $tags = fws_bugs_discord_ensure_tags(); + $newStatus = (string) ($bug['new_status'] ?? ''); + if ($channelId !== '' && isset($tags[$newStatus])) { + fws_bugs_discord_api( + 'PUT', + 'https://discord.com/api/channels/' . $channelId . '/threads/' . $threadId . '/applied-tags', + ['applied_tags' => [$tags[$newStatus]]], + 'Bot ' . $cfg['bot_token'] + ); + } + } +} \ No newline at end of file diff --git a/api/packages.php b/api/packages.php new file mode 100644 index 0000000..d727384 --- /dev/null +++ b/api/packages.php @@ -0,0 +1,31 @@ +getMessage()); + http_response_code(500); + header('Content-Type: application/json; charset=utf-8'); + echo json_encode(['ok' => false, 'error' => 'Erreur base de données.']); + exit; +} + +header('Content-Type: application/json; charset=utf-8'); +header('Access-Control-Allow-Origin: *'); +echo json_encode($packages, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); \ No newline at end of file diff --git a/inc/errors.php b/inc/errors.php new file mode 100644 index 0000000..7ef4b8b --- /dev/null +++ b/inc/errors.php @@ -0,0 +1,243 @@ +) sont forcément à la racine. + Sinon, on est servi depuis un sous-dossier (WAMP : /FWS-Website). */ + if (preg_match('~/((?:inc|api|admin|cache)|p/(?:index|dl|paquets|equipe|contact|assets))(?:/|$)~', $dir, $m)) { + $base = substr($dir, 0, (int) strrpos($dir, $m[0])); + } else { + $base = $dir; + } + return $base; + } +} + +if (!function_exists('fws_url')) { + /** URL d'une route ou d'un asset local, préfixée par la base URL. */ + function fws_url(string $path): string + { + if ($path === '' || preg_match('~^(?:[a-z][a-z0-9+.-]*:|//)~i', $path)) { + return $path; /* absolu, mailto:, tel:, //… : inchangé */ + } + $base = fws_base_url(); + if ($base !== '' && ($path === $base || str_starts_with($path, $base . '/'))) { + return $path; /* déjà préfixé (idempotence) */ + } + return $base . '/' . ltrim($path, '/'); + } +} + +/* En CLI (scripts d'administration dans le conteneur), on affiche tout : + * c'est interactif, l'opérateur doit voir les problèmes. */ +if (PHP_SAPI === 'cli') { + ini_set('display_errors', '1'); +} + +/* ── Portabilité : polyfills mbstring ────────────────────────────────────── + * L'extension mbstring est absente de certaines installations PHP de Windows + * (et de quelques images Docker minimales). Le site doit tourner quand même : + * on fournit des équivalents UTF-8 corrects pour les 4 fonctions mb_* du + * projet. Si mbstring est présente (cas Linux standard), on n'y touche pas. + */ +if (!function_exists('mb_strlen')) { + function fws_mb_chars(string $s): array + { + $c = preg_split('//u', $s, -1, PREG_SPLIT_NO_EMPTY); + return is_array($c) ? $c : ((str_split($s) === false) ? [] : str_split($s)); + } + function mb_strlen(string $s, ?string $enc = null): int + { + return count(fws_mb_chars($s)); + } + function mb_substr(string $s, int $start, ?int $len = null, ?string $enc = null): string + { + $c = fws_mb_chars($s); + $n = count($c); + if ($start < 0) { + $start = max(0, $n + $start); + } + if ($len === null) { + $len = $n; + } elseif ($len < 0) { + $len = max(0, $n - $start + $len); + } + return implode('', array_slice($c, $start, $len)); + } + function mb_check_encoding(string $s, ?string $enc = null): bool + { + return (bool) preg_match('//u', $s); + } + function mb_convert_encoding(string $s, string $to, ?string $from = null): string + { + if (function_exists('iconv') && strcasecmp($to, 'UTF-8') === 0) { + $conv = @iconv((string) $from, 'UTF-8//TRANSLIT//IGNORE', $s); + if (is_string($conv)) { + return $conv; + } + } + /* Dernier recours : on retire les octets qui cassent l'UTF-8. */ + $clean = preg_replace('/[\x80-\xFF]+/', '?', $s); + return is_string($clean) ? $clean : $s; + } +} + +/* Journal : api/bugs/data/ (déjà interdit au web par .htaccess + gitigné). */ +$fwsErrorLogDir = dirname(__DIR__) . '/api/bugs/data'; +if (!is_dir($fwsErrorLogDir)) { + @mkdir($fwsErrorLogDir, 0770, true); +} +if (is_dir($fwsErrorLogDir) && is_writable($fwsErrorLogDir)) { + ini_set('error_log', $fwsErrorLogDir . '/php-errors.log'); +} +unset($fwsErrorLogDir); + +/* ── 3. Réponses d'erreur propres ──────────────────────────────────────── */ + +if (!function_exists('fws_error_wants_json')) { + + /** + * Le client attend-il du JSON ? + * + * Un navigateur (navigation réelle) demande explicitement du HTML + * (« Accept: text/html, … ») → il recevra une page visuelle. + * Tout le reste — curl (Accept générique), scripts, apps, appels fetch() + * ou clients qui annoncent du JSON — reçoit du JSON. + */ + function fws_error_wants_json(): bool + { + $accept = strtolower((string) ($_SERVER['HTTP_ACCEPT'] ?? '')); + if (str_contains($accept, 'text/html')) { + return false; /* navigateur → page visuelle */ + } + return true; /* curl, scripts, API clients → JSON */ + } + + /** + * Réponse d'erreur finale : JSON ou page HTML minimaliste, sans aucun + * détail technique. Ne fait rien si les en-têtes sont déjà partis. + */ + function fws_error_render(int $status, string $message): void + { + if (headers_sent()) { + return; /* trop tard pour propre : on referme silencieusement */ + } + + http_response_code($status); + + if (fws_error_wants_json()) { + header('Content-Type: application/json; charset=utf-8'); + header('X-Content-Type-Options: nosniff'); + header('Cache-Control: no-store'); + echo json_encode(['ok' => false, 'error' => $message], JSON_UNESCAPED_UNICODE); + return; + } + + header('Content-Type: text/html; charset=utf-8'); + header('Cache-Control: no-store'); + $msg = htmlspecialchars($message, ENT_QUOTES, 'UTF-8'); + echo << + + + + + +Erreur | FWS Linux + + + +
+

Oups…

+

{$msg}

+ Retour à l'accueil +
+ + +HTML; + } +} + +if (!function_exists('fws_error_install')) { + + /** Pose les handlers (une seule fois, jamais en CLI). */ + function fws_error_install(): void + { + static $installed = false; + if ($installed || PHP_SAPI === 'cli') { + return; + } + $installed = true; + + /* Exception non interceptée → 500 propre. */ + set_exception_handler(static function (Throwable $e): void { + error_log('[fws] exception non interceptée : ' . $e->getMessage() + . ' — ' . $e->getFile() . ':' . $e->getLine()); + fws_error_render(500, 'Une erreur inattendue est survenue. Merci de réessayer plus tard.'); + }); + + /* Erreur fatale (mémoire, parse, include manquant…) → 500 propre. + * NB : les warnings/notices restent simplement journalisés — on ne + * les transforme pas en exceptions pour ne pas casser les pages. */ + register_shutdown_function(static function (): void { + $e = error_get_last(); + if ($e === null) { + return; + } + $fatals = [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR]; + if (!in_array((int) $e['type'], $fatals, true)) { + return; + } + error_log('[fws] erreur fatale : ' . $e['message'] + . ' — ' . $e['file'] . ':' . $e['line']); + fws_error_render(500, 'Une erreur inattendue est survenue. Merci de réessayer plus tard.'); + }); + } +} + +fws_error_install(); diff --git a/inc/site.php b/inc/site.php new file mode 100644 index 0000000..f57c5a9 --- /dev/null +++ b/inc/site.php @@ -0,0 +1,625 @@ +) : chaque mise + * à jour d'un CSS/JS est immédiatement re-téléchargée par les navigateurs, + * au lieu d'être bloquée par le cache « 7 jours » du .htaccess. + */ +function fws_asset(string $path): string +{ + $abs = FWS_SITE_ROOT . $path; + $mtime = @filemtime($abs); + return fws_url($path) . ($mtime ? '?v=' . $mtime : ''); +} + +/* fws_utf8_str / fws_utf8_arr sont définies dans api/bugs/db.php (chargé + ci-dessous via fws_site_db()) avec des gardes function_exists : elles + sont donc disponibles quel que soit l'ordre d'inclusion. */ + +/** Date ISO → « 29 août 2026 » (ou la valeur brute si non parsable). */ +function fws_format_date(?string $iso): string +{ + if ($iso === null || trim($iso) === '') { + return ''; + } + static $mois = [ + 1 => 'janvier', 'février', 'mars', 'avril', 'mai', 'juin', + 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre', + ]; + try { + $d = new DateTimeImmutable($iso); + return trim($d->format('j')) . ' ' . $mois[(int) $d->format('n')] . ' ' . $d->format('Y'); + } catch (Throwable $e) { + return $iso; + } +} + +/* ───────────────────────── paquets (base SQLite) ───────────────────────── */ + +/** + * Connexion à la base du site (celle des bugs, partagée). Renvoie null si la + * base n'est pas disponible : le site doit rester fonctionnel sans DB. + */ +function fws_site_db(): ?PDO +{ + static $pdo = null; + static $failed = false; + if ($pdo instanceof PDO || $failed) { + return $failed ? null : $pdo; + } + try { + require_once __DIR__ . '/../api/bugs/db.php'; + $pdo = fws_bugs_db(); + } catch (Throwable $e) { + error_log('[fws-site] base indisponible : ' . $e->getMessage()); + $failed = true; + return null; + } + return $pdo; +} + +/** + * Paquets du site : base SQLite (source de vérité, éditable dans /admin/bugs) + * avec repli sur p/paquets/packages.json si la base est vide ou absente. + * Chaque entrée est nettoyée (UTF-8 valide) pour ne jamais casser json_encode + * ni le rendu HTML. + */ +function fws_site_packages(): array +{ + static $cache = null; + if ($cache !== null) { + return $cache; + } + + $out = []; + + $pdo = fws_site_db(); + if ($pdo !== null) { + try { + $has = $pdo->query( + "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='packages'" + )->fetchColumn(); + if ((int) $has > 0) { + foreach ($pdo->query('SELECT * FROM packages ORDER BY id ASC') as $r) { + $out[] = fws_site_package_row($r); + } + } + } catch (Throwable $e) { + error_log('[fws-site] lecture paquets : ' . $e->getMessage()); + } + } + + /* Repli : l'ancien fichier JSON (avant la DB, ou base vide). */ + if ($out === []) { + /* dbId = 0 : les URLs /?p/paquets/N/ se rabattent sur la position. */ + $file = FWS_SITE_ROOT . '/p/paquets/packages.json'; + if (is_file($file)) { + $data = json_decode((string) file_get_contents($file), true); + if (is_array($data)) { + foreach ($data as $p) { + if (is_array($p)) { + $out[] = fws_site_package_shape($p); + } + } + } + } + } + + /* Release + historique tirés de Gitea (URL des liens du paquet). */ + foreach ($out as $i => $pkg) { + $out[$i] = fws_site_package_with_releases($pkg); + } + + $cache = $out; + return $cache; +} + +/** Normalise un paquet quelconque (JSON ou DB) vers la forme du site. + * « dbId » = identifiant en base (0 si venant du fichier JSON de repli) : + * c'est lui qui pilote les URLs /?p/paquets/N/. */ +function fws_site_package_shape(array $p): array +{ + return fws_utf8_arr([ + 'id' => (string) ($p['id'] ?? ''), + 'name' => (string) ($p['name'] ?? ''), + 'tagline' => (string) ($p['tagline'] ?? ''), + 'description' => (string) ($p['description'] ?? ''), + 'since' => (string) ($p['since'] ?? '') !== '' ? (string) $p['since'] : null, + 'sinceLabel' => (string) ($p['sinceLabel'] ?? 'FWS'), + 'latest' => isset($p['latest']) && is_array($p['latest']) + ? [ + 'name' => (string) ($p['latest']['name'] ?? ''), + 'date' => (string) ($p['latest']['date'] ?? '') !== '' ? (string) $p['latest']['date'] : null, + ] + : null, + 'links' => is_array($p['links'] ?? null) ? array_values($p['links']) : [], + 'screens' => is_array($p['screens'] ?? null) ? array_values($p['screens']) : [], + 'changelog' => is_array($p['changelog'] ?? null) ? array_values($p['changelog']) : [], + 'dbId' => (int) ($p['dbId'] ?? 0), + ]); +} + +/** Ligne brute DB → forme du site (même format que l'ancien packages.json). */ +function fws_site_package_row(array $r): array +{ + return fws_site_package_shape([ + 'dbId' => (int) ($r['id'] ?? 0), + 'id' => $r['slug'] ?? '', + 'name' => $r['name'] ?? '', + 'tagline' => $r['tagline'] ?? '', + 'description' => $r['description'] ?? '', + 'since' => $r['since'] ?? null, + 'sinceLabel' => $r['since_label'] ?? 'FWS', + 'latest' => [ + 'name' => $r['latest_name'] ?? '', + 'date' => $r['latest_date'] ?? '', + ], + 'links' => json_decode((string) ($r['links'] ?? '[]'), true) ?: [], + 'screens' => json_decode((string) ($r['screens'] ?? '[]'), true) ?: [], + 'changelog' => json_decode((string) ($r['changelog'] ?? '[]'), true) ?: [], + ]); +} + +/** + * Enrichit un paquet avec les releases Gitea (à partir de l'URL « Releases » + * ou « Gitea » de ses liens) : latest + changelog réels, en cache fichier. + */ +function fws_site_package_with_releases(array $pkg): array +{ + $repo = fws_site_gitea_repo_from_links($pkg['links'] ?? []); + if ($repo === null) { + return $pkg; + } + + $releases = fws_site_gitea_releases($repo['owner'], $repo['name']); + if ($releases === []) { + /* Pas de release Gitea : on garde latest/changelog de la DB. */ + return $pkg; + } + + $first = $releases[0]; + $pkg['latest'] = [ + 'name' => (string) ($first['tag_name'] ?? ''), + 'date' => isset($first['published_at']) ? substr((string) $first['published_at'], 0, 10) : null, + ]; + + $changelog = []; + foreach ($releases as $rel) { + $notes = trim(strip_tags((string) fws_markdown((string) ($rel['body'] ?? '')))); + if (mb_strlen($notes) > 200) { + $notes = rtrim(mb_substr($notes, 0, 200)) . '…'; + } + $changelog[] = [ + 'version' => (string) ($rel['tag_name'] ?? ''), + 'date' => isset($rel['published_at']) ? substr((string) $rel['published_at'], 0, 10) : null, + 'notes' => $notes !== '' ? $notes : '', + ]; + } + $pkg['changelog'] = $changelog; + + return $pkg; +} + +/** Trouve owner/name du dépôt Gitea dans les liens d'un paquet (null sinon). */ +function fws_site_gitea_repo_from_links(array $links): ?array +{ + foreach ($links as $link) { + $url = (string) ($link['url'] ?? ''); + if (preg_match('~^https?://gitea\.nocode-var\.tech/([^/]+)/([^/]+)/?$~i', $url, $m)) { + return ['owner' => $m[1], 'name' => $m[2]]; + } + } + return null; +} + +/* ───────────────────────── HTTP + cache fichier ───────────────────────── */ + +/** GET JSON avec cache fichier (cache/ gitignoré) ; [] en cas d'échec. */ +function fws_site_fetch_json(string $url, array $headers = []): array +{ + $key = 'http_' . sha1($url); + $file = FWS_SITE_CACHE_DIR . '/' . $key . '.json'; + + if (is_file($file) && (time() - (int) filemtime($file)) < FWS_SITE_CACHE_TTL) { + $data = json_decode((string) file_get_contents($file), true); + if (is_array($data)) { + return $data; + } + } + + $cacheOk = is_dir(FWS_SITE_CACHE_DIR) || @mkdir(FWS_SITE_CACHE_DIR, 0777, true); + if ($cacheOk && !is_writable(FWS_SITE_CACHE_DIR)) { + @chmod(FWS_SITE_CACHE_DIR, 0777); + $cacheOk = is_writable(FWS_SITE_CACHE_DIR); + } + + $data = []; + if (function_exists('curl_init')) { + $ch = curl_init($url); + $allHeaders = ['Accept: application/json', 'User-Agent: FWS-Linux-Website']; + foreach ($headers as $h) { + $allHeaders[] = $h; + } + curl_setopt_array($ch, [ + CURLOPT_RETURNTRANSFER => true, + CURLOPT_TIMEOUT => 8, + CURLOPT_CONNECTTIMEOUT => 4, + CURLOPT_HTTPHEADER => $allHeaders, + CURLOPT_FOLLOWLOCATION => true, + ]); + $body = curl_exec($ch); + $code = (int) curl_getinfo($ch, CURLINFO_RESPONSE_CODE); + curl_close($ch); + if (is_string($body) && $code >= 200 && $code < 300) { + $decoded = json_decode($body, true); + if (is_array($decoded)) { + $data = $decoded; + } + } + } + + if (!$cacheOk) { + /* Répertoire de cache non accessible (droits) : on répond quand même, + simplement sans persistance entre les requêtes. */ + return $data; + } + + if ($data !== []) { + @file_put_contents($file, json_encode($data, JSON_UNESCAPED_UNICODE), LOCK_EX); + } elseif (is_file($file)) { + /* API injoignable : on sert le dernier cache connu (périmé mais mieux que rien). */ + $data = json_decode((string) file_get_contents($file), true) ?: []; + } + + return $data; +} + +/** Releases d'un dépôt Gitea (les plus récentes d'abord). */ +function fws_site_gitea_releases(string $owner, string $name): array +{ + static $memo = []; + $key = $owner . '/' . $name; + if (isset($memo[$key])) { + return $memo[$key]; + } + $url = 'https://gitea.nocode-var.tech/api/v1/repos/' + . rawurlencode($owner) . '/' . rawurlencode($name) . '/releases?limit=10'; + $data = fws_site_fetch_json($url); + $out = []; + /* L'API renvoie un tableau, ou {message:...} si le dépôt n'existe pas. */ + if (isset($data[0]) && is_array($data[0]) && isset($data[0]['tag_name'])) { + foreach ($data as $rel) { + if (is_array($rel) && isset($rel['tag_name'])) { + $out[] = $rel; + } + } + } + $memo[$key] = $out; + return $out; +} + +/* ───────────────────────── releases ISO (page Téléchargements) ─────────── */ + +/** + * Releases de l'ISO pour la page Téléchargements : Gitea FWS/ISO s'il existe, + * sinon GitHub (comme avant). Renvoie ['mode' => 'gitea'|'github'|'none', 'items' => [...]]. + */ +function fws_site_iso_releases(): array +{ + $gitea = fws_site_gitea_releases('FWS', 'ISO'); + if ($gitea !== []) { + return ['mode' => 'gitea', 'items' => $gitea]; + } + + $gh = fws_site_fetch_json( + 'https://api.github.com/repos/You-re-like-Windows-a-bitch/ISO/releases?per_page=6', + ['Accept: application/vnd.github+json'] + ); + if (isset($gh[0]) && is_array($gh[0]) && isset($gh[0]['tag_name'])) { + return ['mode' => 'github', 'items' => $gh]; + } + + $tags = fws_site_fetch_json( + 'https://api.github.com/repos/You-re-like-Windows-a-bitch/ISO/tags?per_page=6', + ['Accept: application/vnd.github+json'] + ); + if (isset($tags[0]) && is_array($tags[0]) && isset($tags[0]['name'])) { + return ['mode' => 'tags', 'items' => $tags]; + } + + return ['mode' => 'none', 'items' => []]; +} + +/** Libellé d'une release (Gitea : « name » sinon tag ; GitHub : idem). */ +function fws_site_release_label(array $rel): string +{ + $name = trim((string) ($rel['name'] ?? '')); + $tag = (string) ($rel['tag_name'] ?? ($rel['ref'] ?? '')); + return $name !== '' ? $name : ($tag !== '' ? $tag : 'Sans nom'); +} + +/** URL de téléchargement directe d'une release (asset .iso sinon page). */ +function fws_site_release_download_url(array $rel): string +{ + $assets = $rel['assets'] ?? []; + if (is_array($assets)) { + foreach ($assets as $asset) { + if (is_array($asset) + && preg_match('/\.iso$/i', (string) ($asset['name'] ?? '')) + && isset($asset['browser_download_url'])) { + return (string) $asset['browser_download_url']; + } + } + foreach ($assets as $asset) { + if (is_array($asset) && isset($asset['browser_download_url'])) { + return (string) $asset['browser_download_url']; + } + } + } + return (string) ($rel['html_url'] ?? ($rel['zipball_url'] ?? '#')); +} + +/** Date de publication d'une release (date ISO brute, sans l'heure). */ +function fws_site_release_date(array $rel): ?string +{ + foreach (['published_at', 'created_at'] as $k) { + if (!empty($rel[$k])) { + return substr((string) $rel[$k], 0, 10); + } + } + return null; +} + +/* ───────────────────────── Markdown (portage PHP de downloads.js) ──────── */ + +function fws_md_escape(string $t): string +{ + return htmlspecialchars($t, ENT_NOQUOTES, 'UTF-8'); +} + +function fws_md_inline(string $t): string +{ + $t = fws_md_escape($t); + $t = preg_replace('/\*\*\*(.+?)\*\*\*/s', '$1', $t) ?? $t; + $t = preg_replace('/\*\*(.+?)\*\*/s', '$1', $t) ?? $t; + $t = preg_replace('/\*(.+?)\*/s', '$1', $t) ?? $t; + $t = preg_replace('/`([^`]+)`/', '$1', $t) ?? $t; + $t = preg_replace('/!\[([^\]]*)\]\(([^)\s]+)\)/', '$1', $t) ?? $t; + $t = preg_replace('/\[([^\]]+)\]\(([^)\s]+)\)/', '$1', $t) ?? $t; + return $t; +} + +/** Rendu Markdown minimal (titres, listes, tables, citations, code…) + sanitisé. */ +function fws_markdown(string $md): string +{ + if (trim($md) === '') { + return ''; + } + + $lines = preg_split('/\r?\n/', $md) ?: []; + $html = ''; + $inCode = false; + $code = ''; + $codeLang = ''; + $listBuf = ''; + $listKind = ''; + $tableRows = []; + $tableHeader = true; + $quoteBuf = ''; + + $flushList = function () use (&$html, &$listBuf, &$listKind) { + if ($listBuf !== '') { + $html .= '<' . $listKind . ">\n" . $listBuf . '\n"; + $listBuf = ''; + $listKind = ''; + } + }; + $flushTable = function () use (&$html, &$tableRows, &$tableHeader) { + if ($tableRows !== []) { + $html .= "\n" . implode("\n", $tableRows) . "\n
\n"; + $tableRows = []; + $tableHeader = true; + } + }; + $flushQuote = function () use (&$html, &$quoteBuf) { + if ($quoteBuf !== '') { + $html .= '
' . $quoteBuf . "
\n"; + $quoteBuf = ''; + } + }; + $flushAll = function () use ($flushList, $flushTable, $flushQuote) { + $flushList(); + $flushTable(); + $flushQuote(); + }; + $cells = function (string $line): array { + $line = preg_replace('/^\|/', '', $line) ?? $line; + $line = preg_replace('/\|$/', '', $line) ?? $line; + return array_map('trim', explode('|', $line)); + }; + $isSep = function (string $line): bool { + return (bool) preg_match('/^\|?[\s|:\-]+\|?$/', $line) && strpos($line, '-') !== false; + }; + + foreach ($lines as $line) { + if (strncmp($line, '```', 3) === 0) { + $flushAll(); + if ($inCode) { + $langAttr = $codeLang !== '' ? ' class="language-' . e($codeLang) . '"' : ''; + $html .= '
' . fws_md_escape(trim($code)) . "
\n"; + $code = ''; + $codeLang = ''; + $inCode = false; + } else { + $inCode = true; + $codeLang = trim(substr($line, 3)); + } + continue; + } + + if ($inCode) { + $code .= ($code !== '' ? "\n" : '') . $line; + continue; + } + + if (trim($line) === '') { + $flushAll(); + continue; + } + + if (preg_match('/^(#{1,6})\s+(.+)$/', $line, $m)) { + $flushAll(); + $lvl = strlen($m[1]); + $html .= '' . fws_md_inline($m[2]) . '\n"; + continue; + } + + if (preg_match('/^[-*_]{3,}\s*$/', trim($line))) { + $flushAll(); + $html .= "
\n"; + continue; + } + + if (strncmp(ltrim($line), '>', 1) === 0) { + $flushList(); + $flushTable(); + $quoteBuf .= '

' . fws_md_inline((string) preg_replace('/^>\s?/', '', $line)) . '

'; + continue; + } + $flushQuote(); + + if (strpos($line, '|') !== false && !$isSep($line)) { + $flushList(); + $tag = $tableHeader ? 'th' : 'td'; + $row = ''; + foreach ($cells($line) as $c) { + $row .= '<' . $tag . '>' . fws_md_inline($c) . ''; + } + $row .= ''; + $tableRows[] = $row; + $tableHeader = false; + continue; + } + + if ($isSep($line)) { + $tableHeader = false; + continue; + } + + if (preg_match('/^(\s*)[-*+]\s+(.+)$/', $line, $m)) { + $flushTable(); + if ($listKind !== 'ul') { + $flushList(); + $listKind = 'ul'; + } + $listBuf .= '
  • ' . fws_md_inline($m[2]) . "
  • \n"; + continue; + } + + if (preg_match('/^(\s*)\d+\.\s+(.+)$/', $line, $m)) { + $flushTable(); + if ($listKind !== 'ol') { + $flushList(); + $listKind = 'ol'; + } + $listBuf .= '
  • ' . fws_md_inline($m[2]) . "
  • \n"; + continue; + } + + if ($listBuf !== '' && preg_match('/^\s{2,}/', $line)) { + $listBuf = (string) preg_replace('/<\/li>\n$/', ' ' . fws_md_inline(trim($line)) . "\n", $listBuf); + continue; + } + + $flushList(); + $flushTable(); + $html .= '

    ' . fws_md_inline($line) . "

    \n"; + } + + $flushAll(); + if ($inCode) { + $langAttr = $codeLang !== '' ? ' class="language-' . e($codeLang) . '"' : ''; + $html .= '
    ' . fws_md_escape(trim($code)) . "
    \n"; + } + + return fws_sanitize_html($html); +} + +/** Retire scripts/événements/URL javascript: du HTML généré côté serveur. */ +function fws_sanitize_html(string $html): string +{ + $html = (string) preg_replace('#<\s*(script|iframe|object|embed|link|style)\b[^>]*>.*?<\s*/\s*\1\s*>#is', '', $html); + $html = (string) preg_replace('#<\s*(script|iframe|object|embed|link|style)\b[^>]*/?>#i', '', $html); + $html = (string) preg_replace_callback( + '/\son\w+\s*=\s*("[^"]*"|\'[^\']*\'|[^\s>]+)/i', + static function ($m) { + return ''; + }, + $html + ); + $html = (string) preg_replace('/(href|src)\s*=\s*(["\'])\s*javascript:[^"\']*\2/i', '$1="#"', $html); + return $html; +} + +/** + * Tronque un rendu HTML vers ~N caractères de texte (portage de truncateHtml), + * sans couper au milieu d'une balise : on retire les blocs entiers en trop. + * Renvoie ['html' => …, 'truncated' => bool]. + */ +function fws_truncate_html(string $html, int $limit = 600): array +{ + $text = trim((string) preg_replace('/\s+/u', ' ', strip_tags($html))); + if (mb_strlen($text) <= $limit) { + return ['html' => $html, 'truncated' => false]; + } + + $blocks = preg_split('/(?=<)/', $html) ?: [$html]; + $acc = ''; + $count = 0; + $out = ''; + foreach ($blocks as $block) { + if ($block === '') { + continue; + } + $blockText = trim((string) preg_replace('/\s+/u', ' ', strip_tags($block))); + /* On ne coupe qu'avant un bloc porteur de texte : les blocs vides + (fermetures

    , …) suivent toujours leur ouverture, sinon + on produirait du HTML non fermé. */ + if ($blockText !== '' && $count > 0 && $count + mb_strlen($blockText) > $limit) { + break; + } + $out .= $block; + if ($blockText !== '') { + $count += mb_strlen($blockText); + } + } + if ($out === '') { + $out = '

    ' . e(mb_substr($text, 0, $limit)) . '…

    '; + return ['html' => $out, 'truncated' => true]; + } + return ['html' => $out, 'truncated' => true]; +} diff --git a/index.html b/index.html deleted file mode 100644 index 7296f41..0000000 --- a/index.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - Fws Web - - - - -
    - - -
    - -
    - -
    - -
    -
    - - - - - \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..386a399 --- /dev/null +++ b/index.php @@ -0,0 +1,8 @@ + +
    +
    + +

    Cette page a été débranchée

    +

    Tux a tiré un peu fort sur le câble RJ45… La page demandée n'existe pas ou a été déplacée. Le reste du réseau tient bon.

    + +
    + + +
    diff --git a/p/assets/img/hero/KDE.webp b/p/assets/img/hero/KDE.webp new file mode 100644 index 0000000..e8ba7e9 Binary files /dev/null and b/p/assets/img/hero/KDE.webp differ diff --git a/p/assets/img/hero/gnome.webp b/p/assets/img/hero/gnome.webp new file mode 100644 index 0000000..837024f Binary files /dev/null and b/p/assets/img/hero/gnome.webp differ diff --git a/p/assets/img/hero/hyprland.webp b/p/assets/img/hero/hyprland.webp new file mode 100644 index 0000000..382e08a Binary files /dev/null and b/p/assets/img/hero/hyprland.webp differ diff --git a/p/assets/img/hero/install.webp b/p/assets/img/hero/install.webp new file mode 100644 index 0000000..0a3b198 Binary files /dev/null and b/p/assets/img/hero/install.webp differ diff --git a/p/assets/img/hero/xfce.webp b/p/assets/img/hero/xfce.webp new file mode 100644 index 0000000..6a51965 Binary files /dev/null and b/p/assets/img/hero/xfce.webp differ diff --git a/p/assets/js/hero-carousel.js b/p/assets/js/hero-carousel.js new file mode 100644 index 0000000..fd64fb5 --- /dev/null +++ b/p/assets/js/hero-carousel.js @@ -0,0 +1,155 @@ +(() => { + "use strict"; + + const existingCleanup = window.__heroCarouselCleanup; + if (typeof existingCleanup === "function") { + existingCleanup(); + } + + const hero = document.querySelector(".hero-carousel"); + if (!hero) { + return; + } + + const slides = Array.from(hero.querySelectorAll("[data-hero-slide]")); + const prevButton = hero.querySelector("[data-hero-prev]"); + const nextButton = hero.querySelector("[data-hero-next]"); + const dotsContainer = hero.querySelector("[data-hero-dots]"); + + if (!slides.length || !prevButton || !nextButton || !dotsContainer) { + return; + } + + let currentIndex = Math.max( + 0, + slides.findIndex((slide) => slide.classList.contains("is-active")) + ); + let autoRotateTimer = null; + const rotateDelay = 5500; + const abortController = new AbortController(); + const { signal } = abortController; + + const dots = slides.map((_, index) => { + const dot = document.createElement("button"); + dot.type = "button"; + dot.className = "hero-dot"; + dot.setAttribute("role", "tab"); + dot.setAttribute("aria-label", `Aller a l'image ${index + 1}`); + dot.dataset.index = index.toString(); + dotsContainer.appendChild(dot); + return dot; + }); + + function updateUI() { + slides.forEach((slide, index) => { + const isActive = index === currentIndex; + slide.classList.toggle("is-active", isActive); + slide.setAttribute("aria-hidden", String(!isActive)); + }); + + dots.forEach((dot, index) => { + const isActive = index === currentIndex; + dot.classList.toggle("is-active", isActive); + dot.setAttribute("aria-selected", String(isActive)); + dot.tabIndex = isActive ? 0 : -1; + }); + } + + function goTo(index) { + if (index < 0) { + currentIndex = slides.length - 1; + } else if (index >= slides.length) { + currentIndex = 0; + } else { + currentIndex = index; + } + updateUI(); + } + + function stopAutoRotate() { + if (autoRotateTimer !== null) { + window.clearInterval(autoRotateTimer); + autoRotateTimer = null; + } + } + + function startAutoRotate() { + stopAutoRotate(); + autoRotateTimer = window.setInterval(() => { + goTo(currentIndex + 1); + }, rotateDelay); + } + + prevButton.addEventListener( + "click", + () => { + goTo(currentIndex - 1); + startAutoRotate(); + }, + { signal } + ); + + nextButton.addEventListener( + "click", + () => { + goTo(currentIndex + 1); + startAutoRotate(); + }, + { signal } + ); + + dotsContainer.addEventListener( + "click", + (event) => { + const button = event.target.closest(".hero-dot"); + if (!button) { + return; + } + + const targetIndex = Number.parseInt(button.dataset.index || "0", 10); + goTo(targetIndex); + startAutoRotate(); + }, + { signal } + ); + + hero.addEventListener( + "mouseenter", + () => { + stopAutoRotate(); + }, + { signal } + ); + + hero.addEventListener( + "mouseleave", + () => { + startAutoRotate(); + }, + { signal } + ); + + document.addEventListener( + "visibilitychange", + () => { + if (document.hidden) { + stopAutoRotate(); + } else { + startAutoRotate(); + } + }, + { signal } + ); + + updateUI(); + startAutoRotate(); + + window.__heroCarouselCleanup = () => { + stopAutoRotate(); + abortController.abort(); + }; + + document.addEventListener("page:before-route-change", window.__heroCarouselCleanup, { + once: true, + }); +})(); diff --git a/p/assets/js/not-found.js b/p/assets/js/not-found.js new file mode 100644 index 0000000..8daae56 --- /dev/null +++ b/p/assets/js/not-found.js @@ -0,0 +1,372 @@ +/** + * FWS Linux — animation de la page 404. + * + * Une seule fois, puis on s'arrête sur l'image finale : Tux s'approche du switch, + * saisit le câble RJ45 et tire (le connecteur sort du port, la LED passe au + * rouge, une pastille « link down » apparaît). Le coup de fil le déséquilibre : + * il tombe en arrière sur le fesse et reste assis, le câble toujours dans la + * main, tandis que le connecteur finit au sol au pied du switch. + * + * Tant qu'il est branché, le connecteur suit sa cible via un ressort + * sous-amorti ; une fois débranché il devient un point libre soumis à la gravité + * (rebond, frottement, torsion jusqu'à l'arrêt à plat). Le tracé du câble est + * recalculé à chaque image : le mou, le balancement et la traînée au sol en + * découlent. + * + * Sans JavaScript, la scène reste dans son état « branché » défini dans le SVG. + */ +(function () { + 'use strict'; + + var svg = document.querySelector('.nf-scene'); + if (!svg) { + return; + } + + var el = { + switchBox: svg.querySelector('#nf-switch'), + shadow: svg.querySelector('#nf-shadow'), + tux: svg.querySelector('#nf-tux'), + arm: svg.querySelector('#nf-arm'), + connector: svg.querySelector('#nf-connector'), + cables: svg.querySelectorAll('.nf-cable'), + ledGreen: svg.querySelectorAll('.nf-led-green'), + ledRed: svg.querySelectorAll('.nf-led-red'), + badge: svg.querySelector('#nf-badge'), + spark: svg.querySelector('#nf-spark'), + footL: svg.querySelector('#nf-foot-l'), + footR: svg.querySelector('#nf-foot-r'), + eyes: svg.querySelector('#nf-eyes') + }; + + if (!el.tux || !el.arm || !el.connector || !el.cables.length) { + return; + } + + /* Géométrie — doit rester synchronisée avec le dessin dans p/404.php. */ + var G = { + walk: [215, 358], // pivot de la marche, entre les deux pattes + hip: [215, 322], // fesse : pivot de la chute en arrière + shoulder: [265, 250], + hand: [304, 256], + footL: [168, 346], // chevilles : pivot de la contre-rotation des pattes + footR: [262, 346], + plugPivot: [555, 236], + connAttach: [534, 236], + ground: 374 + }; + + /* Pose finale : assis, dos voûté, câble toujours en main. Les valeurs sont + calées pour que le bas du corps touche le sol et que la tête reste dans le + cadre (viewBox 0 0 720 440). */ + var SIT = { deg: -32, x: -20, y: -10, arm: -24, foot: 50, footDropL: 6, footDropR: 62 }; + + /* Timeline (ms) : tout se joue une fois, puis l'image finale reste. */ + var APPROACH_A = 700, APPROACH_B = 1500; + var PULL_A = 1800; + /* La chute part exactement du décrochage : plus de temps mort entre les deux. */ + var RELEASE = 2900, FALL_A = RELEASE, FALL_B = 4050; + var TOTAL = 5500; + + var APPROACH_X = 14, PULL_X = 22, STUMBLE_X = 18; + var GRAVITY = 1600; + + /* ── Helpers ─────────────────────────────────────────────────────────── */ + + function clamp01(x) { return x < 0 ? 0 : (x > 1 ? 1 : x); } + function lerp(a, b, k) { return a + (b - a) * k; } + function smoothstep(e0, e1, x) { + var t = clamp01((x - e0) / (e1 - e0)); + return t * t * (3 - 2 * t); + } + function easeInOut(t) { + return t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2; + } + + function mul(A, B) { + return [ + A[0] * B[0] + A[2] * B[1], + A[1] * B[0] + A[3] * B[1], + A[0] * B[2] + A[2] * B[3], + A[1] * B[2] + A[3] * B[3], + A[0] * B[4] + A[2] * B[5] + A[4], + A[1] * B[4] + A[3] * B[5] + A[5] + ]; + } + function tr(x, y) { return [1, 0, 0, 1, x, y]; } + function rot(deg, cx, cy) { + var r = deg * Math.PI / 180, c = Math.cos(r), s = Math.sin(r); + return [c, s, -s, c, cx - c * cx + s * cy, cy - s * cx - c * cy]; + } + function apply(m, x, y) { return [m[0] * x + m[2] * y + m[4], m[1] * x + m[3] * y + m[5]]; } + function tx(x, y, deg, px, py) { + return 'translate(' + x.toFixed(2) + ' ' + y.toFixed(2) + ')' + + (deg ? ' rotate(' + deg.toFixed(2) + ' ' + px.toFixed(1) + ' ' + py.toFixed(1) + ')' : ''); + } + function setOpacity(list, value) { + for (var i = 0; i < list.length; i++) { + list[i].setAttribute('opacity', value.toFixed(3)); + } + } + function setCable(d) { + for (var i = 0; i < el.cables.length; i++) { + el.cables[i].setAttribute('d', d); + } + } + + /* ── État persistant ─────────────────────────────────────────────────── */ + + var springX = 0, springV = 0; // connecteur tant qu'il est dans le port + var gait = 0; + var released = false; // le connecteur est-il tombé ? + var plug = { x: 0, y: 0, vx: 0, vy: 0, rest: false }; + var connDeg = 0, connDegV = 0; + + function springStep(pos, vel, target, k, d, dt) { + var acc = -k * (pos - target) - d * vel; + vel += acc * dt; + pos += vel * dt; + return [pos, vel]; + } + + /* Chute du connecteur : gravité, rebond amorti, frottement au sol. */ + function fallPoint(pt, dt) { + if (pt.rest) { + return; + } + pt.vy += GRAVITY * dt; + pt.vx *= 0.995; + pt.x += pt.vx * dt; + pt.y += pt.vy * dt; + if (pt.y >= G.ground) { + pt.y = G.ground; + if (pt.vy > 40) { + pt.vy = -pt.vy * 0.34; // rebond + pt.vx *= 0.55; + } else { + pt.vy = 0; + } + pt.vx *= 0.84; // frottement + if (Math.abs(pt.vx) < 7 && Math.abs(pt.vy) < 1) { + pt.vx = 0; + pt.rest = true; + } + } + } + + /* ── Un pas d'animation ──────────────────────────────────────────────── */ + + function advance(t, dt) { + var approach = smoothstep(APPROACH_A, APPROACH_B, t); + + /* Courbe de traction : Tux tire, puis se laisse retomber en arrière. */ + var pull; + if (t <= PULL_A) { + pull = 0; + } else if (t < RELEASE) { + pull = easeInOut((t - PULL_A) / (RELEASE - PULL_A)); + } else if (t < FALL_A) { + pull = 1; + } else { + pull = 1 - 0.5 * clamp01((t - FALL_A) / (FALL_B - FALL_A)); + } + + /* Chute : de la station debout à la pose assise. Courbe rapide au départ + (il perd l'équilibre dès que le câble lâche), puis amortie à l'arrivée. */ + var fall = 1 - Math.pow(1 - clamp01((t - FALL_A) / (FALL_B - FALL_A)), 2.4); + + var sinceRel = (t - RELEASE) / 1000; + var yank = 0, yankRot = 0; + if (t >= RELEASE) { + yank = -11 * Math.sin(sinceRel * 27) * Math.exp(-sinceRel * 6.5); + yankRot = 3.4 * Math.sin(sinceRel * 27) * Math.exp(-sinceRel * 6.5); + } + /* Rebond d'assise : petit amorti au moment où le fesse touche le sol. */ + var sinceSit = (t - FALL_B) / 1000; + var settle = t > FALL_B ? 2 * Math.sin(sinceSit * 32) * Math.exp(-sinceSit * 4.5) : 0; + + var bob = Math.sin(t / 520) * 1.3 * (1 - fall); + /* L'élan : il se met à reculer pendant la traction, atteint son maximum à + l'instant du décrochage, puis s'amortit. C'est ce recul qui bascule le + poids du corps et déclenche la chute. */ + var slip = clamp01(1 - (t - RELEASE) / 900); + var standX = APPROACH_X * approach - PULL_X * pull - STUMBLE_X * slip + yank; + var standRot = 4 * approach - 11 * pull - 9 * slip + yankRot; + var standY = -1.5 * approach - 2 * pull + bob; + + /* Démarche : la phase avance avec la vitesse de déplacement. */ + var walk = smoothstep(APPROACH_A - 120, APPROACH_A + 260, t) + * (1 - smoothstep(APPROACH_B - 140, APPROACH_B + 200, t)) + * (1 - fall); + gait += dt * 8.5 * walk; + var swing = Math.sin(gait) * 8.5 * walk; + var liftL = Math.max(0, Math.sin(gait)) * 5.5 * walk; + var liftR = Math.max(0, Math.sin(gait + Math.PI)) * 5.5 * walk; + + /* Assis, les deux pattes sont posées à plat au sol devant le corps : on + compense la rotation du corps pour les remettre de niveau, et on les + descend d'autant pour qu'elles touchent terre. */ + var footSpin = SIT.foot * fall; + el.footL.setAttribute('transform', + tx(swing * 0.5, -liftL + SIT.footDropL * fall, footSpin, G.footL[0], G.footL[1])); + el.footR.setAttribute('transform', + tx(-swing * 0.5, -liftR + SIT.footDropR * fall, footSpin, G.footR[0], G.footR[1])); + + /* Corps : on interpole le pivot (pattes → fesse), l'angle et le décalage. */ + var pvX = lerp(G.walk[0], G.hip[0], fall); + var pvY = lerp(G.walk[1], G.hip[1], fall); + var ang = lerp(standRot, SIT.deg, fall) + settle; + var ox = lerp(standX, SIT.x, fall); + var oy = lerp(standY, SIT.y, fall); + var bodyTf = tx(ox, oy, ang, pvX, pvY); + + el.tux.setAttribute('transform', bodyTf); + + /* Aileron avant : tend le bras, puis garde le câble en l'air en s'asseyant. */ + var armRot = (16 * approach - 26 * pull) * (1 - fall) + SIT.arm * fall; + el.arm.setAttribute('transform', + bodyTf + ' rotate(' + armRot.toFixed(2) + ' ' + G.shoulder[0] + ' ' + G.shoulder[1] + ')'); + + /* L'ombre s'aplatit et se décale vers la fesse quand Tux se pose. */ + if (el.shadow) { + el.shadow.setAttribute('transform', + 'translate(' + (215 - 40 * fall).toFixed(1) + ' 376)' + + ' scale(1 ' + (1 - 0.5 * fall).toFixed(3) + ')' + + ' translate(-215 -376)'); + } + + /* Regard : vers le connecteur pendant la traction, vers le câble au sol + une fois assis. */ + var gx = 0, gy = 0; + if (t >= FALL_B) { gx = 3; gy = 2.5; } + else if (t >= RELEASE) { gx = 1.5; gy = -0.5; } + else if (t >= PULL_A) { gx = -1; gy = 0; } + if (el.eyes) { + el.eyes.setAttribute('transform', 'translate(' + gx + ' ' + gy + ')'); + } + + var bodyM = mul(tr(ox, oy), rot(ang, pvX, pvY)); + var armM = mul(bodyM, rot(armRot, G.shoulder[0], G.shoulder[1])); + var hand = apply(armM, G.hand[0], G.hand[1]); + + /* Connecteur : ressort vers sa cible tant qu'il est dans le port. */ + var sp = springStep(springX, springV, -34 * pull, 190, 15, dt); + springX = sp[0]; + springV = sp[1]; + var seated = [G.connAttach[0] + springX, G.connAttach[1]]; + + /* Point A = extrémité « connecteur » du câble ; point B = main de Tux. + Après le débranchement, A devient un point libre et B reste dans la main + jusqu'à la fin : c'est ce qui fait que Tux retombe en gardant le câble. */ + var A, B, deg; + if (t < RELEASE) { + A = seated; + B = hand; + deg = 0; + released = false; + } else { + if (!released) { + released = true; + plug.x = seated[0]; + plug.y = seated[1]; + plug.vx = springV * 0.4 - 150; + plug.vy = -30; + connDeg = 0; + connDegV = -140; + } + fallPoint(plug, dt); + connDegV += (-(connDeg - 6) * 95 - connDegV * 11) * dt; + connDeg += connDegV * dt; + A = [plug.x, plug.y]; + B = hand; + deg = connDeg; + } + + /* Connecteur : translation calculée pour amener son point d'attache en A. */ + var R = rot(deg, G.plugPivot[0], G.plugPivot[1]); + var ar = apply(R, G.connAttach[0], G.connAttach[1]); + el.connector.setAttribute('transform', + 'translate(' + (A[0] - ar[0]).toFixed(2) + ' ' + (A[1] - ar[1]).toFixed(2) + ')' + + ' rotate(' + deg.toFixed(2) + ' ' + G.plugPivot[0] + ' ' + G.plugPivot[1] + ')'); + + /* Câble : affaissement réduit quand il se tend, jamais sous le sol. */ + var dx = A[0] - B[0], dy = A[1] - B[1]; + var taut = clamp01((Math.sqrt(dx * dx + dy * dy) - 210) / 240); + var velWorld = released ? plug.vx : springV; + var wob = Math.max(-16, Math.min(16, velWorld * 0.05)); + var sway = 5 * Math.sin(t / 620) + 2 * Math.sin(t / 370 + 1.3); + var sag = 96 * (1 - 0.5 * taut) + (released ? 0 : sway); + var lim = G.ground - 3; + + var c1x = A[0] - 48 - 18 * taut; + var c1y = Math.min(lim, A[1] + sag); + var c2x = B[0] + (released ? 52 : 64); + var c2y = Math.min(lim, Math.min(lim, B[1] + sag * 0.85) + wob); + setCable('M ' + A[0].toFixed(2) + ' ' + A[1].toFixed(2) + + ' C ' + c1x.toFixed(2) + ' ' + c1y.toFixed(2) + + ', ' + c2x.toFixed(2) + ' ' + c2y.toFixed(2) + + ', ' + B[0].toFixed(2) + ' ' + B[1].toFixed(2)); + + /* LED : vert au départ, rouge clignotant une fois débranché */ + var greenA = clamp01(1 - smoothstep(RELEASE - 60, RELEASE + 40, t)); + var redA = (1 - greenA) * (0.55 + 0.45 * Math.abs(Math.sin(t / 90))); + setOpacity(el.ledGreen, greenA); + setOpacity(el.ledRed, redA); + + /* Pastille « link down » */ + var badgeA = smoothstep(RELEASE, RELEASE + 220, t); + el.badge.setAttribute('opacity', badgeA.toFixed(3)); + el.badge.setAttribute('transform', + 'translate(648 150) scale(' + (0.55 + 0.45 * badgeA).toFixed(3) + ') translate(-648 -150)'); + + /* Étincelle de débranchement */ + var sparkA = (t >= RELEASE && sinceRel < 0.55) ? Math.exp(-sinceRel * 7) : 0; + el.spark.setAttribute('opacity', sparkA.toFixed(3)); + el.spark.setAttribute('transform', + 'translate(557 228) scale(' + (0.7 + sinceRel * 1.6).toFixed(3) + ') translate(-557 -228)'); + + /* Secousse du switch */ + var jx = 0, jr = 0; + if (t >= RELEASE) { + jx = 4 * Math.sin(sinceRel * 32) * Math.exp(-sinceRel * 7); + jr = 0.55 * Math.sin(sinceRel * 32) * Math.exp(-sinceRel * 7); + } + el.switchBox.setAttribute('transform', tx(jx, 0, jr, 515, 206)); + } + + /* ── Lancement ───────────────────────────────────────────────────────── */ + + var reduceMotion = window.matchMedia + && window.matchMedia('(prefers-reduced-motion: reduce)').matches; + + if (reduceMotion || typeof window.requestAnimationFrame !== 'function') { + /* Accessibilité / vieux navigateurs : on saute directement à l'image finale. */ + var step = 1000 / 60; + for (var sim = 0; sim < TOTAL; sim += step) { + advance(sim, step / 1000); + } + advance(TOTAL, step / 1000); + return; + } + + var start = null; + var last = 0; + + function frame(now) { + if (start === null) { + start = now; + last = now; + } + var t = now - start; + var dt = Math.min(0.05, (now - last) / 1000) || 0.016; + last = now; + if (t >= TOTAL) { + advance(TOTAL, dt); // image finale, puis on s'arrête + return; + } + advance(t, dt); + window.requestAnimationFrame(frame); + } + + window.requestAnimationFrame(frame); +})(); diff --git a/p/assets/js/note-toggle.js b/p/assets/js/note-toggle.js new file mode 100644 index 0000000..3a535f2 --- /dev/null +++ b/p/assets/js/note-toggle.js @@ -0,0 +1,23 @@ +(() => { + const note = document.querySelector("[data-current-release-note]"); + const toggle = document.querySelector("[data-toggle-release-note]"); + if (!note || !toggle) return; + + const fullTemplate = note.querySelector("template[data-note-full]"); + if (!fullTemplate) return; + const fullHtml = fullTemplate.innerHTML; + const truncatedHtml = note.innerHTML; + + toggle.addEventListener("click", () => { + const expanded = toggle.dataset.expanded === "true"; + if (expanded) { + note.innerHTML = truncatedHtml; + toggle.textContent = "Voir plus"; + toggle.dataset.expanded = "false"; + } else { + note.innerHTML = fullHtml; + toggle.textContent = "Voir moins"; + toggle.dataset.expanded = "true"; + } + }); +})(); diff --git a/p/assets/js/packages-ui.js b/p/assets/js/packages-ui.js new file mode 100644 index 0000000..59562f5 --- /dev/null +++ b/p/assets/js/packages-ui.js @@ -0,0 +1,122 @@ +(() => { + /* Une seule exécution, même si le script est chargé deux fois. */ + if (window.__fwsPackagesUi) return; + window.__fwsPackagesUi = true; + + /* ── « Voir plus » de l'historique (liste des paquets) ── */ + document.addEventListener("click", (ev) => { + const btn = ev.target.closest("[data-toggle-timeline]"); + if (!btn) return; + const timeline = btn.closest(".paquet-changelog")?.querySelector("[data-expandable]"); + if (!timeline) return; + const expanded = btn.dataset.expanded === "true"; + timeline.classList.toggle("is-expanded", !expanded); + btn.dataset.expanded = expanded ? "false" : "true"; + btn.textContent = expanded ? (btn.dataset.label || "Voir plus") : "Voir moins"; + }); + + /* ── Popup central « aperçu de l'image » (page détail) ── */ + const zoomables = Array.from(document.querySelectorAll("img[data-zoom]")); + if (zoomables.length === 0) return; + + let overlay = null; + let imgEl = null; + let capEl = null; + let countEl = null; + let current = 0; + + function buildOverlay() { + if (overlay) return; + overlay = document.createElement("div"); + overlay.className = "pkg-lightbox"; + overlay.setAttribute("role", "dialog"); + overlay.setAttribute("aria-modal", "true"); + overlay.setAttribute("aria-label", "Aperçu de l'image"); + overlay.innerHTML = + '' + + '' + + '
    ' + + '' + + '
    ' + + '' + + '' + + "
    " + + "
    " + + ''; + document.body.appendChild(overlay); + + imgEl = overlay.querySelector(".pkg-lightbox-img"); + capEl = overlay.querySelector(".pkg-lightbox-caption"); + countEl = overlay.querySelector(".pkg-lightbox-count"); + + /* Navigation clavier pendant que le popup est ouvert. */ + document.addEventListener("keydown", (ev) => { + if (!overlay.classList.contains("is-open")) return; + if (ev.key === "Escape") { + ev.preventDefault(); + closeOverlay(); + } else if (ev.key === "ArrowLeft" && zoomables.length > 1) { + showImage(current - 1); + } else if (ev.key === "ArrowRight" && zoomables.length > 1) { + showImage(current + 1); + } + }); + } + + function showImage(index) { + current = (index + zoomables.length) % zoomables.length; + const src = zoomables[current]; + imgEl.src = src.currentSrc || src.src; + imgEl.alt = src.alt || ""; + const caption = src.dataset.caption || ""; + capEl.textContent = caption; + capEl.style.display = caption ? "" : "none"; + countEl.textContent = (current + 1) + " / " + zoomables.length; + countEl.style.display = zoomables.length > 1 ? "" : "none"; + + /* Relance l'animation d'apparition à chaque changement d'image. */ + const figure = overlay.querySelector(".pkg-lightbox-figure"); + figure.classList.remove("is-animating"); + void figure.offsetWidth; /* reflow : réinitialise l'animation CSS */ + figure.classList.add("is-animating"); + } + + function openOverlay(index) { + buildOverlay(); + showImage(index); + overlay.classList.add("is-open"); + document.documentElement.classList.add("pkg-no-scroll"); + } + + function closeOverlay() { + if (!overlay) return; + overlay.classList.remove("is-open"); + document.documentElement.classList.remove("pkg-no-scroll"); + } + + /* Un seul gestionnaire délégué : clic sur une image → ouverture ; + clic sur croix / flèches / fond → action correspondante. */ + document.addEventListener("click", (ev) => { + const zoom = ev.target.closest("img[data-zoom]"); + if (zoom) { + const idx = zoomables.indexOf(zoom); + if (idx >= 0) { + ev.preventDefault(); + openOverlay(idx); + } + return; + } + + if (!overlay || !overlay.classList.contains("is-open")) return; + + if (ev.target.closest("[data-lightbox-close]")) { + closeOverlay(); + } else if (ev.target.closest("[data-lightbox-prev]")) { + showImage(current - 1); + } else if (ev.target.closest("[data-lightbox-next]")) { + showImage(current + 1); + } else if (ev.target === overlay) { + closeOverlay(); /* clic sur le fond uniquement, pas sur l'image */ + } + }); +})(); diff --git a/p/assets/main-nav/app.js b/p/assets/main-nav/app.js deleted file mode 100644 index 3173bb4..0000000 --- a/p/assets/main-nav/app.js +++ /dev/null @@ -1,169 +0,0 @@ -(() => { - const main = document.getElementById("app-main"); - const footerYear = document.getElementById("footer-year"); - const pageStyleSelectors = "[data-page-style='true']"; - - const links = Array.from(document.querySelectorAll("[data-route]")); - - if (footerYear) { - footerYear.textContent = new Date().getFullYear().toString(); - } - - function clearInjectedPageStyles() { - document.querySelectorAll(pageStyleSelectors).forEach((node) => node.remove()); - } - - function injectPageStyles(parsedDocument, sourceUrl) { - clearInjectedPageStyles(); - - const head = parsedDocument.head; - if (!head) { - return; - } - - const styleNodes = Array.from(head.querySelectorAll("link[rel='stylesheet'], style")); - - styleNodes.forEach((node) => { - const clonedNode = node.cloneNode(true); - clonedNode.setAttribute("data-page-style", "true"); - - if (clonedNode.tagName === "LINK") { - const href = clonedNode.getAttribute("href"); - if (href) { - clonedNode.href = new URL(href, sourceUrl).toString(); - } - } - - document.head.appendChild(clonedNode); - }); - } - - function normalizeRoute(value) { - const raw = (value ?? "").toString().trim().toLowerCase(); - if (!raw || raw === "/" || raw === "home" || raw === "index" || raw === "accueil") { - return "index"; - } - return raw.replace(/^\/+|\/+$/g, "") || "index"; - } - - function routeFromLocation() { - const params = new URLSearchParams(window.location.search); - - if (params.has("p")) { - return normalizeRoute(params.get("p")); - } - - const rawSearch = window.location.search.replace(/^\?/, ""); - if (rawSearch.startsWith("p/")) { - return normalizeRoute(rawSearch.slice(2)); - } - - if (rawSearch.startsWith("p=")) { - return normalizeRoute(rawSearch.slice(2)); - } - - const path = window.location.pathname.replace(/^\/+|\/+$/g, ""); - if (path) { - if (path.endsWith(".html")) { - return "index"; - } - - const parts = path.split("/"); - if (parts[0] === "p" && parts[1]) { - return normalizeRoute(parts.slice(1).join("/")); - } - return normalizeRoute(parts[0]); - } - - return "index"; - } - - function setActiveRoute(route) { - links.forEach((link) => { - const isActive = link.dataset.route === route; - if (isActive) { - link.setAttribute("aria-current", "page"); - } else { - link.removeAttribute("aria-current"); - } - }); - } - - function setCanonicalUrl(route, replace = false) { - const url = route === "index" ? "/?p/index/" : `/?p/${route}/`; - if (replace) { - history.replaceState({ route }, "", url); - return; - } - history.pushState({ route }, "", url); - } - - function routeToSource(route) { - return `p/${route}/index.html`; - } - - function routeToTitle(route) { - if (route === "index") { - return "Fws Web"; - } - - const label = route - .split("/") - .filter(Boolean) - .map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)) - .join(" / "); - - return `Fws Web - ${label}`; - } - - async function loadRoute(route) { - const source = routeToSource(route); - const response = await fetch(source, { cache: "no-store" }); - if (!response.ok) { - throw new Error(`Impossible de charger ${source} (${response.status})`); - } - - const html = await response.text(); - const parsed = new DOMParser().parseFromString(html, "text/html"); - injectPageStyles(parsed, response.url); - const injected = parsed.querySelector("[data-page-content]") ?? parsed.body; - main.innerHTML = injected.innerHTML.trim(); - } - - function render(route, { replaceHistory = false } = {}) { - const safeRoute = route || "index"; - - loadRoute(safeRoute) - .then(() => { - setActiveRoute(safeRoute); - setCanonicalUrl(safeRoute, replaceHistory); - document.title = routeToTitle(safeRoute); - window.scrollTo({ top: 0, behavior: "smooth" }); - }) - .catch((error) => { - main.innerHTML = `

    Erreur de chargement

    ${error.message}

    `; - setActiveRoute("index"); - }); - } - - document.addEventListener("click", (event) => { - const link = event.target.closest("[data-route]"); - if (!link) { - return; - } - - const route = normalizeRoute(link.dataset.route); - if (!route) { - return; - } - - event.preventDefault(); - render(route); - }); - - window.addEventListener("popstate", () => { - render(routeFromLocation(), { replaceHistory: true }); - }); - - render(routeFromLocation(), { replaceHistory: true }); -})(); \ No newline at end of file diff --git a/p/assets/main-nav/nav.js b/p/assets/main-nav/nav.js new file mode 100644 index 0000000..436a747 --- /dev/null +++ b/p/assets/main-nav/nav.js @@ -0,0 +1,55 @@ +(() => { + /* Menu déroulant « Paquets » de la barre de navigation. + Le reste (contenu, données, états actifs) est rendu côté serveur. */ + const root = document.querySelector("[data-nav-dropdown]"); + const burger = document.querySelector(".nav-burger"); + const nav = document.getElementById("app-nav"); + + /* Burger mobile : plie/déplie le panneau de navigation */ + if (burger && nav) { + burger.addEventListener("click", () => { + const open = nav.classList.toggle("is-open"); + burger.setAttribute("aria-expanded", open ? "true" : "false"); + burger.setAttribute("aria-label", open ? "Fermer le menu de navigation" : "Ouvrir le menu de navigation"); + }); + + /* Navigation choisie → le panneau se referme */ + nav.querySelectorAll("a").forEach((link) => { + link.addEventListener("click", () => { + nav.classList.remove("is-open"); + burger.setAttribute("aria-expanded", "false"); + }); + }); + } + + if (!root) return; + + const toggle = root.querySelector(".nav-dropdown-toggle"); + const panel = root.querySelector(".nav-dropdown-panel"); + if (!toggle || !panel) return; + + function setOpen(open) { + root.classList.toggle("is-open", open); + toggle.setAttribute("aria-expanded", open ? "true" : "false"); + } + + toggle.addEventListener("click", (event) => { + event.stopPropagation(); + setOpen(!root.classList.contains("is-open")); + }); + + document.addEventListener("click", (event) => { + if (!root.contains(event.target)) setOpen(false); + }); + + document.addEventListener("keydown", (event) => { + if (event.key === "Escape" && root.classList.contains("is-open")) { + setOpen(false); + toggle.focus(); + } + }); + + panel.querySelectorAll("a").forEach((link) => { + link.addEventListener("click", () => setOpen(false)); + }); +})(); diff --git a/p/assets/main-styles/main.css b/p/assets/main-styles/main.css deleted file mode 100644 index 7904585..0000000 --- a/p/assets/main-styles/main.css +++ /dev/null @@ -1,129 +0,0 @@ -@import "./var.css"; - -.hero, -.card { - backdrop-filter: blur(18px); - background: var(--bg-soft); - box-shadow: var(--shadow); -} - -.hero { - padding: clamp(1.5rem, 3vw, 2.75rem); -} - -.eyebrow { - margin: 0 0 0.75rem; - color: var(--accent); - text-transform: uppercase; - letter-spacing: 0.22em; - font-size: 0.78rem; - font-weight: 700; -} - -.hero h1, -.card h2 { - font-family: "Georgia", "Palatino Linotype", serif; -} - -.hero h1 { - margin: 0; - font-size: clamp(2.2rem, 5vw, 4.5rem); - line-height: 0.98; - max-width: 12ch; -} - -.lead { - max-width: 62ch; - color: var(--muted); - font-size: 1.08rem; - line-height: 1.7; - margin: 1rem 0 0; -} - -.lead span, -.card span { - color: var(--text); -} - -.release-badge { - display: inline-flex; - align-items: center; - gap: 0.75rem; - margin: 1.35rem 0 0; - padding: 0.7rem 1rem; - border: 1px solid rgba(148, 163, 184, 0.22); - border-radius: 999px; - background: rgba(255, 255, 255, 0.04); - color: var(--muted); - font-size: 0.95rem; - font-weight: 700; -} - -.release-badge span { - color: var(--text); -} - -.hero-actions { - display: flex; - flex-wrap: wrap; - gap: 0.75rem; - margin-top: 1.5rem; -} - -.button { - display: inline-flex; - align-items: center; - justify-content: center; - padding: 0.85rem 1.2rem; - text-decoration: none; - border: 1px solid rgba(148, 163, 184, 0.22); - border-radius: 999px; - font-weight: 700; - transition: - transform 160ms ease, - background 160ms ease, - color 160ms ease, - border-color 160ms ease; -} - -.button:hover { - transform: translateY(-1px); -} - -.button-primary { - color: #08101d; - background: linear-gradient(145deg, var(--accent), var(--accent-strong)); -} - -.button-secondary { - color: var(--text); - background: rgba(255, 255, 255, 0.04); -} - -.grid { - display: grid; - grid-template-columns: repeat(3, minmax(0, 1fr)); - gap: 1rem; -} - -.card { - padding: 1.25rem; -} - -.card h2 { - margin-top: 0; - margin-bottom: 0.75rem; - font-size: 1.45rem; -} - -.card p { - margin: 0; - color: var(--muted); - line-height: 1.65; -} - -@media (max-width: 900px) { - .grid { - grid-template-columns: 1fr; - } -} diff --git a/p/assets/main-styles/styles.css b/p/assets/main-styles/styles.css deleted file mode 100644 index 8f9e7ae..0000000 --- a/p/assets/main-styles/styles.css +++ /dev/null @@ -1,314 +0,0 @@ -@import "./var.css"; - -:root { - color-scheme: dark; - --bg: var(--background-color); - --bg-soft: rgba(15, 52, 96, 0.72); - --panel: rgba(17, 25, 49, 0.82); - --panel-border: rgba(22, 33, 62, 0.18); - --text: var(--generic-text-color); - --muted: var(--sidebar-text); - --accent: var(--sidebar-text-highlight); - --accent-strong: var(--sidebar-select); - --shadow: 0 24px 70px rgba(0, 0, 0, 0.35); -} - -* { - box-sizing: border-box; -} - -html { - scroll-behavior: smooth; -} - -body { - margin: 0; - min-height: 100vh; - color: var(--text); - font-family: "Trebuchet MS", "Gill Sans", "Segoe UI", sans-serif; - background: - radial-gradient(circle at top left, rgba(56, 189, 248, 0.24), transparent 28%), - radial-gradient(circle at right center, rgba(14, 165, 233, 0.14), transparent 32%), - linear-gradient(160deg, #050816 0%, #0b1020 52%, #08101d 100%); -} - -body::before, -body::after { - content: ""; - position: fixed; - inset: auto; - pointer-events: none; - filter: blur(18px); - opacity: 0.6; -} - -body::before { - width: 22rem; - height: 22rem; - top: -6rem; - left: -8rem; - background: rgba(56, 189, 248, 0.16); -} - -body::after { - width: 18rem; - height: 18rem; - right: -4rem; - bottom: 2rem; - background: rgba(125, 211, 252, 0.12); -} - -.page-shell { - position: relative; - z-index: 1; - width: 100%; - margin: 0 auto; - min-height: 100vh; - display: grid; - grid-template-rows: auto 1fr auto; - gap: 1.25rem; -} - -.site-header, -.site-footer { - backdrop-filter: blur(18px); - background: var(--bg-soft); - box-shadow: var(--shadow); -} - -.header-brand-block{ - width: 100%; - margin: 0 auto; - max-width: 1200px; - display: flex; - /* align-items: center; */ - gap: 0.85rem; - justify-content: space-between; -} - -.site-header { - display: flex; - width: 100%; - align-items: center; - justify-content: space-between; - gap: 1rem; - padding: 1rem 1.25rem; -} - -.brand { - display: inline-flex; - align-items: center; - gap: 0.9rem; - color: inherit; - text-decoration: none; -} - -.brand-mark { - width: 2.75rem; - height: 2.75rem; - object-fit: cover; - display: block; -} - -.brand-text { - display: grid; - line-height: 1.05; -} - -.brand-text strong { - font-family: "Georgia", "Palatino Linotype", serif; -} - -.brand-text small { - color: var(--muted); -} - -.site-nav { - display: flex; - flex-wrap: wrap; - gap: 0.6rem; -} - -.site-nav a { - border-radius: 999px; - transition: - transform 160ms ease, - background 160ms ease, - color 160ms ease, - border-color 160ms ease; -} - -.site-nav a { - padding: 0.7rem 1rem; - color: var(--muted); - text-decoration: none; - border: 1px solid transparent; -} - -.site-nav a:hover, -.site-nav a[aria-current="page"] { - color: var(--text); - border-color: rgba(125, 211, 252, 0.4); - background: rgba(125, 211, 252, 0.08); -} - -.site-main { - margin: 0 auto; - max-width: 1200px; - display: grid; - gap: 1.25rem; - align-content: start; -} - -.site-nav a:hover { - transform: translateY(-1px); -} - -.site-footer { - padding: 1.5rem 1.25rem; - background: rgb(50, 54, 66); -} - -.site-footer p { - margin: 0; -} - -.footer-brand-row { - display: flex; - align-items: start; - justify-content: space-between; - gap: 1rem; - padding-bottom: 1rem; - border-bottom: 1px solid rgba(148, 163, 184, 0.16); -} -.footer-content { - margin: 0 auto; - max-width: 1200px; - display: flex; - flex-direction: column; - gap: 0.5rem; -} -.footer-brand-block { - display: flex; - align-items: center; - gap: 0.85rem; - max-width: 42rem; -} - -.footer-brand-mark { - width: 3rem; - height: 3rem; - border-radius: 0.95rem; - object-fit: cover; - display: block; - flex: none; -} - -.footer-brand-block strong { - display: block; - color: var(--text); - font-family: "Georgia", "Palatino Linotype", serif; - font-size: 1.05rem; -} - -.footer-brand-block p, -.footer-note, -.footer-bottom p { - color: var(--muted); - line-height: 1.6; -} - -.footer-note { - max-width: 20rem; -} - -.footer-links-grid { - display: grid; - grid-template-columns: repeat(3, minmax(0, 1fr)); - gap: 1rem; - padding: 1.25rem 0; -} - -.footer-links-grid section { - display: grid; - gap: 0.6rem; - align-content: start; -} - -.footer-links-grid h2 { - margin: 0 0 0.15rem; - color: var(--text); - font-size: 0.98rem; -} - -.footer-links-grid a { - color: var(--muted); - text-decoration: none; - width: fit-content; - transition: color 160ms ease, transform 160ms ease; -} - -.footer-links-grid a:hover { - color: var(--text); - transform: translateX(2px); -} - -.footer-bottom { - display: flex; - justify-content: space-between; - gap: 1rem; - padding-top: 1rem; - border-top: 1px solid rgba(148, 163, 184, 0.16); - font-size: 0.95rem; -} - -.footer-release, -.footer-commit { - text-align: right; -} - -.footer-release span, -.footer-commit span { - color: var(--text); -} - -@media (max-width: 900px) { - .grid { - grid-template-columns: 1fr; - } - - .footer-links-grid { - grid-template-columns: 1fr; - } -} - -@media (max-width: 700px) { - .page-shell { - width: min(100% - 1rem, 1120px); - gap: 0.9rem; - padding-top: 0.5rem; - } - - .site-header { - flex-direction: column; - align-items: stretch; - } - - .site-nav { - justify-content: space-between; - } - - .site-nav a, - .button { - width: 100%; - } - - .footer-brand-row, - .footer-bottom { - flex-direction: column; - } - - .footer-brand-block { - align-items: flex-start; - } -} \ No newline at end of file diff --git a/p/assets/main-styles/var.css b/p/assets/main-styles/var.css deleted file mode 100644 index 42d7428..0000000 --- a/p/assets/main-styles/var.css +++ /dev/null @@ -1,14 +0,0 @@ -:root { - /* Couleurs de la sidebar */ - --sidebar-background: #1a1a2e; - --sidebar-text: #e0e0e0; - --sidebar-text-highlight: #00d4ff; - --sidebar-select: #16213e; - - /* Couleurs générales */ - --background-color: #0f3460; - --highlighted-text-color: #ffffff; - --generic-text-color: #e0e0e0; - --error-text-color: #ff6b6b; - --warning-text-color: #ffa500; -} diff --git a/p/assets/styles/404.css b/p/assets/styles/404.css new file mode 100644 index 0000000..6d1a3f8 --- /dev/null +++ b/p/assets/styles/404.css @@ -0,0 +1,110 @@ +@import "./var.css"; + +/* ── 404 — Tux débranche le câble réseau ───────────────────────────────────── + Mise en page uniquement : le mouvement (Tux, connecteur, câble) est piloté + par p/assets/js/not-found.js. Le SVG est livré dans son état « branché », + donc la page reste propre même sans JavaScript. */ + +.notfound { + position: relative; + overflow: hidden; + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); + align-items: center; + gap: clamp(1.5rem, 4vw, 3rem); + padding: clamp(1.75rem, 4vw, 3.25rem); + border-radius: 1.25rem; + background: var(--surface); + border: 1px solid var(--border); + box-shadow: var(--shadow-lg); +} + +.notfound::before { + content: ""; + position: absolute; + inset: -35% -10% auto; + height: 70%; + background: radial-gradient(60% 100% at 78% 0%, rgba(56, 189, 248, 0.16), transparent 70%); + pointer-events: none; +} + +.notfound-copy { + position: relative; + z-index: 2; +} + +.notfound-code { + margin: 0 0 0.35rem; + font-family: "Georgia", "Palatino Linotype", serif; + font-size: clamp(3.5rem, 11vw, 6.5rem); + line-height: 0.9; + letter-spacing: -0.04em; + color: transparent; + background: linear-gradient(180deg, var(--accent-soft), var(--accent-strong)); + -webkit-background-clip: text; + background-clip: text; +} + +.notfound-title { + margin: 0 0 0.75rem; + font-family: "Georgia", "Palatino Linotype", serif; + font-size: clamp(1.6rem, 3.6vw, 2.6rem); + line-height: 1.1; + color: var(--text); +} + +.notfound-lead { + margin: 0 0 1.5rem; + max-width: 46ch; + color: var(--text-secondary); + line-height: 1.7; + text-wrap: pretty; +} + +.notfound-actions { + display: flex; + flex-wrap: wrap; + gap: 0.75rem; +} + +.notfound-visual { + position: relative; + z-index: 2; +} + +.nf-scene { + display: block; + width: 100%; + height: auto; + overflow: visible; +} + +/* ── Responsive ───────────────────────────────────────────────────────────── */ + +@media (max-width: 900px) { + .notfound { + grid-template-columns: 1fr; + text-align: center; + } + + .notfound-visual { + order: 2; + max-width: 34rem; + margin: 0 auto; + } + + .notfound-lead { + margin-left: auto; + margin-right: auto; + } + + .notfound-actions { + justify-content: center; + } +} + +@media (max-width: 700px) { + .notfound-actions .button { + width: 100%; + } +} diff --git a/p/assets/styles/contact.css b/p/assets/styles/contact.css new file mode 100644 index 0000000..cea9502 --- /dev/null +++ b/p/assets/styles/contact.css @@ -0,0 +1,121 @@ +@import "./var.css"; + +html { + scroll-behavior: smooth; +} + +body { + margin: 0; + min-height: 100vh; + font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif; + color: var(--text); + background: var(--surface-dim); + background-image: + radial-gradient(circle at top left, rgba(56, 189, 248, 0.06), transparent 40%), + radial-gradient(circle at bottom right, rgba(125, 211, 252, 0.04), transparent 40%); +} + +.contact-header { + max-width: 1120px; + margin: 0 auto; + padding: clamp(2.5rem, 6vw, 5rem) 1.25rem 1.25rem; + text-align: center; +} + +.contact-header h1 { + margin: 0; + font-family: "Georgia", "Times New Roman", serif; + font-size: clamp(2rem, 6vw, 3.5rem); + line-height: 1.1; + letter-spacing: -0.02em; + color: var(--text); +} + +.contact-header p { + max-width: 62ch; + margin: 1rem auto 0; + color: var(--text-secondary); + font-size: 1.05rem; + line-height: 1.8; +} + +hr { + width: min(1120px, calc(100% - 2.5rem)); + margin: 0 auto; + border: 0; + height: 1px; + background: var(--border); +} + +main { + width: min(1120px, calc(100% - 2.5rem)); + margin: 1.5rem auto 0; + padding: 0 0 3rem; +} + +main section { + padding: clamp(1.4rem, 3vw, 2rem); + border-radius: 1rem; + border: 1px solid var(--border); + background: var(--surface); + box-shadow: var(--shadow-sm); +} + +main section h2 { + margin: 0 0 0.85rem; + color: var(--text); + font-family: "Georgia", "Times New Roman", serif; + font-size: clamp(1.4rem, 3vw, 2.1rem); +} + +main section p { + margin: 0 0 1rem; + color: var(--text-secondary); + line-height: 1.8; +} + +main section strong { + color: var(--text); +} + +main section a:not(.button) { + color: var(--accent); + text-decoration: underline; + text-underline-offset: 0.15em; +} + +main section a:not(.button):hover, +main section a:not(.button):focus-visible { + color: var(--accent-soft); +} + +main section a.button { + width: fit-content; +} + +@media (max-width: 700px) { + .contact-header { + padding-top: 2rem; + } + + main, + hr { + width: min(100% - 1rem, 1120px); + } + + main section { + border-radius: 0.8rem; + } + + main section a.button { + width: 100%; + text-align: center; + } +} + +/* Très petits écrans : texte du hero resserré */ +@media (max-width: 380px) { + .contact-header h1 { + font-size: clamp(1.6rem, 8vw, 2rem); + } +} diff --git a/p/assets/styles/creators.css b/p/assets/styles/creators.css new file mode 100644 index 0000000..e0a710a --- /dev/null +++ b/p/assets/styles/creators.css @@ -0,0 +1,130 @@ +@import "./var.css"; + +/* ── Creators Grid ── */ + +.creators-grid { + display: flex; + flex-wrap: wrap; + gap: 1.25rem; + margin-top: 1rem; +} + +.creator-card { + flex: 1 1 280px; + max-width: 100%; + display: flex; + gap: 1rem; + padding: 1.25rem; + border-radius: 0.75rem; + background: var(--surface); + border: 1px solid var(--border); + box-shadow: var(--shadow-sm); + transition: transform 200ms ease, box-shadow 200ms ease; +} + +.creator-card:hover { + transform: translateY(-2px); + box-shadow: var(--shadow-md); +} + +.creator-avatar { + width: 4rem; + height: 4rem; + border-radius: 50%; + object-fit: cover; + flex-shrink: 0; + border: 2px solid var(--border); +} + +.creator-info { + display: flex; + flex-direction: column; + gap: 0.3rem; + min-width: 0; +} + +.creator-name { + margin: 0; + font-family: "Georgia", "Palatino Linotype", serif; + font-size: 1.1rem; + color: var(--text); + line-height: 1.2; +} + +.creator-role { + color: var(--accent); + font-size: 0.9rem; + font-weight: 500; +} + +.creator-joined { + color: var(--muted); + font-size: 0.85rem; +} + +.creator-email { + color: var(--text-secondary); + font-size: 0.88rem; + text-decoration: none; +} + +.creator-email:hover { + color: var(--accent); + text-decoration: underline; +} + +.creator-links { + display: flex; + flex-wrap: wrap; + gap: 0.4rem; + margin-top: 0.2rem; +} + +.creator-link { + display: inline-flex; + align-items: center; + padding: 0.2rem 0.6rem; + font-size: 0.82rem; + font-weight: 500; + color: var(--accent); + background: var(--accent-bg); + border: 1px solid rgba(56, 189, 248, 0.2); + border-radius: 0.35rem; + text-decoration: none; + transition: background 160ms ease; +} + +.creator-link:hover { + background: rgba(56, 189, 248, 0.18); +} + +.creators-error { + color: var(--error-text-color); + font-size: 0.95rem; +} + +@media (max-width: 640px) { + .creator-card { + flex: 1 1 100%; + max-width: 100%; + } + + /* Carte en pile : avatar au-dessus des infos, rien ne déborde */ + .creator-card { + flex-direction: column; + align-items: center; + text-align: center; + } + + .creator-info { + align-items: center; + } + + .creator-links { + justify-content: center; + } + + .creator-email { + word-break: break-all; + } +} diff --git a/p/assets/styles/downloads.css b/p/assets/styles/downloads.css new file mode 100644 index 0000000..12733e5 --- /dev/null +++ b/p/assets/styles/downloads.css @@ -0,0 +1,235 @@ +.versions-panel { + margin-top: 1rem; + padding: 1.25rem; + border-radius: 1rem; + background: var(--surface); + border: 1px solid var(--border); + box-shadow: var(--shadow-sm); +} + +.latest-version h2 { + margin: 0 0 0.35rem; + color: var(--text); +} + +.latest-row { + display: flex; + justify-content: space-between; + align-items: center; + gap: 1rem; +} + +.latest-meta { + color: var(--text-secondary); + font-size: 1.05rem; +} + +.latest-actions { + display: flex; + gap: 0.6rem; + flex-wrap: wrap; +} + +.latest-note { + margin: 0.85rem 0 0; + color: var(--text-secondary); + line-height: 1.6; + max-height: none; + overflow: visible; +} + +.latest-note h1, +.latest-note h2, +.latest-note h3, +.latest-note h4 { + color: var(--text); + margin: 1.2rem 0 0.5rem; +} + +.latest-note h2 { font-size: 1.2rem; } +.latest-note h3 { font-size: 1.05rem; } +.latest-note p { margin: 0.5rem 0; } +.latest-note ul, .latest-note ol { margin: 0.4rem 0; padding-left: 1.4rem; } +.latest-note li { margin: 0.25rem 0; } + +.latest-note table { + width: 100%; + border-collapse: collapse; + margin: 0.75rem 0; + font-size: 0.92rem; +} + +.latest-note th, +.latest-note td { + padding: 0.45rem 0.65rem; + border: 1px solid var(--border); + text-align: left; +} + +.latest-note th { + background: var(--surface-raised); + font-weight: 600; + color: var(--text); +} + +.latest-note blockquote { + margin: 0.6rem 0; + padding: 0.5rem 0.9rem; + border-left: 3px solid var(--accent); + background: var(--accent-bg); + border-radius: 0 0.4rem 0.4rem 0; + color: var(--text-secondary); +} + +.latest-note blockquote p { margin: 0; } + +.latest-note code { + background: var(--surface-raised); + border: 1px solid var(--border-soft); + padding: 0.15em 0.4em; + border-radius: 0.3rem; + font-size: 0.9em; + font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; +} + +.latest-note pre { + background: var(--surface-dim); + border: 1px solid var(--border); + border-radius: 0.5rem; + padding: 0.8rem 1rem; + overflow-x: auto; + margin: 0.6rem 0; +} + +.latest-note pre code { + background: none; + border: none; + padding: 0; + font-size: 0.88rem; +} + +.latest-note hr { + border: none; + border-top: 1px solid var(--border); + margin: 1rem 0; +} + +.latest-note img { + display: block; + max-width: 100%; + height: auto; + margin: 0.75rem 0; + border-radius: 0.65rem; +} + +.latest-note a { + color: var(--accent); + text-decoration: none; +} + +.latest-note a:hover { + text-decoration: underline; +} + +.toggle-note { + display: inline-block; + margin-top: 0.5rem; + padding: 0.35rem 0.9rem; + font-size: 0.88rem; + background: var(--accent-bg); + color: var(--accent); + border: 1px solid rgba(56, 189, 248, 0.2); + border-radius: 0.4rem; + cursor: pointer; + transition: background 0.2s; +} + +.toggle-note:hover { + background: rgba(56, 189, 248, 0.18); +} + +.versions-archive { margin-top: 1rem; } + +.versions-list { + list-style: none; + margin: 0; + padding: 0; + display: grid; + gap: 0.75rem; +} + +.version-item { + display: flex; + justify-content: space-between; + align-items: center; + gap: 1rem; + padding: 0.8rem 0.9rem; + border-radius: 0.8rem; + background: var(--surface-raised); + border: 1px solid var(--border-soft); +} + +.version-item-empty { opacity: 0.8; } + +.version-main { + display: flex; + flex-direction: column; + gap: 0.2rem; +} + +.version-main a { + color: var(--accent); + text-decoration: none; + width: fit-content; +} + +.version-main a:hover { text-decoration: underline; } + +.version-side { + display: flex; + gap: 0.5rem; + flex-wrap: wrap; +} + +@media (max-width: 880px) { + .latest-row, .version-item { + flex-direction: column; + align-items: flex-start; + } + .version-side { width: 100%; } +} + +/* ── Mobile : les tableaux de release notes défilent localement ── */ + +@media (max-width: 640px) { + .versions-panel { + padding: 1rem 0.85rem; + } + + /* wrapper nécessaire : surcharge la base « overflow: visible » de ce + fichier (chargé après styles.css) pour que les tableaux débordent + dans leur propre scroll au lieu de casser la page */ + .latest-note { + overflow-x: auto; + -webkit-overflow-scrolling: touch; + } + + .latest-note table { + min-width: 34rem; + } + + .latest-note pre code { + font-size: 0.8rem; + word-break: break-all; + } + + .latest-actions .button { + flex: 1; + justify-content: center; + } + + .toggle-note { + width: 100%; + text-align: center; + } +} diff --git a/p/assets/styles/equipe.css b/p/assets/styles/equipe.css new file mode 100644 index 0000000..bafba93 --- /dev/null +++ b/p/assets/styles/equipe.css @@ -0,0 +1,24 @@ +@import "./var.css"; + +.equipe-hero { + text-align: center; + padding: clamp(1.5rem, 4vw, 3rem) 1.25rem; +} + +.equipe-hero h1 { + margin: 0 0 0.5rem; + font-family: "Georgia", "Palatino Linotype", serif; + font-size: clamp(2rem, 5vw, 3rem); + color: var(--text); +} + +.equipe-hero p { + margin: 0; + color: var(--text-secondary); + font-size: 1.1rem; + line-height: 1.7; +} + +.equipe-grid-section { + padding: 0 1.25rem clamp(2rem, 4vw, 3rem); +} diff --git a/p/assets/styles/legal.css b/p/assets/styles/legal.css new file mode 100644 index 0000000..29161aa --- /dev/null +++ b/p/assets/styles/legal.css @@ -0,0 +1,117 @@ +@import "./var.css"; + +/* ── Legal pages (mentions légales, conditions, confidentialité) ── */ + +.legal-header { + max-width: 1120px; + margin: 0 auto; + padding: clamp(2.5rem, 6vw, 5rem) 1.25rem 1.25rem; + text-align: center; +} + +.legal-header h1 { + margin: 0; + font-family: "Georgia", "Times New Roman", serif; + font-size: clamp(2rem, 6vw, 3.5rem); + line-height: 1.1; + letter-spacing: -0.02em; + color: var(--text); +} + +.legal-header p { + max-width: 62ch; + margin: 1rem auto 0; + color: var(--text-secondary); + font-size: 1.05rem; + line-height: 1.8; +} + +.legal-main { + width: min(1120px, calc(100% - 2.5rem)); + margin: 1.5rem auto 0; + padding: 0 0 3rem; + display: grid; + gap: 1.5rem; + align-content: start; +} + +.legal-main section { + padding: clamp(1.4rem, 3vw, 2rem); + border-radius: 1rem; + border: 1px solid var(--border); + background: var(--surface); + box-shadow: var(--shadow-sm); +} + +.legal-main h2 { + margin: 0 0 0.85rem; + color: var(--text); + font-family: "Georgia", "Times New Roman", serif; + font-size: clamp(1.3rem, 3vw, 1.9rem); +} + +.legal-main p, +.legal-main li { + margin: 0 0 0.85rem; + color: var(--text-secondary); + line-height: 1.8; +} + +.legal-main ul { + margin: 0 0 1rem; + padding-left: 1.25rem; +} + +.legal-main li:last-child { + margin-bottom: 0; +} + +.legal-main strong { + color: var(--text); +} + +.legal-main a:not(.button) { + color: var(--accent); + text-decoration: underline; + text-underline-offset: 0.15em; +} + +.legal-main a:not(.button):hover, +.legal-main a:not(.button):focus-visible { + color: var(--accent-soft); +} + +/* Contact sheet : label/value pairs without bullets. */ +.legal-sheet { + margin: 0 0 0.5rem; + padding: 0; + list-style: none; + display: grid; + gap: 0.5rem; +} + +.legal-sheet li { + margin: 0; +} + +/* Field to complete by the maintainer (legal identity, IDE, venue). */ +.legal-updated { + margin: 0; + color: var(--muted); + font-size: 0.9rem; + text-align: center; +} + +@media (max-width: 700px) { + .legal-header { + padding-top: 2rem; + } + + .legal-main { + width: min(100% - 1rem, 1120px); + } + + .legal-main section { + border-radius: 0.8rem; + } +} diff --git a/p/assets/styles/main.css b/p/assets/styles/main.css new file mode 100644 index 0000000..84dd100 --- /dev/null +++ b/p/assets/styles/main.css @@ -0,0 +1,521 @@ +@import "./var.css"; + +:root { + --main-max: 1200px; +} + +main[data-page-content] { + margin: 0 auto; + max-width: var(--main-max); + padding: 2rem 1.25rem; + box-sizing: border-box; +} + +.grid { display: block; } + +/* ── Hero ── */ + +.hero { + position: relative; + overflow: hidden; + background: var(--surface); + border: 1px solid var(--border); + box-shadow: var(--shadow-md); + border-radius: 1rem; + padding: clamp(2rem, 4.5vw, 3.5rem); + color: var(--text); + min-height: clamp(22rem, 50vw, 30rem); +} + +.hero-carousel-track { + position: absolute; + inset: 0; +} + +.hero-slide { + position: absolute; + inset: 0; + background-size: cover; + background-position: center; + opacity: 0; + transform: scale(1.02); + transition: opacity 700ms ease, transform 1000ms ease; +} + +.hero-slide::before { + content: ""; + position: absolute; + inset: 0; + background: + linear-gradient(110deg, rgba(15, 23, 42, 0.82) 18%, rgba(15, 23, 42, 0.35) 58%, rgba(15, 23, 42, 0.7) 100%), + radial-gradient(circle at 72% 20%, rgba(56, 189, 248, 0.15), transparent 48%); +} + +.hero-slide.is-active { + opacity: 1; + transform: scale(1); +} + +.hero-inner { + width: 100%; + max-width: 52rem; + position: relative; + z-index: 2; +} + +.eyebrow { + color: var(--accent); + font-weight: 700; + letter-spacing: 0.16em; + text-transform: uppercase; + margin: 0 0 0.6rem; +} + +.hero-title { + font-family: "Georgia", "Palatino Linotype", serif; + font-size: clamp(2.5rem, 7vw, 4.5rem); + line-height: 1; + margin: 0 0 0.25rem; + color: var(--text); +} + +.hero-subtitle { + font-size: clamp(1rem, 2.2vw, 1.3rem); + color: var(--accent-soft); + margin: 0 0 1rem; + font-weight: 600; +} + +.lead { + color: var(--text-secondary); + max-width: 68ch; + margin: 0 0 1.25rem; + text-wrap: pretty; + line-height: 1.7; +} + +.hero-actions { + display: flex; + gap: 0.75rem; + flex-wrap: wrap; +} + +.hero-controls { + position: absolute; + right: clamp(1rem, 2.5vw, 2rem); + bottom: clamp(1rem, 2.8vw, 1.75rem); + z-index: 3; + display: inline-flex; + align-items: center; + gap: 0.45rem; + padding: 0.4rem 0.55rem; + border-radius: 999px; + backdrop-filter: blur(10px); + background: rgba(30, 41, 59, 0.7); + border: 1px solid var(--border); + box-shadow: var(--shadow-sm); +} + +.hero-control { + width: 2.2rem; + height: 2.2rem; + border: 0; + border-radius: 999px; + display: grid; + place-items: center; + font-size: 1.32rem; + color: var(--text-secondary); + background: rgba(148, 163, 184, 0.15); + cursor: pointer; + transition: all 180ms ease; +} + +.hero-control:hover { + transform: translateY(-1px); + background: var(--accent-bg); + color: var(--accent); +} + +.hero-dots { + display: inline-flex; + align-items: center; + gap: 0.4rem; + margin: 0 0.15rem; +} + +.hero-dot { + width: 0.6rem; + height: 0.6rem; + border-radius: 999px; + border: 0; + background: rgba(148, 163, 184, 0.3); + cursor: pointer; + transition: all 180ms ease; +} + +.hero-dot.is-active { + background: var(--accent); + transform: scale(1.18); +} + +/* ── Feature Cards ── */ + +.features { + margin-top: 1.5rem; + display: flex; + gap: 1rem; + align-items: stretch; +} + +.features .card { + flex: 1 1 0; + min-width: 0; + min-height: 11rem; + background: var(--surface); + padding: 1.5rem; + border-radius: 0.75rem; + border: 1px solid var(--border); + box-shadow: var(--shadow-sm); + display: flex; + flex-direction: column; + justify-content: center; + position: relative; + overflow: hidden; + cursor: pointer; + transition: transform 220ms ease, box-shadow 220ms ease, border-color 220ms ease; +} + +.features .card h2 { + margin: 0; + font-family: "Georgia", serif; + font-size: clamp(1.25rem, 1.6vw, 1.6rem); + line-height: 1.1; + color: var(--text); + transition: transform 220ms ease; +} + +.features .card p { + margin: 0; + font-size: clamp(0.95rem, 1.05vw, 1.08rem); + line-height: 1.6; + color: var(--text-secondary); + position: absolute; + left: 1.5rem; + right: 1.5rem; + bottom: 1.35rem; + padding: 0.85rem 1rem; + background: var(--surface-raised); + border-radius: 0.5rem; + border: 1px solid var(--border-soft); + opacity: 0; + transform: translateY(0.5rem); + transition: opacity 180ms ease, transform 220ms ease; + pointer-events: none; +} + +.features:not(:hover) .card:first-child, +.features .card:first-child:hover, +.features .card:first-child:focus { + flex-grow: 2.6; + justify-content: flex-start; +} + +.features:not(:hover) .card:first-child p, +.features .card:first-child:hover p, +.features .card:first-child:focus p { + opacity: 1; + transform: translateY(0); +} + +.features:hover .card:first-child:not(:hover):not(:focus) { + flex-grow: 1; + justify-content: center; +} + +.features:hover .card:first-child:not(:hover):not(:focus) p { + opacity: 0; + transform: translateY(0.5rem); +} + +.features .card:hover, +.features .card:focus { + flex-grow: 2.6; + justify-content: flex-start; + transform: translateY(-4px); + box-shadow: var(--shadow-lg); + border-color: var(--accent-soft); + z-index: 2; +} + +.features .card:hover p, +.features .card:focus p { + opacity: 1; + transform: translateY(0); +} + +.features .card:focus { + outline: 2px solid var(--accent); + outline-offset: 3px; +} + +/* ── Environment Choices ── */ + +.env-choices { + margin-top: 1.8rem; + display: grid; + gap: 1rem; + padding: clamp(1.2rem, 2.4vw, 1.8rem); + border-radius: 1rem; + background: var(--surface); + border: 1px solid var(--border); + box-shadow: var(--shadow-sm); +} + +.env-choices-header h2 { + margin: 0 0 0.45rem; + font-family: "Georgia", "Palatino Linotype", serif; + font-size: clamp(1.6rem, 3vw, 2.2rem); + color: var(--text); +} + +.env-choices-header p { + margin: 0.5rem 0 1rem; + color: var(--text-secondary); + max-width: 78ch; + line-height: 1.7; +} + +.env-row { + display: grid; + grid-template-columns: minmax(170px, 0.9fr) minmax(0, 2.1fr); + gap: clamp(0.85rem, 2vw, 1.35rem); + align-items: stretch; +} + +.env-row.is-reverse { + grid-template-columns: minmax(0, 2.1fr) minmax(170px, 0.9fr); +} + +.env-media, +.env-text { + margin: 0; + border-radius: 0.8rem; + border: 1px solid var(--border); + overflow: hidden; + background: var(--surface-raised); +} + +.env-media { + min-height: clamp(140px, 20vw, 190px); +} + +.env-media img { + width: 100%; + height: 100%; + display: block; + object-fit: cover; +} + +.env-text { + padding: clamp(1rem, 2.4vw, 1.4rem); + display: grid; + align-content: center; + gap: 0.55rem; +} + +.env-text h3 { + margin: 0; + font-family: "Georgia", "Palatino Linotype", serif; + font-size: clamp(1.25rem, 2vw, 1.6rem); + color: var(--text); +} + +.env-text p { + margin: 0; + color: var(--text-secondary); + line-height: 1.65; +} + +/* ── Downloads (inline styles) ── */ + +.downloads { + margin-top: 1.5rem; +} + +.downloads-header h1 { margin: 0 0 0.35rem; } + +.download-grid { + display: grid; + grid-template-columns: repeat(2, 1fr); + gap: 1rem; + margin-top: 1rem; +} + +.download-card { + display: flex; + gap: 1rem; + align-items: stretch; + padding: 0.8rem; + border-radius: 0.75rem; + background: var(--surface); + border: 1px solid var(--border); +} + +.download-media { width: 220px; flex: 0 0 220px; overflow: hidden; border-radius: 0.5rem; } +.download-media img { width: 100%; height: 100%; object-fit: cover; display: block; } + +.download-body { flex: 1 1 auto; display: flex; flex-direction: column; gap: 0.6rem; } + +.download-actions { display: flex; gap: 0.6rem; margin-top: auto; } + +@media (max-width: 880px) { + .download-grid { grid-template-columns: 1fr; } + .download-media { width: 140px; flex-basis: 140px; } +} + +/* Versions toolbar */ +.version-toolbar { + display: flex; + gap: 1rem; + align-items: center; + justify-content: space-between; + margin-top: 0.8rem; +} + +.version-current { color: var(--muted); } + +.versions-archive { + margin-top: 0.8rem; + padding: 0.8rem; + border-radius: 0.6rem; + background: var(--surface-raised); + border: 1px solid var(--border-soft); +} + +.versions-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; } +.version-item { display: flex; justify-content: space-between; align-items: center; padding: 0.4rem 0.6rem; border-radius: 0.45rem; } +.version-meta { color: var(--muted); margin-left: 0.6rem; font-size: 0.92rem; } +.version-actions { display: flex; gap: 0.5rem; } + +/* ── Responsive tablette ── */ + +@media (max-width: 900px) { + .features { + flex-wrap: wrap; + } + + .features .card { + flex: 1 1 45%; + min-height: 9rem; + } + + /* La mécanique hover-grow de l'accordéon n'a pas de sens au doigt : + chaque carte affiche sa description en permanence. */ + .features .card p { + position: static; + margin-top: 0.4rem; + padding: 0; + background: none; + border: 0; + opacity: 1; + transform: none; + pointer-events: auto; + } + + .features .card:hover, + .features .card:focus { + flex-grow: 0; + transform: none; + } + + .features:not(:hover) .card:first-child, + .features:hover .card:first-child:not(:hover):not(:focus) { + flex-grow: 0; + } + + .env-row, + .env-row.is-reverse { + grid-template-columns: 1fr; + } + + /* Ordre visuel : l'image au-dessus du texte, même pour les rangées inversées */ + .env-row.is-reverse .env-text { order: 2; } + .env-row.is-reverse .env-media { order: 1; } + + .env-media { + min-height: 10rem; + } + + .download-media { + width: 120px; + flex-basis: 120px; + } +} + +/* ── Responsive mobile ── */ + +@media (max-width: 640px) { + main[data-page-content] { + padding: 1.25rem 1rem; + } + + .hero { + min-height: 26rem; + } + + .hero-controls { + position: static; + margin-top: 1.25rem; + justify-content: center; + } + + .hero-inner { + max-width: none; + } + + .features { + flex-direction: column; + } + + .features .card { + flex: 1 1 auto; + min-height: 0; + padding: 1.15rem; + } + + .env-choices { + padding: 1.1rem 0.9rem; + } + + .env-text { + padding: 1rem 0.9rem; + } + + .download-card { + flex-direction: column; + } + + .download-media { + width: 100%; + flex-basis: auto; + max-height: 10rem; + } + + .download-media img { + height: 100%; + } + + .version-item { + flex-direction: column; + align-items: flex-start; + gap: 0.5rem; + } + + .version-actions { + width: 100%; + } + + .version-actions .button { + flex: 1; + } +} \ No newline at end of file diff --git a/p/assets/styles/paquets.css b/p/assets/styles/paquets.css new file mode 100644 index 0000000..04e114e --- /dev/null +++ b/p/assets/styles/paquets.css @@ -0,0 +1,803 @@ +/* ── Menu déroulant « Paquets » (barre de navigation) ── */ + +.nav-dropdown { + position: relative; + display: inline-flex; +} + +.nav-dropdown-toggle { + display: inline-flex; + align-items: center; + gap: 0.4rem; + padding: 0.5rem 1rem; + border: 0; + background: transparent; + color: var(--text-secondary); + font-family: inherit; + font-size: 0.95rem; + font-weight: 500; + border-radius: 0.5rem; + cursor: pointer; + transition: all 160ms ease; +} + +.nav-dropdown-toggle:hover, +.nav-dropdown-toggle[aria-current="page"] { + color: var(--accent); + background: var(--accent-bg); +} + +.nav-dropdown-toggle:hover { + transform: translateY(-1px); +} + +.nav-dropdown-caret { + width: 0.55rem; + height: 0.55rem; + border-right: 2px solid currentColor; + border-bottom: 2px solid currentColor; + transform: rotate(45deg) translateY(-2px); + transition: transform 160ms ease; + flex: none; +} + +.is-open .nav-dropdown-caret { + transform: rotate(-135deg) translateY(-1px); +} + +.nav-dropdown-panel { + position: absolute; + top: calc(100% + 0.55rem); + left: 50%; + z-index: 300; + width: min(92vw, 26rem); + padding: 0.4rem; + background: color-mix(in srgb, var(--surface-raised) 88%, transparent); + backdrop-filter: blur(14px); + -webkit-backdrop-filter: blur(14px); + border: 1px solid var(--border); + border-radius: 1rem; + box-shadow: 0 18px 50px rgba(2, 6, 23, 0.55), var(--shadow-lg); + opacity: 0; + visibility: hidden; + transform: translateX(-50%) translateY(-6px) scale(0.98); + transform-origin: top center; + transition: opacity 170ms ease, transform 170ms ease, visibility 170ms; +} + +.nav-dropdown.is-open .nav-dropdown-panel { + opacity: 1; + visibility: visible; + transform: translateX(-50%) translateY(0) scale(1); +} + +/* En-tête du panneau : titre + compteur */ +.nav-dropdown-head { + display: flex; + align-items: baseline; + justify-content: space-between; + gap: 0.75rem; + padding: 0.55rem 0.7rem 0.5rem; + border-bottom: 1px solid var(--border-soft); +} + +.nav-dropdown-head strong { + color: var(--text); + font-size: 0.8rem; + font-weight: 700; + text-transform: uppercase; + letter-spacing: 0.07em; +} + +.nav-dropdown-head small { + color: var(--muted); + font-size: 0.72rem; +} + +.nav-dropdown-panel-inner { + display: grid; + gap: 0.2rem; + max-height: min(58vh, 24rem); + overflow: auto; + padding: 0.4rem 0.15rem 0.2rem; + scrollbar-width: thin; +} + +.nav-dropdown-item { + display: flex; + align-items: center; + gap: 0.65rem; + padding: 0.55rem 0.6rem; + border-radius: 0.65rem; + text-decoration: none; + color: var(--text-secondary); + transition: background 130ms ease, color 130ms ease, transform 130ms ease; +} + +/* Item avec miniature (première image du paquet) */ +.nav-dropdown-item.has-thumb { + grid-template-columns: auto 1fr; +} +.nav-dropdown-thumb { + width: 2.4rem; + height: 2.4rem; + border-radius: 0.55rem; + object-fit: cover; + border: 1px solid var(--border); + display: block; + flex: none; + background: var(--surface); +} +.nav-dropdown-text { + display: grid; + gap: 0.1rem; + min-width: 0; + flex: 1; +} + +.nav-dropdown-item:hover, +.nav-dropdown-item:focus-visible { + background: var(--accent-bg); + color: var(--text); + outline: none; + transform: translateX(2px); +} + +.nav-dropdown-item strong { + display: inline-flex; + align-items: center; + flex-wrap: wrap; + gap: 0.4rem; + color: var(--text); + font-size: 0.92rem; + font-weight: 600; +} + +.nav-dropdown-version { + padding: 0.05rem 0.45rem; + font-size: 0.65rem; + font-weight: 700; + color: var(--accent); + background: var(--accent-bg); + border: 1px solid rgba(56, 189, 248, 0.3); + border-radius: 999px; +} + +.nav-dropdown-item small { + color: var(--muted); + font-size: 0.76rem; + line-height: 1.35; + overflow: hidden; + display: -webkit-box; + -webkit-line-clamp: 1; + -webkit-box-orient: vertical; +} + +.nav-dropdown-all { + display: flex; + align-items: center; + justify-content: center; + gap: 0.4rem; + margin: 0.3rem 0.15rem 0.1rem; + padding: 0.6rem 0.75rem; + border-top: 1px solid var(--border-soft); + color: var(--accent); + text-decoration: none; + font-size: 0.88rem; + font-weight: 600; + border-radius: 0.65rem; + transition: background 130ms ease, color 130ms ease; +} + +.nav-dropdown-all:hover { + background: var(--accent-bg); + color: var(--accent-strong); +} + +.nav-dropdown-error { + margin: 0; + padding: 0.6rem 0.75rem; + color: var(--error-text-color); + font-size: 0.85rem; +} + +/* ── Page « Paquets » ── */ + +.paquets-hero { + text-align: center; + padding: 1.5rem 0 0.5rem; +} + +.paquets-hero h1 { + margin: 0 0 0.5rem; + font-family: "Georgia", "Palatino Linotype", serif; + font-size: 2.25rem; + color: var(--text); +} + +.paquets-list { + display: grid; + gap: 1.5rem; +} + +.paquet-card { + display: grid; + gap: 1rem; + padding: 1.25rem 1.25rem 1.5rem; + background: var(--surface); + border: 1px solid var(--border); + border-radius: 0.75rem; + box-shadow: var(--shadow-sm); + scroll-margin-top: 6rem; +} + +.paquet-head { + display: grid; + gap: 0.4rem; +} + +.paquet-title-row { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 0.6rem; +} + +.paquet-title-row h2 { + margin: 0; + font-family: "Georgia", "Palatino Linotype", serif; + font-size: 1.35rem; + color: var(--text); +} + +.paquet-since { + padding: 0.15rem 0.5rem; + font-size: 0.72rem; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.04em; + color: var(--accent); + background: var(--accent-bg); + border: 1px solid rgba(56, 189, 248, 0.25); + border-radius: 999px; +} + +.paquet-detail-link { + margin-left: auto; + padding: 0.35rem 0.75rem; + font-size: 0.8rem; + font-weight: 600; + color: var(--accent); + text-decoration: none; + border: 1px solid var(--accent-soft); + border-radius: 0.5rem; + transition: color 160ms ease, background 160ms ease; +} + +.paquet-detail-link:hover { + color: var(--text); + background: var(--accent-bg); +} + +.paquet-tagline { + margin: 0; + color: var(--accent-soft); + font-weight: 500; +} + +.paquet-latest { + margin: 0; + color: var(--muted); + font-size: 0.85rem; +} + +.paquet-description { + margin: 0; + color: var(--text-secondary); + line-height: 1.6; +} + +.paquet-body { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 1.25rem; + align-items: start; +} + +.paquet-changelog, +.paquet-screens { + display: grid; + gap: 0.6rem; +} + +.paquet-changelog > h3, +.paquet-screens > h3 { + margin: 0; + font-size: 0.8rem; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.06em; + color: var(--muted); +} + +.paquet-timeline { + list-style: none; + margin: 0; + padding: 0; + display: grid; + gap: 0.65rem; + border-left: 2px solid var(--border); + margin-left: 0.25rem; +} + +.paquet-timeline-item { + position: relative; + padding-left: 1rem; + display: grid; + gap: 0.1rem; +} + +.paquet-timeline-item::before { + content: ""; + position: absolute; + left: -5px; + top: 0.3rem; + width: 8px; + height: 8px; + border-radius: 50%; + background: var(--accent); +} + +.paquet-timeline-version { + color: var(--text); + font-size: 0.95rem; +} + +.paquet-timeline-date { + color: var(--muted); + font-size: 0.78rem; +} + +.paquet-timeline-notes { + color: var(--text-secondary); + font-size: 0.9rem; + line-height: 1.5; +} + +.paquet-screens-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); + gap: 0.6rem; +} + +.paquet-screens-grid figure { + margin: 0; + display: grid; + gap: 0.3rem; +} + +.paquet-screens-grid img { + width: 100%; + aspect-ratio: 16 / 10; + object-fit: cover; + border-radius: 0.5rem; + border: 1px solid var(--border); +} + +.paquet-screens-grid figcaption { + color: var(--muted); + font-size: 0.75rem; +} + +/* ── Historique limité (« Voir plus ») ── */ + +.paquet-timeline-item.paquet-timeline-extra { + display: none; +} + +.paquet-timeline.is-expanded .paquet-timeline-extra { + display: grid; +} + +.paquet-more { + justify-self: start; + padding: 0.3rem 0.8rem; + border: 1px solid var(--border); + border-radius: 999px; + background: transparent; + color: var(--accent); + font-size: 0.8rem; + font-weight: 600; + cursor: pointer; + transition: border-color 140ms ease, color 140ms ease; +} + +.paquet-more:hover { + border-color: var(--accent); + color: var(--accent-strong, var(--accent)); +} + +/* ── Images cliquables (page détail) ── */ + +.paquet-screens-grid img[data-zoom] { + cursor: zoom-in; + transition: opacity 140ms ease; +} + +.paquet-screens-grid img[data-zoom]:hover { + opacity: 0.85; +} + +.paquet-zoom-hint { + color: var(--muted); + font-size: 0.72rem; +} + +/* ── Popup central « aperçu de l'image » ── */ + +html.pkg-no-scroll { + overflow: hidden; +} + +.pkg-lightbox { + position: fixed; + inset: 0; + z-index: 1000; + display: none; + align-items: center; + justify-content: center; + padding: 2rem; + background: rgba(2, 6, 23, 0.55); + backdrop-filter: blur(10px); + -webkit-backdrop-filter: blur(10px); +} + +.pkg-lightbox.is-open { + display: flex; +} + +.pkg-lightbox-figure { + margin: 0; + display: grid; + gap: 0.55rem; + max-width: min(1000px, 90vw); + animation: pkg-pop 220ms cubic-bezier(0.2, 0.9, 0.3, 1.2); +} + +.pkg-lightbox-figure.is-animating { + animation: pkg-pop 220ms cubic-bezier(0.2, 0.9, 0.3, 1.2); +} + +@keyframes pkg-pop { + from { opacity: 0; transform: scale(0.92); } + to { opacity: 1; transform: scale(1); } +} + +.pkg-lightbox-img { + display: block; + max-width: 100%; + max-height: 78vh; + object-fit: contain; + border-radius: 0.8rem; + border: 1px solid var(--border); + box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55); + margin: 0 auto; +} + +.pkg-lightbox-figcap { + display: flex; + align-items: center; + justify-content: center; + gap: 0.8rem; +} + +.pkg-lightbox-caption { + color: #e2e8f0; + font-size: 0.9rem; +} + +.pkg-lightbox-count { + color: #94a3b8; + font-size: 0.78rem; +} + +.pkg-lightbox-close { + position: absolute; + top: 1rem; + right: 1.2rem; + width: 2.5rem; + height: 2.5rem; + border: 1px solid rgba(148, 163, 184, 0.4); + border-radius: 999px; + background: rgba(15, 23, 42, 0.75); + color: #e2e8f0; + font-size: 1.4rem; + line-height: 1; + cursor: pointer; +} + +.pkg-lightbox-close:hover { + border-color: #e2e8f0; +} + +.pkg-lightbox-nav { + position: absolute; + top: 50%; + transform: translateY(-50%); + width: 2.8rem; + height: 2.8rem; + border: 1px solid rgba(148, 163, 184, 0.35); + border-radius: 999px; + background: rgba(15, 23, 42, 0.75); + color: #e2e8f0; + font-size: 1.6rem; + line-height: 1; + cursor: pointer; +} + +.pkg-lightbox-prev { left: 1.2rem; } +.pkg-lightbox-next { right: 1.2rem; } + +.pkg-lightbox-nav:hover { + border-color: #e2e8f0; + background: rgba(30, 41, 59, 0.9); +} + +@media (max-width: 720px) { + .pkg-lightbox { + padding: 1rem; + } + .pkg-lightbox-nav { + top: auto; + bottom: 1.2rem; + transform: none; + } + .pkg-lightbox-prev { left: auto; right: 4.2rem; } + .pkg-lightbox-next { right: 1.2rem; } +} + +.paquet-links { + grid-column: 1 / -1; + display: flex; + flex-wrap: wrap; + gap: 0.5rem; +} + +.paquet-links > h3 { + flex-basis: 100%; + margin: 0; + font-size: 0.8rem; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.06em; + color: var(--muted); +} + +.paquet-empty { + margin: 0; + padding: 0.6rem 0.8rem; + border: 1px dashed var(--border); + border-radius: 0.5rem; + color: var(--muted); + font-size: 0.85rem; + font-style: italic; +} + +/* ── Page détail « Paquets / N » ── */ + +.paquet-detail-page { + display: grid; + gap: 1.5rem; + max-width: 56rem; + margin: 0 auto; +} + +.paquet-detail-back { + justify-self: start; + color: var(--accent); + text-decoration: none; + font-size: 0.95rem; + font-weight: 500; + transition: color 160ms ease, transform 160ms ease; +} + +.paquet-detail-back:hover { + color: var(--accent-strong); + transform: translateX(-2px); +} + +.paquet-detail-hero { + display: grid; + gap: 0.75rem; + padding: 2rem 2rem 2.25rem; + text-align: center; + justify-items: center; + background: var(--surface); + border: 1px solid var(--border); + border-radius: 1rem; + box-shadow: var(--shadow-sm); +} + +.paquet-detail-hero .paquet-since { + justify-self: center; +} + +.paquet-detail-hero h1 { + margin: 0; + font-family: "Georgia", "Palatino Linotype", serif; + font-size: 2.75rem; + color: var(--text); +} + +.paquet-detail-hero .paquet-tagline { + font-size: 1.15rem; +} + +.paquet-detail-hero .paquet-description { + max-width: 40rem; +} + +.paquet-detail-latest { + display: inline-flex; + align-items: center; + gap: 0.75rem; + flex-wrap: wrap; + justify-content: center; + margin-top: 0.5rem; + padding: 0.4rem 1rem; + border: 1px solid var(--border); + border-radius: 999px; + background: var(--surface-raised); +} + +.paquet-detail-latest-empty { + color: var(--muted); + font-style: italic; + font-size: 0.9rem; +} + +.paquet-detail-version { + font-size: 1.4rem; + font-weight: 700; + color: var(--accent); + letter-spacing: 0.02em; +} + +.paquet-detail-date { + color: var(--text-secondary); + font-size: 0.9rem; +} + +.paquet-detail-body { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 1.5rem; + align-items: start; +} + +.paquet-detail-page > .paquet-links { + grid-column: auto; +} + +/* ── Responsive ── */ + +/* Tablette : grilles deux colonnes → une, panels déroulants déjà statiques <900px */ +@media (max-width: 900px) { + .paquet-body, + .paquet-detail-body { + grid-template-columns: 1fr; + } + + .paquet-detail-hero { + padding: 1.5rem 1.25rem 1.75rem; + } + + .paquet-detail-hero h1 { + font-size: 2rem; + } + + .paquet-detail-link { + margin-left: 0; + } + + /* La popup garde la place : flèches en bas, comme le bloc 720px existant */ + .pkg-lightbox { + padding: 0.9rem; + } + + .pkg-lightbox-img { + max-height: 62vh; + } + + .pkg-lightbox-nav { + top: auto; + bottom: 1.2rem; + transform: none; + width: 2.6rem; + height: 2.6rem; + } + + .pkg-lightbox-prev { left: auto; right: 4.4rem; } + .pkg-lightbox-next { right: 1rem; } + + .pkg-lightbox-close { + top: 0.8rem; + right: 0.8rem; + } + + .pkg-lightbox-figcap { + flex-direction: column; + gap: 0.25rem; + text-align: center; + } +} + +@media (max-width: 700px) { + .nav-dropdown-toggle { + width: 100%; + justify-content: center; + } + + .nav-dropdown-panel { + position: static; + left: auto; + min-width: 0; + max-width: none; + transform: none; + width: 100%; + display: none; + } + + /* Le conteneur flex desktop mettrait toggle et panneau côte à côte : en mobile on empile */ + .nav-dropdown { + display: block; + width: 100%; + } + + .nav-dropdown.is-open .nav-dropdown-panel { + display: block; + opacity: 1; + visibility: visible; + transform: none; + } + + .paquet-links { + grid-column: auto; + } + + .paquets-hero h1 { + font-size: 1.75rem; + } + + .paquet-card { + padding: 1.1rem 1rem 1.3rem; + } + + .paquet-title-row h2 { + font-size: 1.2rem; + } + + .paquet-timeline { + margin-left: 0; + padding-left: 0.9rem; + } + + .paquet-screens-grid { + grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); + } + + .paquet-links .button { + flex: 1 1 100%; + justify-content: center; + } + + .paquet-detail-back { + font-size: 0.9rem; + } +} +/* Très petits écrans : captures en une colonne (après le bloc 700px pour gagner) */ +@media (max-width: 480px) { + .paquet-screens-grid { + grid-template-columns: 1fr; + } +} diff --git a/p/assets/styles/styles.css b/p/assets/styles/styles.css new file mode 100644 index 0000000..5de5265 --- /dev/null +++ b/p/assets/styles/styles.css @@ -0,0 +1,501 @@ +@import "./var.css"; + +* { + box-sizing: border-box; +} + +/* ── Skip link (accessibilité) ── */ + +.skip-link { + position: absolute; + top: -100%; + left: 0.5rem; + z-index: 9999; + padding: 0.6rem 1rem; + background: var(--accent); + color: var(--surface-dim); + font-weight: 600; + border-radius: 0 0 0.5rem 0.5rem; + text-decoration: none; + transition: top 200ms ease; +} + +.skip-link:focus { + top: 0; +} + +html { + scroll-behavior: smooth; +} + +body { + margin: 0; + min-height: 100vh; + color: var(--text); + font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif; + background: var(--surface-dim); + background-image: + radial-gradient(circle at top left, rgba(56, 189, 248, 0.08), transparent 40%), + radial-gradient(circle at bottom right, rgba(125, 211, 252, 0.05), transparent 40%); +} + +.page-shell { + position: relative; + z-index: 1; + width: 100%; + margin: 0 auto; + min-height: 100vh; + display: grid; + grid-template-rows: auto 1fr auto; + gap: 0; +} + +/* ── Header ── */ + +.site-header { + background: var(--surface); + border-bottom: 1px solid var(--border); + box-shadow: var(--shadow-sm); + position: sticky; + top: 0; + z-index: 100; +} + +.header-brand-block { + width: 100%; + margin: 0 auto; + max-width: 1200px; + display: flex; + align-items: center; + gap: 0.85rem; + justify-content: space-between; + padding: 0.75rem 1.25rem; +} + +.brand { + display: inline-flex; + align-items: center; + gap: 0.75rem; + color: var(--text); + text-decoration: none; +} + +.brand-mark { + width: 2.75rem; + height: 2.75rem; + object-fit: cover; + display: block; + border-radius: 0.5rem; +} + +.brand-text { + display: grid; + font-size: 1.5rem; + line-height: 1.1; +} + +.brand-text strong { + font-family: "Georgia", "Palatino Linotype", serif; + color: var(--text); +} + +.brand-text small { + color: var(--muted); + font-size: 0.75rem; +} + +/* ── Navigation ── */ + +.site-nav { + display: flex; + flex-wrap: wrap; + gap: 0.35rem; +} + +/* Burger mobile : bouton visible <900px, la nav devient un panneau dépliant */ + +.nav-burger { + display: none; + flex-direction: column; + justify-content: center; + gap: 5px; + width: 2.75rem; + height: 2.75rem; + padding: 0 0.6rem; + border: 1px solid var(--border); + border-radius: 0.5rem; + background: var(--surface-raised); + cursor: pointer; + flex: none; +} + +.nav-burger span { + display: block; + width: 100%; + height: 2px; + border-radius: 2px; + background: var(--text); + transition: transform 180ms ease, opacity 180ms ease; +} + +.nav-burger[aria-expanded="true"] span:nth-child(1) { + transform: translateY(7px) rotate(45deg); +} + +.nav-burger[aria-expanded="true"] span:nth-child(2) { + opacity: 0; +} + +.nav-burger[aria-expanded="true"] span:nth-child(3) { + transform: translateY(-7px) rotate(-45deg); +} + +.site-nav a { + padding: 0.5rem 1rem; + color: var(--text-secondary); + text-decoration: none; + border-radius: 0.5rem; + font-weight: 500; + font-size: 0.95rem; + transition: all 160ms ease; +} + +.site-nav a:hover, +.site-nav a[aria-current="page"] { + color: var(--accent); + background: var(--accent-bg); +} + +.site-nav a:hover { + transform: translateY(-1px); +} + +/* ── Main ── */ + +.site-main { + margin: 0 auto; + max-width: 1200px; + width: 100%; + padding: 2rem 1.25rem; + display: grid; + gap: 2rem; + align-content: start; +} + +/* ── Footer ── */ + +.site-footer { + background: var(--surface); + border-top: 1px solid var(--border); + padding: 2rem 1.25rem; +} + +.site-footer p { + margin: 0; +} + +.footer-brand-row { + display: flex; + align-items: start; + justify-content: space-between; + gap: 1rem; + padding-bottom: 1.25rem; + border-bottom: 1px solid var(--border); +} + +.footer-content { + margin: 0 auto; + max-width: 1200px; + display: flex; + flex-direction: column; + gap: 0.5rem; +} + +.footer-brand-block { + display: flex; + align-items: center; + gap: 0.85rem; + max-width: 42rem; +} + +.footer-brand-mark { + width: 2.5rem; + height: 2.5rem; + border-radius: 0.5rem; + object-fit: cover; + display: block; + flex: none; +} + +.footer-brand-block strong { + display: block; + color: var(--text); + font-family: "Georgia", "Palatino Linotype", serif; + font-size: 1.05rem; +} + +.footer-brand-block p, +.footer-note, +.footer-bottom p { + color: var(--muted); + line-height: 1.6; +} + +.footer-note { + max-width: 20rem; +} + +.footer-links-grid { + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + gap: 1.5rem; + padding: 1.5rem 0; +} + +.footer-links-grid section, +.footer-links-grid nav { + display: grid; + gap: 0.5rem; + align-content: start; +} + +.footer-links-grid h2 { + margin: 0 0 0.25rem; + color: var(--text); + font-size: 0.9rem; + text-transform: uppercase; + letter-spacing: 0.05em; +} + +.footer-links-grid a { + color: var(--text-secondary); + text-decoration: none; + width: fit-content; + font-size: 0.95rem; + transition: color 160ms ease, transform 160ms ease; +} + +.footer-links-grid a:hover { + color: var(--accent); + transform: translateX(2px); +} + +.footer-bottom { + display: flex; + justify-content: space-between; + gap: 1rem; + padding-top: 1.25rem; + border-top: 1px solid var(--border); + font-size: 0.9rem; + color: var(--muted); +} + +.footer-hosting { + text-align: right; +} + +.footer-hosting a { + color: var(--text-secondary); + text-decoration: none; + border-bottom: 1px solid var(--border); + transition: color 160ms ease; +} + +.footer-hosting a:hover, +.footer-hosting a:focus-visible { + color: var(--accent); +} + +.footer-release, +.footer-commit { + text-align: right; +} + +.footer-release span, +.footer-commit span { + color: var(--text-secondary); +} + +/* ── Buttons ── */ + +.button { + display: inline-flex; + align-items: center; + justify-content: center; + padding: 0.7rem 1.4rem; + border-radius: 0.5rem; + text-decoration: none; + font-weight: 600; + font-size: 0.95rem; + border: 1px solid transparent; + cursor: pointer; + transition: all 180ms ease; + user-select: none; + -webkit-tap-highlight-color: transparent; +} + +.button-primary { + background: var(--accent); + color: var(--surface-dim); + box-shadow: 0 2px 8px rgba(56, 189, 248, 0.25); +} + +.button-secondary { + background: var(--surface-raised); + color: var(--text-secondary); + border-color: var(--border); +} + +.button:hover, +.button:focus-visible { + transform: translateY(-1px); + box-shadow: var(--shadow-md); +} + +.button-primary:hover, +.button-primary:focus-visible { + background: var(--accent-strong); + box-shadow: 0 4px 16px rgba(56, 189, 248, 0.3); +} + +.button-secondary:hover, +.button-secondary:focus-visible { + background: rgba(56, 189, 248, 0.12); + border-color: var(--accent-soft); + color: var(--accent); +} + +.button:focus-visible { + outline: 2px solid var(--accent); + outline-offset: 2px; +} + +.button[aria-disabled="true"], +.button:disabled { + opacity: 0.5; + pointer-events: none; + transform: none; + box-shadow: none; +} + +/* ── Responsive ── */ + +@media (max-width: 900px) { + .footer-links-grid { + grid-template-columns: 1fr; + } + + /* Header : burger à droite, nav en panneau dépliant sous la marque */ + .header-brand-block { + flex-direction: row; + align-items: center; + flex-wrap: wrap; + padding: 0.6rem 1rem; + gap: 0.6rem; + } + + .nav-burger { + display: flex; + margin-left: auto; + } + + .site-nav { + display: none; + flex-basis: 100%; + flex-direction: column; + gap: 0.3rem; + padding: 0.35rem 0 0.5rem; + border-top: 1px solid var(--border-soft); + } + + .site-nav.is-open { + display: flex; + } + + .site-nav a, + .nav-dropdown-toggle { + width: 100%; + text-align: center; + justify-content: center; + padding: 0.65rem 1rem; + font-size: 1rem; + } + + /* Le panneau déroulant devient statique : il se déploie dans le flux */ + .nav-dropdown { + width: 100%; + } + + .nav-dropdown-panel { + position: static; + left: auto; + min-width: 0; + max-width: none; + width: 100%; + transform: none; + box-shadow: none; + background: var(--surface); + } + + .nav-dropdown.is-open .nav-dropdown-panel { + transform: none; + } + + .nav-dropdown-panel-inner { + max-height: 16rem; + } + + .site-main { + padding: 1.25rem 1rem; + } +} + +@media (max-width: 700px) { + .page-shell { + width: 100%; + } + + .header-brand-block { + padding: 0.55rem 0.85rem; + } + + .brand-text { + font-size: 1.25rem; + } + + .footer-brand-row, + .footer-bottom { + flex-direction: column; + } + + .footer-brand-block { + align-items: flex-start; + } + + .footer-bottom p { + text-align: center; + } + + .hero-actions .button { + width: 100%; + } +} + +/* Très petits écrans (<380px) : marges réduites, tailles resserrées */ +@media (max-width: 380px) { + .site-main { + padding: 1rem 0.65rem; + } + + .hero { + min-height: 24rem; + } + + .hero-title { + font-size: clamp(2rem, 9vw, 2.5rem); + } + + .footer-links-grid { + gap: 1rem; + } +} diff --git a/p/assets/styles/var.css b/p/assets/styles/var.css new file mode 100644 index 0000000..b898364 --- /dev/null +++ b/p/assets/styles/var.css @@ -0,0 +1,32 @@ +:root { + /* Accent colors */ + --accent: #38bdf8; + --accent-soft: #7dd3fc; + --accent-strong: #0ea5e9; + --accent-bg: rgba(56, 189, 248, 0.1); + + /* Surfaces — slate doux, pas noir pur */ + --surface: #1e293b; + --surface-raised: #273449; + --surface-dim: #0f172a; + + /* Text */ + --text: #e2e8f0; + --text-secondary: #94a3b8; + --muted: #64748b; + + /* Borders */ + --border: rgba(148, 163, 184, 0.15); + --border-soft: rgba(148, 163, 184, 0.08); + + /* Shadows */ + --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.15); + --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.15); + --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.2); + --shadow: 0 4px 16px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.15); + + /* Status */ + --error-text-color: #f87171; + --warning-text-color: #fbbf24; + --success-text-color: #34d399; +} diff --git a/p/conditions/index.php b/p/conditions/index.php new file mode 100644 index 0000000..e18d8a9 --- /dev/null +++ b/p/conditions/index.php @@ -0,0 +1,83 @@ + + + + diff --git a/p/confidentialite/index.php b/p/confidentialite/index.php new file mode 100644 index 0000000..c67aa31 --- /dev/null +++ b/p/confidentialite/index.php @@ -0,0 +1,74 @@ + + + + diff --git a/p/contact/index.html b/p/contact/index.html deleted file mode 100644 index bf5ce52..0000000 --- a/p/contact/index.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - Contact - - - -
    -
    -

    Contact

    -

    Tu veux nous joindre ?

    -

    - Cette page centralise les moyens de contact et les liens utiles pour écrire, appeler, ou retrouver le projet ailleurs. -

    - -
    - -
    -
    -

    Email

    -

    contact@fwslinux.fr pour les demandes générales et les retours rapides.

    -
    -
    -

    Téléphone

    -

    +33 0 00 00 00 00 pour les appels ou le support direct.

    -
    -
    -

    Réseaux

    -

    Le footer te donne aussi les liens vers GitHub, Instagram et LinkedIn.

    -
    -
    -
    - - diff --git a/p/contact/index.php b/p/contact/index.php new file mode 100644 index 0000000..50b3343 --- /dev/null +++ b/p/contact/index.php @@ -0,0 +1,36 @@ + +
    +

    Contactez l'équipe de développement

    +

    Une question, un bug à signaler ou envie de contribuer ? Voici comment nous joindre.

    +
    + +
    + +
    +
    +

    Notre seul canal officiel actuel

    +

    Le projet est en plein développement. Pour le moment, nous n'avons pas encore d'adresse email dédiée ni de réseaux sociaux.

    +

    + Suivez le projet et ouvrez des Issues / PR ici : +

    + Notre GitHub +
    + +
    +
    diff --git a/p/dl/index.html b/p/dl/index.html deleted file mode 100644 index 48a4643..0000000 --- a/p/dl/index.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - DL - - - -
    -
    -

    Route DL

    -

    Le contenu de la section DL charge ici.

    -

    - Cette page vit dans p/dl/index.html et son contenu est injecté dans le - main quand l'URL pointe vers /?p/dl/. -

    - -
    - -
    -
    -

    Vrai fichier

    -

    Le HTML est bien stocké dans le dossier p/, pas dans le fichier principal.

    -
    -
    -

    Injection

    -

    Le script lit ce fichier puis injecte uniquement le bloc portant data-page-content.

    -
    -
    -

    Extensible

    -

    Tu peux créer d'autres dossiers comme p/contact/ ou p/about/.

    -
    -
    -
    - - \ No newline at end of file diff --git a/p/dl/index.php b/p/dl/index.php new file mode 100644 index 0000000..80aa35d --- /dev/null +++ b/p/dl/index.php @@ -0,0 +1,112 @@ +Release la plus récente.

    '; + } + $tr = fws_truncate_html($latestNoteFull, 600); + $latestNote = $tr['html']; + $latestTruncated = $tr['truncated']; +} +?> +
    +
    +

    Téléchargements

    +
    +
    +

    Dernière version

    +
    +
    + + +
    + +
    +
    Aucune release publiée pour le moment, affichage des tags du dépôt.

    '; + } elseif ($latest === null) { + echo '

    Le dépôt ne renvoie ni release ni tag public.

    '; + } else { + echo $latestNote; + } + ?>
    + +
    + +
    +

    Versions précédentes

    +
      Aucune release trouvéeLe dépôt n\'expose pas encore de release ou les releases ne sont pas accessibles.
      ' + . ''; + } elseif ($previous === []) { + echo '
    • Aucune release précédenteIl n\'y a qu\'une seule release publiée pour le moment.
    • '; + } else { + foreach ($previous as $rel) { + $d = fws_format_date(fws_site_release_date($rel)); + $url = $mode === 'tags' + ? 'https://github.com/You-re-like-Windows-a-bitch/ISO/releases/tag/' . rawurlencode((string) ($rel['name'] ?? $rel['ref'] ?? '')) + : fws_site_release_download_url($rel); + echo '
    • ' . e(fws_site_release_label($rel)) . '' + . '' . ($d !== '' ? 'Publié le ' . e($d) : ($mode === 'tags' ? 'Tag GitHub' : 'Date inconnue')) . '
      ' + . '
    • '; + } + } + ?>
    +
    +
    +
    +
    diff --git a/p/equipe/creators.json b/p/equipe/creators.json new file mode 100644 index 0000000..7565127 --- /dev/null +++ b/p/equipe/creators.json @@ -0,0 +1,43 @@ +[ + { + "name": "BlackAngelTV", + "role": "Owner", + "avatar": "/p/assets/img/logo.png", + "joined": "2026-03-17", + "email": "dami.scoot3@gmail.com", + "links": [ + { "label": "GitHub", "url": "https://github.com/BlackAngelTVdev" }, + {"label": "Gitea", "url": "https://gitea.nocode-var.tech/BlackAngelTV"} + ] + }, + { + "name": "NoCode", + "role": "Owner", + "avatar": "/p/assets/img/logo.png", + "joined": "2026-03-17", + "email": null, + "links": [ + { "label": "GitHub", "url": "https://github.com/fkDeath" }, {"label": "Gitea", "url": "https://gitea.nocode-var.tech/nocode"} + ] + }, + { + "name": "Söl", + "role": "Graphic Designer", + "avatar": "/p/assets/img/logo.png", + "joined": "2026-04-26", + "email": null, + "links": [ + { "label": "Portfolio (coming soon)", "url": "https://dev-sol.laxacube.ch" } + ] + }, + { + "name": "Angi", + "role": "Devlopper", + "avatar": "/p/assets/img/logo.png", + "joined": "2026-09-14", + "email": "gianmarco.ruberti@gmail.com", + "links": [ + { "label": "GitHub", "url": "https://github.com/Gianmarco-Ruberti" } + ] + } +] diff --git a/p/equipe/index.php b/p/equipe/index.php new file mode 100644 index 0000000..c8b2833 --- /dev/null +++ b/p/equipe/index.php @@ -0,0 +1,69 @@ + +
    +

    L'équipe

    +

    Les personnes qui contribuent au projet FWS Linux.

    +
    + +
    + +

    Impossible de charger les données des créateurs.

    + +
    + +
    + + <?= e((string) ($creator['name'] ?? $creator['role'] ?? '')) ?> + +
    + +

    + + + + + + A rejoint le + + + + + + + +
    +
    + +
    + +
    diff --git a/p/index/index.html b/p/index/index.html deleted file mode 100644 index 14e6468..0000000 --- a/p/index/index.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - Accueil - - - -
    -
    -

    Navigation one-page

    -

    Le site change de contenu sans changer de page.

    -

    - La page principale vit dans p/index/index.html et le script l'injecte dans le - main quand l'URL pointe vers /?p/index/. -

    -

    Download FWS

    - -
    - -
    -
    -

    Header commun

    -

    Le bandeau du haut reste identique sur chaque vue.

    -
    -
    -

    Footer commun

    -

    Le pied de page reste fixe, quelle que soit la section chargée.

    -
    -
    -

    Injection réelle

    -

    Chaque route peut venir d'un vrai fichier index.html dans p/.

    -
    -
    -
    - - \ No newline at end of file diff --git a/p/index/index.php b/p/index/index.php new file mode 100644 index 0000000..bd5646b --- /dev/null +++ b/p/index/index.php @@ -0,0 +1,117 @@ + + + +
    +
    +

    Installation simplifiée

    +

    Installateur graphique pour une configuration facile et rapide.

    +
    +
    +

    Léger et rapide

    +

    Conçu pour être peu gourmand en ressources : idéal pour redonner vie à d'anciens PC.

    +
    +
    +

    Respect de la vie privée

    +

    Pas de télémétrie intrusive ni de collecte de données : vous gardez le contrôle.

    +
    +
    +

    Compatibilité Windows

    +

    Exécutez vos logiciels Windows avec Wine et Winboat sans devoir rester sous Windows.

    +
    +
    + +
    +
    +

    Choisissez votre environnement à l'installation

    +

    FWS Linux vous laisse choisir l'interface qui correspond à votre usage. Vous pouvez démarrer en CLI minimale ou installer un bureau complet dès le début.

    +
    + +
    +
    +

    KDE Plasma

    +

    Interface moderne, complète et hautement personnalisable. Un excellent choix si vous voulez un bureau riche avec de nombreux outils intégrés.

    +
    +
    + Capture d'écran de l'environnement KDE Plasma sur FWS Linux +
    +
    + +
    +
    + Capture d'écran de l'environnement GNOME sur FWS Linux +
    +
    +

    GNOME

    +

    Expérience épurée et orientée productivité. GNOME met l'accent sur la simplicité d'utilisation et un flux de travail propre sans surcharge visuelle.

    +
    +
    + +
    +
    +

    XFCE

    +

    Environnement léger et très stable, idéal pour les machines modestes ou pour privilégier les performances au quotidien.

    +
    +
    + Capture d'écran de l'environnement XFCE sur FWS Linux +
    +
    + +
    +
    + Capture d'écran de l'environnement Hyprland sur FWS Linux +
    +
    +

    Hyprland

    +

    Tiling Wayland rapide et moderne, pensé pour un workflow clavier et une grande efficacité. Parfait pour les utilisateurs techniques qui aiment optimiser leur espace de travail.

    +
    +
    + +
    +
    +

    CLI (sans environnement)

    +

    Version minimale pour les utilisateurs avancés, les serveurs ou ceux qui veulent construire leur système à la carte. Aucun bureau graphique n'est préinstallé.

    +
    +
    + Capture d'écran de l'interface CLI de FWS Linux +
    +
    +
    diff --git a/p/mentions-legales/index.php b/p/mentions-legales/index.php new file mode 100644 index 0000000..c926191 --- /dev/null +++ b/p/mentions-legales/index.php @@ -0,0 +1,57 @@ + + + + diff --git a/p/paquets/detail.php b/p/paquets/detail.php new file mode 100644 index 0000000..10d60b7 --- /dev/null +++ b/p/paquets/detail.php @@ -0,0 +1,111 @@ + $p) { + if ((int) ($p['dbId'] ?? 0) === $detailId || ($p['dbId'] ?? 0) === 0 && ($i + 1) === $detailId) { + $pkg = $p; + break; + } +} + +if ($pkg === null) { + http_response_code(404); + $title = 'Paquet introuvable | FWS Linux'; + echo '
    ' + . '

    Ce paquet n\'existe pas (il y en a ' . count($packages) . ').

    ' + . '← Tous les paquets' + . '
    '; + return; +} + +$title = $pkg['name'] . ' | FWS Linux'; +$description = (string) ($pkg['tagline'] ?? '') !== '' ? (string) $pkg['tagline'] : (string) ($pkg['description'] ?? ''); +$extraJs[] = fws_url('/p/assets/js/packages-ui.js'); + +$latest = $pkg['latest'] ?? null; +?> +
    + ← Tous les paquets + +
    + +

    +

    +

    +
    + + + + Publiée le + + + Aucune release publiée pour le moment. + +
    +
    + +
    + +

    Historique

    Historique en cours de rédaction.

    + +

    Historique

    +
      + +
    1. + + + + + +
    2. + +
    +
    + + + +

    Captures d'écran

    Captures d'écran à venir.

    + +

    Captures d'écran

    +
    + +
    + <?= e((string) ($screen['alt'] ?? $pkg['name'])) ?> data-caption=""> + +
    — cliquez pour agrandir
    + +
    Cliquez pour agrandir
    + +
    + +
    +
    + +
    + + +
    diff --git a/p/paquets/index.php b/p/paquets/index.php new file mode 100644 index 0000000..e778882 --- /dev/null +++ b/p/paquets/index.php @@ -0,0 +1,121 @@ +' . e($message) . '

    '; +} + +/** + * Historique du paquet. En liste ($limited) : seules les 3 dernières + * versions sont visibles, un bouton « Voir plus » affiche les autres. + */ +function fws_packages_changelog(array $pkg, bool $limited = false): string +{ + $html = '

    Historique

    '; + if (empty($pkg['changelog'])) { + $html .= fws_packages_empty('Historique en cours de rédaction.') . '
    '; + return $html; + } + $entries = array_values($pkg['changelog']); + $total = count($entries); + $extraCount = 0; + if ($limited && $total > 3) { + $extraCount = $total - 3; + } + $html .= '
      0) { + $html .= ' data-expandable'; + } + $html .= '>'; + foreach ($entries as $idx => $entry) { + $html .= '
    1. ' + . '' . e((string) ($entry['version'] ?? '—')) . '' + . '' + . (!empty($entry['notes']) ? '' . e((string) $entry['notes']) . '' : '') + . '
    2. '; + } + $html .= '
    '; + if ($extraCount > 0) { + $html .= ''; + } + $html .= ''; + return $html; +} + +/* Les captures d'écran ne s'affichent que sur la page détail + (« Voir en grand ») : la liste reste compacte. */ + +function fws_packages_links(array $pkg): string +{ + $html = ''; + return $html; + } + foreach ($pkg['links'] as $link) { + $url = (string) ($link['url'] ?? ''); + $external = (bool) preg_match('/^https?:\/\//i', $url); + $html .= '' + . e((string) ($link['label'] ?? '') !== '' ? (string) $link['label'] : $url) . ''; + } + $html .= ''; + return $html; +} + +function fws_packages_card(array $pkg, int $position): string +{ + $latest = $pkg['latest'] ?? null; + $latestText = ($latest !== null && ($latest['name'] ?? '') !== '') + ? 'Dernière release : ' . $latest['name'] . (!empty($latest['date']) ? ' — ' . fws_format_date((string) $latest['date']) : '') + : 'Aucune release publiée pour le moment.'; + + /* En liste : pas d'images (elles ne s'affichent que sur la page + « Voir en grand »), et seules les 3 dernières versions. */ + $html = '
    ' + . '
    ' + . '

    ' . e($pkg['name']) . '

    ' + . '' + . e($pkg['sinceLabel'] !== '' ? $pkg['sinceLabel'] : 'FWS') . '' + . 'Voir en grand' + . '
    ' + . (!empty($pkg['tagline']) ? '

    ' . e($pkg['tagline']) . '

    ' : '') + . '

    ' . e($latestText) . '

    ' + . (!empty($pkg['description']) ? '

    ' . e($pkg['description']) . '

    ' : '') + . '
    ' + . '
    ' . fws_packages_changelog($pkg, true) . fws_packages_links($pkg) . '
    ' + . '
    '; + return $html; +} +?> +
    +

    Paquets

    +

    Tous les outils développés pour FWS Linux, leur historique, leurs captures d'écran et les liens utiles.

    +
    + +
    + + + + $pkg): ?> + + + +
    diff --git a/p/paquets/packages.json b/p/paquets/packages.json new file mode 100644 index 0000000..be6bb49 --- /dev/null +++ b/p/paquets/packages.json @@ -0,0 +1,35 @@ +[ + { + "id": "fws-pacmanage", + "name": "PacManage", + "tagline": "Gestionnaire de paquets pour FWS", + "description": "Gestionnaire de paquets graphique pour FWS : recherche unifiée multi-fournisseurs (Pacman, Flatpak…), système de plugins, mises à jour agrégées et intégration au bureau.", + "since": "2026-08-29", + "sinceLabel": "V1.0.0", + "latest": { "name": "V1.2.1", "date": "2026-08-29" }, + "links": [ + { "label": "Gitea", "url": "https://gitea.nocode-var.tech/FWS/FWS-PacManage" }, + { "label": "Releases", "url": "https://gitea.nocode-var.tech/FWS/FWS-PacManage/releases" } + ], + "screens": [], + "changelog": [ + { "version": "V1.2.1", "date": "2026-08-29", "notes": "" }, + { "version": "V1.0.0", "date": "2026-08-29", "notes": "Version initiale : recherche unifiée Pacman + Flatpak, système de plugins, mises à jour agrégées et intégration au bureau." } + ] + }, + { + "id": "fws-deskmanger", + "name": "DeskManger", + "tagline": "Gestionnaire de bureau pour FWS", + "description": "Le gestionnaire de bureau de FWS, actuellement en cours de développement.", + "since": null, + "sinceLabel": "En développement", + "latest": null, + "links": [ + { "label": "Gitea", "url": "https://gitea.nocode-var.tech/FWS/FWS-DeskManger" }, + { "label": "Releases", "url": "https://gitea.nocode-var.tech/FWS/FWS-DeskManger/releases" } + ], + "screens": [], + "changelog": [] + } +] \ No newline at end of file diff --git a/page.php b/page.php new file mode 100644 index 0000000..4138103 --- /dev/null +++ b/page.php @@ -0,0 +1,303 @@ +/index.php et la coquille + * (header/nav/footer) est écrite une seule fois ici. + */ + +declare(strict_types=1); + +require __DIR__ . '/inc/site.php'; + +/* ───────────────────────── route ───────────────────────── */ + +function fws_site_current_route(): string +{ + $raw = ''; + $qs = (string) ($_SERVER['QUERY_STRING'] ?? ''); + if ($qs !== '') { + if (str_starts_with($qs, 'p=')) { + $raw = substr($qs, 2); + } elseif (str_starts_with($qs, 'p/')) { + $raw = substr($qs, 2); + } + } + if ($raw === '' && isset($_GET['p'])) { + $raw = (string) $_GET['p']; + } + if ($raw === '') { + /* Forme chemin : /p/dl/ (directement sous la base URL). En + sous-dossier (WAMP), REQUEST_URI commence par /FWS-Website/ : on + retire la base pour retrouver le début de la route. */ + $path = trim((string) (parse_url((string) ($_SERVER['REQUEST_URI'] ?? '/'), PHP_URL_PATH) ?: '/'), '/'); + if ($path !== '') { + $base = ltrim(fws_base_url() . '/', '/'); + if ($base !== '' && str_starts_with($path, $base)) { + $path = substr($path, strlen($base)); + $path = trim(preg_replace('/^\\/+|\\/+$/', '', $path) ?? ''); + } + } + if ($path !== '' && !str_contains($path, '.') && str_starts_with($path, 'p/')) { + $raw = substr($path, 2); + } + } + + $raw = strtolower(trim($raw)); + $raw = trim(preg_replace('/^\/+|\/+$/', '', $raw) ?? ''); + if ($raw === '' || $raw === 'home' || $raw === 'accueil' || $raw === 'index') { + return 'index'; + } + return $raw; +} + +$route = fws_site_current_route(); + +/* Résolution du corps de page : index, dl, paquets, paquets/N, equipe, contact. */ +$pageFile = null; +$detailId = 0; +if (preg_match('/^paquets\/(\d+)$/', $route, $m)) { + $detailId = max(1, (int) $m[1]); + $route = 'paquets/_detail'; + $pageFile = __DIR__ . '/p/paquets/detail.php'; +} else { + $known = ['index', 'dl', 'paquets', 'equipe', 'contact', 'mentions-legales', 'conditions', 'confidentialite']; + if (in_array($route, $known, true)) { + $pageFile = __DIR__ . '/p/' . $route . '/index.php'; + } +} + +$is404 = $pageFile === null || !is_file($pageFile); + +/* Erreurs Apache « douces » : les 403/404 déroutés ici via ErrorDocument + * (voir .htaccess) rendent la page 404 du site — jamais de page Apache + * brute, jamais de détail technique. */ +if (in_array((int) ($_GET['__e'] ?? 0), [403, 404], true)) { + $pageFile = null; + $is404 = true; + header('Access-Control-Allow-Origin: *'); + header('Cache-Control: no-store'); + /* Chemins API : JSON pour curl/scripts, page visuelle pour un navigateur + * (négociation via Accept, comme inc/errors.php). */ + $reqPath = (string) (parse_url((string) ($_SERVER['REQUEST_URI'] ?? '/'), PHP_URL_PATH) ?: '/'); + if (str_starts_with($reqPath, '/api') && fws_error_wants_json()) { + http_response_code(404); + header('Content-Type: application/json; charset=utf-8'); + header('X-Content-Type-Options: nosniff'); + exit(json_encode(['ok' => false, 'error' => 'Ressource introuvable.'], JSON_UNESCAPED_UNICODE)); + } +} + +/* Paquets : une seule lecture DB + cache Gitea pour toute la page + (le corps ET la nav déroulante les consomment). */ +$packages = fws_site_packages(); + +/* ───────────────────────── corps de page ───────────────────────── */ +/* Le corps est rendu d'abord : il peut définir $title, $description, + $canonical, $extraCss[] et $extraJs[] (données issues de la DB / API). */ + +/* NB : pas de null pour title/description — isset(null) est false et les + gardes des pages incluses (« isset($title, …) ») échoueraient. */ +$title = ''; +$description = ''; +$canonical = null; +$extraCss = []; +$extraJs = []; + +define('FWS_PAGE_SHELL', 1); /* les corps inclus peuvent vérifier qu'ils + ne sont pas exécutés en accès direct */ + +ob_start(); +if ($is404) { + http_response_code(404); + include __DIR__ . '/p/404.php'; +} else { + include $pageFile; +} +$body = ob_get_clean(); + +if ($title === null) { + $labels = [ + 'index' => 'Accueil', 'dl' => 'Téléchargements', 'paquets' => 'Paquets', + 'paquets/_detail' => 'Paquet', 'equipe' => "L'équipe", 'contact' => 'Contact', + 'mentions-legales' => 'Mentions légales', 'conditions' => "Conditions d'utilisation", + 'confidentialite' => 'Confidentialité', + ]; + $label = $labels[$route] ?? 'FWS Linux'; + $title = $label . ' | FWS Linux'; +} +if ($description === null) { + $description = 'FWS Linux — distribution open-source basée sur Arch Linux. Installation simplifiée, léger, respectueux de la vie privée, compatible Windows grâce à Wine et Winboat.'; +} +if ($canonical === null) { + $canonRoute = $route === 'paquets/_detail' ? 'paquets/' . $detailId : $route; + /* Portabilité : hôte courant + base URL (sous-dossier WAMP inclus), + au lieu du domaine de production codé en dur. */ + $fwsScheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') + || (($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') === 'https') ? 'https' : 'http'; + $fwsHost = trim((string) ($_SERVER['HTTP_HOST'] ?? '')) !== '' + ? (string) $_SERVER['HTTP_HOST'] : 'fwslinux.fr'; + $canonical = $fwsScheme . '://' . $fwsHost . fws_url('/?p/' . ($canonRoute === 'index' ? 'index' : $canonRoute) . '/'); +} + +function fws_site_active(string $route, string $prefix): string +{ + return $route === $prefix || str_starts_with($route, $prefix . '/') + ? ' aria-current="page"' : ''; +} +?> + + + + + + <?= e($title) ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + +
    + +
    + + +
    + + + + + + + + diff --git a/tools/router.php b/tools/router.php new file mode 100644 index 0000000..0cec78c --- /dev/null +++ b/tools/router.php @@ -0,0 +1,46 @@ + { + const upstream = net.connect(TARGET_PORT, TARGET_HOST); + client.pipe(upstream); + upstream.pipe(client); + const cleanup = () => { + client.destroy(); + upstream.destroy(); + }; + client.on("error", cleanup); + upstream.on("error", cleanup); +}); + +server.listen(LISTEN, "127.0.0.1", () => { + console.log(`forwarding 127.0.0.1:${LISTEN} -> ${TARGET_HOST}:${TARGET_PORT}`); +});