Template
Feat(site): rendu serveur PHP — paquets en SQLite, releases Gitea, build ISO
- Front controller page.php + inc/site.php : coquille et pages rendues
en PHP (accueil, dl, paquets, paquets/N, equipe, contact, 404) ; les
URLs ne changent pas et l'apparence est conservée.
- Paquets stockés dans la base SQLite partagée (table packages),
éditables depuis l'onglet 📦 Paquets de /admin/bugs, avec bouton de
synchronisation des releases depuis l'API Gitea du dépôt lié.
Repli automatique sur packages.json si la base est vide.
- Releases ISO de la page Téléchargements récupérées côté serveur
(Gitea FWS/ISO sinon GitHub) avec cache fichier 10 min ; note de
release rendue en Markdown serveur (Voir plus / Voir moins).
- Suppression du routeur SPA et des chargeurs JS devenus inutiles
(app.js, packages.js, downloads.js, creators-loader.js, index.html) ;
restent nav.js, note-toggle.js et hero-carousel.js.
- Panneau admin : onglet Build ISO (git pull sur main, build.sh avec
repli setup-aur.sh, terminal des logs en direct), durcissement UTF-8
à l'écriture des paquets (json_encode ne casse plus sur des accents
mal encodés), 404 réels et gardes d'accès direct sur les corps PHP.
This commit is contained in:
1 parent
34b3f1cf3c
commit
1775adceaa
34 files changed
+2799
-1862
No files matched your search
@@ -17,3 +17,6 @@ api/bugs/data/*.db-shm
|
||||
*.sqlite
|
||||
*.sqlite-wal
|
||||
*.sqlite-shm
|
||||
|
||||
# Cache HTTP local du site (releases Gitea/GitHub, généré par inc/site.php)
|
||||
cache/
|
||||
@@ -1,5 +1,10 @@
|
||||
# ── 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
|
||||
|
||||
|
||||
+47
-173
@@ -1,183 +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 `<head>` 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/<route>/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/<route>/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.
|
||||
- [.htaccess](../.htaccess) contient la configuration Apache (`Options +Indexes`).
|
||||
- [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.
|
||||
- [p/contact/index.html](../p/contact/index.html) contient la page contact.
|
||||
- [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
|
||||
<main data-page-content>
|
||||
...
|
||||
</main>
|
||||
```
|
||||
|
||||
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
|
||||
<head>
|
||||
<link rel="stylesheet" href="./page.css" />
|
||||
<style>
|
||||
.hero {
|
||||
background: black;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
```
|
||||
|
||||
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
|
||||
<a href="/?p/contact/" data-route="contact">Contact</a>
|
||||
```
|
||||
|
||||
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é.
|
||||
|
||||
## Fichier .htaccess
|
||||
|
||||
Le fichier [.htaccess](../.htaccess) à la racine contient la directive Apache suivante :
|
||||
|
||||
```apache
|
||||
Options +Indexes
|
||||
```
|
||||
|
||||
Cela active l'**indexation des répertoires** : si un dossier ne contient pas de fichier `index.html`, Apache affiche automatiquement la liste de son contenu.
|
||||
|
||||
### Points à noter
|
||||
|
||||
- Cette option ne fonctionne que si le serveur Apache a `AllowOverride Options` (ou `AllowOverride All`) activé dans sa configuration.
|
||||
- En production, il peut être préférable de désactiver les indexes pour des raisons de sécurité. Remplacez par `Options -Indexes` si besoin.
|
||||
- Le fichier `.htaccess` est placé à la racine du projet pour couvrir tous les sous-dossiers.
|
||||
|
||||
## Structure de la documentation
|
||||
|
||||
La documentation du projet est dans le dossier `Doc/` et rédigée en Markdown :
|
||||
|
||||
```
|
||||
Doc/
|
||||
└── fonctionnement-onepage.md # Ce fichier
|
||||
```
|
||||
|
||||
Chaque fichier `.md` documente un aspect du projet. Le README à la racine (`README.md`) donne une vue d'ensemble rapide.
|
||||
- `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).
|
||||
@@ -0,0 +1,558 @@
|
||||
<?php
|
||||
/**
|
||||
* FWS — Onglet « Build ISO » du panneau admin des signalements.
|
||||
*
|
||||
* URL : admin/bugs/build.php
|
||||
*
|
||||
* Réservé aux comptes autorisés (voir fws_bugs_can_build() dans
|
||||
* api/bugs/db.php, par défaut : « admin »). Lance le pipeline
|
||||
* admin/bugs/run-build.sh dans un process détaché (nohup) et expose un
|
||||
* mini-terminal : les logs sont lus en direct par polling (act=tail) et les
|
||||
* actions start / stop / clear sont protégées par CSRF comme le reste du
|
||||
* panneau.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../../api/bugs/db.php';
|
||||
|
||||
session_set_cookie_params([
|
||||
'httponly' => 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) . ' </dev/null >> ' . 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');
|
||||
?><!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="robots" content="noindex,nofollow">
|
||||
<title>Build ISO — FWS Linux</title>
|
||||
<style>
|
||||
:root { color-scheme: dark; }
|
||||
* { box-sizing: border-box; }
|
||||
body {
|
||||
margin: 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
|
||||
background: #0b1120; color: #e2e8f0; line-height: 1.5;
|
||||
}
|
||||
.wrap { max-width: 1000px; margin: 0 auto; padding: 24px 16px 80px; }
|
||||
header.top {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
gap: 12px; padding: 14px 0; border-bottom: 1px solid #1e293b; margin-bottom: 20px;
|
||||
}
|
||||
header.top h1 { font-size: 1.15rem; margin: 0; }
|
||||
header.top .sub { font-size: .8rem; color: #94a3b8; }
|
||||
a { color: #38bdf8; text-decoration: none; }
|
||||
a:hover { text-decoration: underline; }
|
||||
.btn {
|
||||
display: inline-block; border: 1px solid #334155; background: #1e293b; color: #e2e8f0;
|
||||
padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: .85rem;
|
||||
text-decoration: none; line-height: 1.4;
|
||||
}
|
||||
.btn:hover { background: #334155; text-decoration: none; }
|
||||
.btn.primary { background: #0284c7; border-color: #0284c7; color: #fff; }
|
||||
.btn.danger { background: transparent; border-color: #7f1d1d; color: #f87171; }
|
||||
.btn.danger:hover { background: #7f1d1d; color: #fff; }
|
||||
.btn:disabled { opacity: .45; cursor: not-allowed; }
|
||||
.card {
|
||||
background: #111a2e; border: 1px solid #1e293b; border-radius: 12px;
|
||||
padding: 16px; margin-bottom: 12px;
|
||||
}
|
||||
.card h3 { margin: 0 0 4px; font-size: 1rem; }
|
||||
.card .meta { font-size: .78rem; color: #94a3b8; display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 8px; }
|
||||
.navtabs { display: flex; gap: 8px; margin: 0 0 16px; }
|
||||
.navtabs a { border: 1px solid #334155; padding: 5px 14px; border-radius: 99px; font-size: .85rem; text-decoration: none; color: #cbd5e1; }
|
||||
.navtabs a.active { background: #0284c7; border-color: #0284c7; color: #fff; }
|
||||
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .9rem; }
|
||||
.flash.err { background: #450a0a; color: #fca5a5; border: 1px solid #7f1d1d; }
|
||||
.status-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
|
||||
.dot { width: 10px; height: 10px; border-radius: 50%; background: #64748b; flex: none; }
|
||||
.dot.run { background: #4ade80; animation: pulse 1.2s ease-in-out infinite; }
|
||||
@keyframes pulse { 50% { opacity: .25; } }
|
||||
pre.term {
|
||||
background: #020617; border: 1px solid #1e293b; border-radius: 8px;
|
||||
padding: 12px; overflow: auto; max-height: 62vh; font-size: .76rem; line-height: 1.45;
|
||||
white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Consolas, "Cascadia Mono", monospace;
|
||||
color: #bae6fd;
|
||||
}
|
||||
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
|
||||
.hint { font-size: .78rem; color: #64748b; margin-top: 10px; }
|
||||
.hint code { background: #0b1120; border: 1px solid #1e293b; padding: 1px 5px; border-radius: 6px; }
|
||||
#authForm { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-top: 6px; }
|
||||
#authForm label { font-size: .78rem; color: #94a3b8; display: block; margin-bottom: 2px; }
|
||||
#authForm input[type=text], #authForm input[type=password] {
|
||||
width: 230px; padding: 7px 9px; background: #0b1120; border: 1px solid #334155;
|
||||
border-radius: 8px; color: #e2e8f0; font-size: .9rem;
|
||||
}
|
||||
#authState { font-size: .8rem; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
|
||||
<header class="top">
|
||||
<div>
|
||||
<h1>🔨 Build ISO</h1>
|
||||
<div class="sub">Connecté : <?= h_build($user['name']) ?> · dépôt : <code>D:\FWS-ISO</code> (branche main)</div>
|
||||
</div>
|
||||
<form method="post" action="index.php">
|
||||
<input type="hidden" name="action" value="logout">
|
||||
<input type="hidden" name="csrf" value="<?= h_build(csrf_token_build()) ?>">
|
||||
<button class="btn" type="submit">Déconnexion</button>
|
||||
</form>
|
||||
</header>
|
||||
|
||||
<div class="navtabs">
|
||||
<a href="index.php">🐞 Signalements</a>
|
||||
<a href="index.php?view=invites">👥 Invitations & comptes</a>
|
||||
<a href="build.php" class="active">🔨 Build ISO</a>
|
||||
</div>
|
||||
|
||||
<?php if (!$allowed): ?>
|
||||
<div class="card">
|
||||
<h3>Accès restreint</h3>
|
||||
<p>Votre compte (<strong><?= h_build($user['name']) ?></strong>) n'est pas autorisé à lancer des builds.
|
||||
Seul le compte <code>admin</code> le peut (voir <code>fws_bugs_can_build()</code> dans <code>api/bugs/db.php</code>).</p>
|
||||
<a class="btn" href="index.php">← Retour aux signalements</a>
|
||||
</div>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<div class="card">
|
||||
<h3>🔑 Accès Gitea (pour le git pull)</h3>
|
||||
<p style="font-size:.82rem;color:#cbd5e1;margin:6px 0 2px">
|
||||
Le dépôt <code>D:\FWS-ISO</code> est privé et le build tourne dans un conteneur sans tes identifiants
|
||||
Windows : crée un token dans Gitea (<em>Settings → Applications → Generate New Token</em>, lecture du dépôt)
|
||||
puis enregistre-le ici. Il n'est stocké que sur ce serveur — jamais commité, jamais affiché dans les logs.
|
||||
</p>
|
||||
<span id="authState">…</span>
|
||||
<form id="authForm">
|
||||
<div>
|
||||
<label for="gUser">Utilisateur Gitea (défaut : fws)</label>
|
||||
<input type="text" id="gUser" name="username" autocomplete="off">
|
||||
</div>
|
||||
<div>
|
||||
<label for="gToken">Token</label>
|
||||
<input type="password" id="gToken" name="token" autocomplete="off" placeholder="token de lecture">
|
||||
</div>
|
||||
<button class="btn primary" type="submit">Enregistrer</button>
|
||||
<button class="btn danger" type="button" id="gClear">Retirer</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h3>🖥️ Terminal du build</h3>
|
||||
<div class="meta">
|
||||
<span id="stateLabel">État : inconnu…</span>
|
||||
<span>· Git Bash lancerait ici : <code style="font-size:.95em">git checkout main && git pull && bash build.sh</code></span>
|
||||
</div>
|
||||
|
||||
<pre class="term" id="term">Chargement du terminal…</pre>
|
||||
|
||||
<div class="actions">
|
||||
<button class="btn primary" id="btnStart" type="button">▶ Lancer le build</button>
|
||||
<button class="btn danger" id="btnStop" type="button">⏹ Arrêter</button>
|
||||
<button class="btn" id="btnClear" type="button">🗑 Effacer le log</button>
|
||||
<span id="rcLabel"></span>
|
||||
</div>
|
||||
|
||||
<p class="hint">
|
||||
Le build se déroule dans un conteneur <code>archlinux</code> jetable (via Docker Desktop, comme
|
||||
<code>build.sh</code> à la main) : passage sur <code>main</code> → <code>git pull</code> → <code>bash build.sh</code> ;
|
||||
en cas d'échec de build, <code>bash setup-aur.sh</code> est lancé puis <code>build.sh</code> est relancé.
|
||||
Si le checkout de <code>main</code> est bloqué par des modifications locales non commitées dans
|
||||
<code>D:\FWS-ISO</code>, le build s'arrête proprement sans rien toucher. L'ISO sort dans
|
||||
<code>D:\FWS-ISO\out\</code>. Peut prendre 30 min et plus — laissez l'onglet ouvert, les logs défilent en direct.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
<script>
|
||||
(() => {
|
||||
const allowed = <?= $allowed ? 'true' : 'false' ?>;
|
||||
if (!allowed) return;
|
||||
|
||||
const CSRF = <?= json_encode(csrf_token_build()) ?>;
|
||||
const term = document.getElementById('term');
|
||||
const btnS = document.getElementById('btnStart');
|
||||
const btnT = document.getElementById('btnStop');
|
||||
const btnC = document.getElementById('btnClear');
|
||||
const stateL = document.getElementById('stateLabel');
|
||||
const rcL = document.getElementById('rcLabel');
|
||||
const csrfP = new URLSearchParams();
|
||||
csrfP.set('csrf', CSRF);
|
||||
|
||||
let pos = -1;
|
||||
let running = null;
|
||||
let finishedRc = null;
|
||||
|
||||
const authState = document.getElementById('authState');
|
||||
const authForm = document.getElementById('authForm');
|
||||
const gUser = document.getElementById('gUser');
|
||||
const gToken = document.getElementById('gToken');
|
||||
const gClear = document.getElementById('gClear');
|
||||
|
||||
async function refreshAuth() {
|
||||
const r = await api('auth_status');
|
||||
if (r.json && r.json.ok) {
|
||||
authState.textContent = r.json.configured
|
||||
? '✅ Token Gitea enregistré' + (r.json.username ? ' (compte : ' + r.json.username + ')' : '')
|
||||
: '⚠️ Aucun token Gitea : le git pull échouera (dépôt privé).';
|
||||
}
|
||||
}
|
||||
|
||||
authForm.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const p = new URLSearchParams(csrfP);
|
||||
p.set('username', gUser.value.trim());
|
||||
p.set('token', gToken.value);
|
||||
const r = await api('save_auth', p);
|
||||
if (r.json && r.json.ok) {
|
||||
gUser.value = gToken.value = '';
|
||||
await refreshAuth();
|
||||
} else {
|
||||
alert(r.json && r.json.error ? r.json.error : 'Erreur.');
|
||||
}
|
||||
});
|
||||
|
||||
gClear.addEventListener('click', async () => {
|
||||
if (!confirm('Retirer le token Gitea enregistré ?')) return;
|
||||
const p = new URLSearchParams(csrfP);
|
||||
p.set('username', '');
|
||||
p.set('token', '');
|
||||
const r = await api('save_auth', p);
|
||||
if (r.json && r.json.ok) await refreshAuth();
|
||||
});
|
||||
|
||||
function stick() {
|
||||
const near = term.scrollHeight - term.scrollTop - term.clientHeight < 90;
|
||||
if (near || running !== false) term.scrollTop = term.scrollHeight;
|
||||
}
|
||||
|
||||
function setUI() {
|
||||
btnS.disabled = running === true;
|
||||
btnT.disabled = running !== true;
|
||||
btnC.disabled = running === true;
|
||||
const dot = document.querySelector('.status-line .dot') ||
|
||||
(() => { const d = document.createElement('span'); d.className = 'dot'; stateL.prepend(d); return d; })();
|
||||
dot.className = 'dot' + (running ? ' run' : '');
|
||||
if (running === true) {
|
||||
stateL.textContent = 'État : build en cours… ';
|
||||
} else if (running === false) {
|
||||
stateL.textContent = 'État : inactif. ';
|
||||
}
|
||||
}
|
||||
|
||||
async function api(act, body) {
|
||||
const opt = body
|
||||
? { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: body }
|
||||
: { method: 'GET' };
|
||||
const r = await fetch('build.php?act=' + encodeURIComponent(act), opt);
|
||||
return { status: r.status, json: await r.json().catch(() => null) };
|
||||
}
|
||||
|
||||
async function poll() {
|
||||
try {
|
||||
const r = await fetch('build.php?act=tail&pos=' + pos);
|
||||
const j = await r.json();
|
||||
if (!j || j.ok !== true) return;
|
||||
if (j.text && j.text !== '') {
|
||||
const wasEmpty = term.textContent === 'Chargement du terminal…';
|
||||
if (wasEmpty) term.textContent = '';
|
||||
const atEnd = term.scrollHeight - term.scrollTop - term.clientHeight < 90;
|
||||
term.textContent += j.text;
|
||||
if (running !== false || atEnd) term.scrollTop = term.scrollHeight;
|
||||
}
|
||||
pos = j.pos;
|
||||
if (j.running !== running) {
|
||||
running = j.running;
|
||||
if (!running && j.rc !== null) {
|
||||
finishedRc = j.rc;
|
||||
rcL.textContent = 'Code de sortie : ' + j.rc + (j.rc === 0 ? ' ✅' : ' ❌');
|
||||
}
|
||||
if (running) { rcL.textContent = ''; finishedRc = null; }
|
||||
setUI();
|
||||
}
|
||||
} catch (e) { /* requête interrompue (navigation…) : on réessaie au prochain tick */ }
|
||||
}
|
||||
|
||||
btnS.addEventListener('click', async () => {
|
||||
if (running === true) return;
|
||||
if (!confirm('Lancer le build ISO ?\n\nPassage sur main → git pull → bash build.sh'
|
||||
+ ' (repli setup-aur.sh en cas d' + '\u2019échec).\nLe dépôt D:\\FWS-ISO ne doit pas être utilisé ailleurs pendant le build.')) return;
|
||||
const p = new URLSearchParams(csrfP); p.set('act', 'start');
|
||||
const r = await api('start', p);
|
||||
if (r.json && r.json.ok) { pos = -1; await poll(); } else { alert(r.json && r.json.error ? r.json.error : 'Erreur au démarrage.'); }
|
||||
});
|
||||
|
||||
btnT.addEventListener('click', async () => {
|
||||
if (running !== true) return;
|
||||
if (!confirm('Arrêter le build en cours ?')) return;
|
||||
const p = new URLSearchParams(csrfP); p.set('act', 'stop');
|
||||
const r = await api('stop', p);
|
||||
if (r.json && r.json.ok) { await poll(); } else { alert(r.json && r.json.error ? r.json.error : 'Erreur à l' + '\u2019arrêt.'); }
|
||||
});
|
||||
|
||||
btnC.addEventListener('click', async () => {
|
||||
if (running === true) return;
|
||||
const p = new URLSearchParams(csrfP); p.set('act', 'clear');
|
||||
const r = await api('clear', p);
|
||||
if (r.json && r.json.ok) { term.textContent = ''; pos = -1; rcL.textContent = ''; } else { alert(r.json && r.json.error ? r.json.error : 'Erreur.'); }
|
||||
});
|
||||
|
||||
setUI();
|
||||
refreshAuth();
|
||||
poll();
|
||||
setInterval(poll, 1000);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+319
-2
@@ -81,11 +81,101 @@ function excerpt(string $s, int $len = 140): string
|
||||
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;
|
||||
}
|
||||
|
||||
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'] ?? '';
|
||||
@@ -197,12 +287,119 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$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();
|
||||
$savedId = fws_packages_save($pdo, [
|
||||
'id' => (int) ($_POST['pkg_id'] ?? 0),
|
||||
'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_from_lines((string) ($_POST['screens'] ?? '')),
|
||||
'changelog' => changelog_from_lines((string) ($_POST['changelog'] ?? '')),
|
||||
]);
|
||||
$wasEdit = (int) ($_POST['pkg_id'] ?? 0) > 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();
|
||||
fws_packages_delete($pdo, $pkgId);
|
||||
$_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 {
|
||||
@@ -214,6 +411,8 @@ try {
|
||||
|
||||
$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];
|
||||
@@ -293,10 +492,13 @@ form.inline { display: inline; }
|
||||
.login-box { max-width: 380px; margin: 12vh auto; }
|
||||
.login-box .card { padding: 28px; }
|
||||
.login-box h1 { font-size: 1.25rem; margin-top: 0; }
|
||||
input[type=text], input[type=password] {
|
||||
input[type=text], input[type=password], input[type=date], textarea {
|
||||
width: 100%; padding: 9px 11px; margin: 6px 0 14px;
|
||||
background: #0b1120; border: 1px solid #334155; border-radius: 8px; color: #e2e8f0; font-size: .95rem;
|
||||
font-family: inherit;
|
||||
}
|
||||
textarea { resize: vertical; min-height: 70px; }
|
||||
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
|
||||
label { font-size: .85rem; color: #cbd5e1; }
|
||||
.back { margin-bottom: 12px; display: inline-block; }
|
||||
.pager { display: flex; gap: 8px; margin-top: 16px; }
|
||||
@@ -357,8 +559,10 @@ table.list th { color: #94a3b8; font-size: .72rem; text-transform: uppercase; le
|
||||
</header>
|
||||
|
||||
<div class="navtabs">
|
||||
<a href="index.php" class="<?= $view_invites ? '' : 'active' ?>">🐞 Signalements</a>
|
||||
<a href="index.php" class="<?= ($view_invites || $view_packages) ? '' : 'active' ?>">🐞 Signalements</a>
|
||||
<a href="index.php?view=invites" class="<?= $view_invites ? 'active' : '' ?>">👥 Invitations & comptes</a>
|
||||
<a href="index.php?view=packages" class="<?= $view_packages ? 'active' : '' ?>">📦 Paquets</a>
|
||||
<?php if (fws_bugs_can_build($user['name'])): ?><a href="build.php">🔨 Build ISO</a><?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($error): ?><div class="flash err"><?= h($error) ?></div><?php endif; ?>
|
||||
@@ -548,6 +752,119 @@ table.list th { color: #94a3b8; font-size: .72rem; text-transform: uppercase; le
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php elseif ($view_packages): /* ─────────── PAQUETS ─────────── */
|
||||
|
||||
$pkgRows = $pdo->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) ?: []));
|
||||
$fScreens = lines_from_screens((array) (json_decode((string) $form['screens'], true) ?: []));
|
||||
$fChangelog = lines_from_changelog((array) (json_decode((string) $form['changelog'], true) ?: []));
|
||||
?>
|
||||
|
||||
<div class="card">
|
||||
<h3><?= $editing !== null ? '✏️ Modifier « ' . h($editing['name']) . ' »' : '➕ Nouveau paquet' ?></h3>
|
||||
<?php if ($editing !== null): ?><p style="font-size:.85rem;color:#94a3b8"><a href="index.php?view=packages">← Annuler la modification</a></p><?php endif; ?>
|
||||
<p style="font-size:.85rem;color:#94a3b8">Les champs « une ligne par entrée » utilisent le format <code>Label | URL</code> (liens),
|
||||
<code>Version | Date | Notes</code> (historique) et <code>src | alt | légende</code> (captures).</p>
|
||||
<form method="post" style="display:grid;gap:2px;max-width:680px">
|
||||
<input type="hidden" name="action" value="pkg_save">
|
||||
<input type="hidden" name="csrf" value="<?= h(csrf_token()) ?>">
|
||||
<input type="hidden" name="pkg_id" value="<?= (int) $form['id'] ?>">
|
||||
<div class="grid2">
|
||||
<div>
|
||||
<label for="pkg_name">Nom *</label>
|
||||
<input type="text" id="pkg_name" name="name" required value="<?= h($form['name']) ?>">
|
||||
</div>
|
||||
<div>
|
||||
<label for="pkg_slug">Slug / id (vide = auto)</label>
|
||||
<input type="text" id="pkg_slug" name="slug" value="<?= h($form['slug']) ?>" placeholder="ex. fws-pacmanage">
|
||||
</div>
|
||||
</div>
|
||||
<label for="pkg_tagline">Tagline</label>
|
||||
<input type="text" id="pkg_tagline" name="tagline" value="<?= h($form['tagline']) ?>">
|
||||
<label for="pkg_desc">Description</label>
|
||||
<textarea id="pkg_desc" name="description" rows="3"><?= h($form['description']) ?></textarea>
|
||||
<div class="grid2">
|
||||
<div>
|
||||
<label for="pkg_since">Disponible depuis (date)</label>
|
||||
<input type="date" id="pkg_since" name="since" value="<?= h((string) ($form['since'] ?? '')) ?>">
|
||||
</div>
|
||||
<div>
|
||||
<label for="pkg_since_label">Badge « depuis »</label>
|
||||
<input type="text" id="pkg_since_label" name="since_label" value="<?= h($form['since_label']) ?>" placeholder="V1.0.0 / En développement">
|
||||
</div>
|
||||
<div>
|
||||
<label for="pkg_latest_name">Dernière release (nom)</label>
|
||||
<input type="text" id="pkg_latest_name" name="latest_name" value="<?= h($form['latest_name']) ?>" placeholder="V1.2.1">
|
||||
</div>
|
||||
<div>
|
||||
<label for="pkg_latest_date">Date de la release</label>
|
||||
<input type="date" id="pkg_latest_date" name="latest_date" value="<?= h((string) ($form['latest_date'] ?? '')) ?>">
|
||||
</div>
|
||||
</div>
|
||||
<label for="pkg_links">Liens utiles — une ligne par lien : <code>Label | URL</code></label>
|
||||
<textarea id="pkg_links" name="links" rows="3" placeholder="Gitea | https://gitea.nocode-var.tech/FWS/FWS-PacManage"><?= h($fLinks) ?></textarea>
|
||||
<label for="pkg_changelog">Historique — une ligne par version : <code>Version | Date | Notes</code></label>
|
||||
<textarea id="pkg_changelog" name="changelog" rows="5" placeholder="V1.2.1 | 2026-08-29 | Correction de bugs"><?= h($fChangelog) ?></textarea>
|
||||
<label for="pkg_screens">Captures d'écran — une ligne : <code>src | alt | légende</code></label>
|
||||
<textarea id="pkg_screens" name="screens" rows="2" placeholder="/p/assets/img/… | Alt | Légende"><?= h($fScreens) ?></textarea>
|
||||
<button class="btn primary" type="submit" style="justify-self:start;margin-top:4px">💾 Enregistrer</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h3>📦 Paquets (<?= count($pkgRows) ?>)</h3>
|
||||
<?php if (!$pkgRows): ?>
|
||||
<p class="empty">Aucun paquet. Créez le premier avec le formulaire ci-dessus.</p>
|
||||
<?php else: ?>
|
||||
<table class="list">
|
||||
<tr><th>#</th><th>Nom</th><th>Dernière release</th><th></th></tr>
|
||||
<?php foreach ($pkgRows as $pr): ?>
|
||||
<tr>
|
||||
<td><?= (int) $pr['id'] ?></td>
|
||||
<td>
|
||||
<strong><?= h($pr['name']) ?></strong>
|
||||
<?php if ($pr['slug'] !== ''): ?><br><span style="font-size:.75rem;color:#64748b"><?= h($pr['slug']) ?></span><?php endif; ?>
|
||||
<?php if ($pr['tagline'] !== ''): ?><br><span style="font-size:.8rem;color:#94a3b8"><?= h($pr['tagline']) ?></span><?php endif; ?>
|
||||
</td>
|
||||
<td><?= h($pr['latest_name'] !== '' ? $pr['latest_name'] . ($pr['latest_date'] !== null ? ' — ' . $pr['latest_date'] : '') : '—') ?></td>
|
||||
<td style="text-align:right;white-space:nowrap">
|
||||
<a class="btn small" href="index.php?view=packages&edit=<?= (int) $pr['id'] ?>">✏️ Modifier</a>
|
||||
<form class="inline" method="post" onsubmit="return confirm('Synchroniser « <?= h($pr['name']) ?> » depuis Gitea ? (latest + historique)')">
|
||||
<input type="hidden" name="action" value="pkg_sync_gitea">
|
||||
<input type="hidden" name="csrf" value="<?= h(csrf_token()) ?>">
|
||||
<input type="hidden" name="pkg_id" value="<?= (int) $pr['id'] ?>">
|
||||
<button class="btn small" type="submit" title="Rafraîchit la dernière release et l'historique depuis Gitea">🔄 Gitea</button>
|
||||
</form>
|
||||
<form class="inline" method="post" onsubmit="return confirm('Supprimer le paquet « <?= h($pr['name']) ?> » ?')">
|
||||
<input type="hidden" name="action" value="pkg_delete">
|
||||
<input type="hidden" name="csrf" value="<?= h(csrf_token()) ?>">
|
||||
<input type="hidden" name="pkg_id" value="<?= (int) $pr['id'] ?>">
|
||||
<button class="btn small danger" type="submit">🗑 Supprimer</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php else: /* ─────────── LISTE ─────────── */
|
||||
|
||||
$filter = $_GET['status'] ?? 'tous';
|
||||
|
||||
@@ -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"
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* FWS Linux — configuration locale des notifications Discord.
|
||||
* FWS Linux — configuration locale des notifications Discord + build ISO.
|
||||
*
|
||||
* Copie ce fichier en « config.local.php » et remplis-le :
|
||||
*
|
||||
@@ -22,15 +22,24 @@
|
||||
* (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' => '',
|
||||
'tags' => [
|
||||
'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' => '',
|
||||
],
|
||||
];
|
||||
];
|
||||
@@ -2,3 +2,7 @@
|
||||
*.sqlite
|
||||
*.sqlite-wal
|
||||
*.sqlite-shm
|
||||
fws_bugs.sqlite
|
||||
|
||||
# Logs / états de l'onglet « Build ISO » (admin/bugs/build.php)
|
||||
/build/
|
||||
+206
-1
@@ -6,6 +6,36 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/* ───────────── UTF-8 (partagé avec inc/site.php, gardes function_exists) ── */
|
||||
|
||||
if (!function_exists('fws_utf8_str')) {
|
||||
/** UTF-8 valide obligatoire : les octets invalides (Windows-1252…) sont
|
||||
* convertis, sinon json_encode échoue et casse tout l'appelant. */
|
||||
function fws_utf8_str(string $s): string
|
||||
{
|
||||
if (mb_check_encoding($s, 'UTF-8')) {
|
||||
return $s;
|
||||
}
|
||||
$conv = @mb_convert_encoding($s, 'UTF-8', 'Windows-1252');
|
||||
return is_string($conv) ? $conv : (string) mb_convert_encoding($s, 'UTF-8', 'UTF-8');
|
||||
}
|
||||
|
||||
function fws_utf8_arr(array $a): array
|
||||
{
|
||||
$out = [];
|
||||
foreach ($a as $k => $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;
|
||||
@@ -98,6 +128,25 @@ function fws_bugs_schema(PDO $pdo): void
|
||||
)'
|
||||
);
|
||||
|
||||
/* 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);
|
||||
}
|
||||
@@ -108,7 +157,7 @@ function fws_bugs_schema(PDO $pdo): void
|
||||
*/
|
||||
function fws_bugs_next_id(PDO $pdo, string $table): int
|
||||
{
|
||||
if (!in_array($table, ['bug_reports', 'admin_users', 'invite_codes'], true)) {
|
||||
if (!in_array($table, ['bug_reports', 'admin_users', 'invite_codes', 'packages'], true)) {
|
||||
throw new InvalidArgumentException('Table inconnue : ' . $table);
|
||||
}
|
||||
$used = [];
|
||||
@@ -200,3 +249,159 @@ function fws_bugs_client_ip(): string
|
||||
}
|
||||
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),
|
||||
':screens' => (string) json_encode(fws_utf8_arr((array) ($d['screens'] ?? [])), 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;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* FWS Linux — API publique des paquets.
|
||||
*
|
||||
* GET /api/packages.php → liste des paquets au même format que
|
||||
* l'ancien p/paquets/packages.json (consommée par packages.js).
|
||||
*
|
||||
* Les données sont stockées dans la base SQLite partagée (api/bugs/data/)
|
||||
* et modifiables depuis le panneau admin (admin/bugs/index.php?view=packages).
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require __DIR__ . '/bugs/db.php';
|
||||
|
||||
try {
|
||||
$pdo = fws_bugs_db();
|
||||
/* Premier démarrage : la table est vide → on importe packages.json une fois. */
|
||||
fws_packages_seed_if_empty($pdo);
|
||||
$packages = fws_packages_all($pdo);
|
||||
} catch (Throwable $e) {
|
||||
error_log('[fws-packages] ' . $e->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);
|
||||
+610
@@ -0,0 +1,610 @@
|
||||
<?php
|
||||
/**
|
||||
* FWS Linux — bibliothèque du site.
|
||||
*
|
||||
* Tout est rendu côté serveur (PHP) : les pages sont de vraies pages HTML.
|
||||
* Les données viennent de la base SQLite (paquets, modifiables dans
|
||||
* /admin/bugs) et des API Gitea / GitHub (releases, avec cache fichier).
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
define('FWS_SITE_ROOT', dirname(__DIR__));
|
||||
define('FWS_SITE_CACHE_DIR', FWS_SITE_ROOT . '/cache');
|
||||
define('FWS_SITE_CACHE_TTL', 600); // 10 minutes
|
||||
|
||||
/* ───────────────────────── utilitaires ───────────────────────── */
|
||||
|
||||
/** Échappement HTML. */
|
||||
function e(?string $s): string
|
||||
{
|
||||
return htmlspecialchars((string) $s, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
/* 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', '<strong><em>$1</em></strong>', $t) ?? $t;
|
||||
$t = preg_replace('/\*\*(.+?)\*\*/s', '<strong>$1</strong>', $t) ?? $t;
|
||||
$t = preg_replace('/\*(.+?)\*/s', '<em>$1</em>', $t) ?? $t;
|
||||
$t = preg_replace('/`([^`]+)`/', '<code>$1</code>', $t) ?? $t;
|
||||
$t = preg_replace('/!\[([^\]]*)\]\(([^)\s]+)\)/', '<img alt="$1" src="$2" loading="lazy">', $t) ?? $t;
|
||||
$t = preg_replace('/\[([^\]]+)\]\(([^)\s]+)\)/', '<a href="$2" target="_blank" rel="noreferrer">$1</a>', $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 . '</' . $listKind . ">\n";
|
||||
$listBuf = '';
|
||||
$listKind = '';
|
||||
}
|
||||
};
|
||||
$flushTable = function () use (&$html, &$tableRows, &$tableHeader) {
|
||||
if ($tableRows !== []) {
|
||||
$html .= "<table>\n" . implode("\n", $tableRows) . "\n</table>\n";
|
||||
$tableRows = [];
|
||||
$tableHeader = true;
|
||||
}
|
||||
};
|
||||
$flushQuote = function () use (&$html, &$quoteBuf) {
|
||||
if ($quoteBuf !== '') {
|
||||
$html .= '<blockquote>' . $quoteBuf . "</blockquote>\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 .= '<pre><code' . $langAttr . '>' . fws_md_escape(trim($code)) . "</code></pre>\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 .= '<h' . $lvl . '>' . fws_md_inline($m[2]) . '</h' . $lvl . ">\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preg_match('/^[-*_]{3,}\s*$/', trim($line))) {
|
||||
$flushAll();
|
||||
$html .= "<hr>\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strncmp(ltrim($line), '>', 1) === 0) {
|
||||
$flushList();
|
||||
$flushTable();
|
||||
$quoteBuf .= '<p>' . fws_md_inline((string) preg_replace('/^>\s?/', '', $line)) . '</p>';
|
||||
continue;
|
||||
}
|
||||
$flushQuote();
|
||||
|
||||
if (strpos($line, '|') !== false && !$isSep($line)) {
|
||||
$flushList();
|
||||
$tag = $tableHeader ? 'th' : 'td';
|
||||
$row = '<tr>';
|
||||
foreach ($cells($line) as $c) {
|
||||
$row .= '<' . $tag . '>' . fws_md_inline($c) . '</' . $tag . '>';
|
||||
}
|
||||
$row .= '</tr>';
|
||||
$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 .= '<li>' . fws_md_inline($m[2]) . "</li>\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preg_match('/^(\s*)\d+\.\s+(.+)$/', $line, $m)) {
|
||||
$flushTable();
|
||||
if ($listKind !== 'ol') {
|
||||
$flushList();
|
||||
$listKind = 'ol';
|
||||
}
|
||||
$listBuf .= '<li>' . fws_md_inline($m[2]) . "</li>\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($listBuf !== '' && preg_match('/^\s{2,}/', $line)) {
|
||||
$listBuf = (string) preg_replace('/<\/li>\n$/', ' ' . fws_md_inline(trim($line)) . "</li>\n", $listBuf);
|
||||
continue;
|
||||
}
|
||||
|
||||
$flushList();
|
||||
$flushTable();
|
||||
$html .= '<p>' . fws_md_inline($line) . "</p>\n";
|
||||
}
|
||||
|
||||
$flushAll();
|
||||
if ($inCode) {
|
||||
$langAttr = $codeLang !== '' ? ' class="language-' . e($codeLang) . '"' : '';
|
||||
$html .= '<pre><code' . $langAttr . '>' . fws_md_escape(trim($code)) . "</code></pre>\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 </p>, </div>…) 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 = '<p>' . e(mb_substr($text, 0, $limit)) . '…</p>';
|
||||
return ['html' => $out, 'truncated' => true];
|
||||
}
|
||||
return ['html' => $out, 'truncated' => true];
|
||||
}
|
||||
-110
@@ -1,110 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Accueil | FWS Linux</title>
|
||||
<meta name="description" content="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." />
|
||||
<meta name="robots" content="index, follow" />
|
||||
<link rel="canonical" href="https://fwslinux.fr/?p/index/" />
|
||||
|
||||
<!-- Open Graph -->
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:title" content="Accueil | FWS Linux" />
|
||||
<meta property="og:description" content="Distribution open-source basée sur Arch Linux. Installation simplifiée, léger, compatible Windows." />
|
||||
<meta property="og:image" content="/p/assets/img/logo.png" />
|
||||
<meta property="og:locale" content="fr_FR" />
|
||||
|
||||
<link rel="stylesheet" href="p/assets/styles/styles.css" />
|
||||
<link rel="stylesheet" href="p/assets/styles/paquets.css" />
|
||||
<link rel="icon" type="image/png" href="/p/assets/img/logo.png" />
|
||||
|
||||
<!-- Réseau : la page Téléchargements interroge l'API GitHub -->
|
||||
<link rel="preconnect" href="https://api.github.com" crossorigin />
|
||||
<link rel="dns-prefetch" href="https://api.github.com" />
|
||||
<link rel="dns-prefetch" href="https://github.com" />
|
||||
<link rel="dns-prefetch" href="https://objects.githubusercontent.com" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a class="skip-link" href="#app-main">Aller au contenu principal</a>
|
||||
|
||||
<div class="page-shell">
|
||||
<header class="site-header" role="banner">
|
||||
<div class="header-brand-block">
|
||||
<a class="brand" href="/?p/index/" data-route="index" aria-label="FWS Linux — Retour à l'accueil">
|
||||
<img class="brand-mark" src="p/assets/img/logo.png" alt="" width="44" height="44" />
|
||||
<span class="brand-text">
|
||||
<strong>FWS Linux</strong>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<nav class="site-nav" aria-label="Navigation principale">
|
||||
<a href="/?p/index/" data-route="index">Accueil</a>
|
||||
<a href="/?p/dl/" data-route="dl">Téléchargements</a>
|
||||
|
||||
<div class="nav-dropdown" data-nav-dropdown>
|
||||
<button type="button" class="nav-dropdown-toggle" aria-expanded="false" aria-haspopup="true" aria-controls="nav-paquets-panel">
|
||||
Paquets
|
||||
<span class="nav-dropdown-caret" aria-hidden="true"></span>
|
||||
</button>
|
||||
<div class="nav-dropdown-panel" id="nav-paquets-panel" role="group" aria-label="Liste des paquets">
|
||||
<div class="nav-dropdown-panel-inner" data-packages-nav></div>
|
||||
<a class="nav-dropdown-all" href="/?p/paquets/" data-route="paquets">Voir tous les paquets →</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main id="app-main" class="site-main" aria-live="polite">
|
||||
<noscript>Activez JavaScript pour naviguer sur ce site.</noscript>
|
||||
</main>
|
||||
|
||||
<footer class="site-footer" role="contentinfo">
|
||||
<div class="footer-content">
|
||||
<div class="footer-brand-row">
|
||||
<div class="footer-brand-block">
|
||||
<img class="footer-brand-mark" src="p/assets/img/logo.png" alt="" width="40" height="40" />
|
||||
<div>
|
||||
<strong>FWS Linux</strong>
|
||||
<p>Un système léger, libre et compatible</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer-links-grid">
|
||||
<nav aria-label="Navigation secondaire">
|
||||
<h2>Navigation</h2>
|
||||
<a href="/?p/index/" data-route="index">Accueil</a>
|
||||
<a href="/?p/dl/" data-route="dl">Téléchargements</a>
|
||||
<a href="/?p/paquets/" data-route="paquets">Paquets</a>
|
||||
<a href="/?p/equipe/" data-route="equipe">Équipe</a>
|
||||
</nav>
|
||||
|
||||
<section>
|
||||
<h2>Contact</h2>
|
||||
<a href="/?p/contact/" data-route="contact">Page de contact</a>
|
||||
<a href="/?p/equipe/" data-route="equipe">Équipe</a>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Réseaux</h2>
|
||||
<a href="https://github.com/You-re-like-Windows-a-bitch/ISO" target="_blank" rel="noopener noreferrer">GitHub</a>
|
||||
<a href="https://discord.gg/6mnpPr2jq4" target="_blank" rel="noopener noreferrer">Discord</a>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="footer-bottom">
|
||||
<p>© <span id="footer-year">2026</span> FWS Linux</p>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<script src="p/assets/main-nav/app.js"></script>
|
||||
<script src="p/assets/js/packages.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* FWS Linux — point d'entrée alternatif (/index.php) : délègue à page.php.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require __DIR__ . '/page.php';
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* FWS Linux — page 404 (incluse par page.php avec http_response_code(404)).
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
if (!isset($title, $extraCss, $extraJs)) {
|
||||
http_response_code(404);
|
||||
exit('Page introuvable.');
|
||||
}
|
||||
|
||||
$title = 'Page introuvable | FWS Linux';
|
||||
?>
|
||||
<section class="hero">
|
||||
<h1>Page introuvable</h1>
|
||||
<p class="lead">Cette page n'existe pas ou a été déplacée.</p>
|
||||
<div class="hero-actions">
|
||||
<a class="button button-primary" href="/?p/index/">Retour à l'accueil</a>
|
||||
</div>
|
||||
</section>
|
||||
@@ -1,108 +0,0 @@
|
||||
(() => {
|
||||
function formatDate(iso) {
|
||||
if (!iso) return null;
|
||||
try {
|
||||
const d = new Date(iso);
|
||||
return d.toLocaleDateString("fr-FR", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
});
|
||||
} catch {
|
||||
return iso;
|
||||
}
|
||||
}
|
||||
|
||||
function createCreatorCard(creator) {
|
||||
const card = document.createElement("article");
|
||||
card.className = "creator-card";
|
||||
|
||||
if (creator.avatar) {
|
||||
const img = document.createElement("img");
|
||||
img.className = "creator-avatar";
|
||||
img.src = creator.avatar;
|
||||
img.alt = creator.name || creator.role || "";
|
||||
img.loading = "lazy";
|
||||
card.appendChild(img);
|
||||
}
|
||||
|
||||
const info = document.createElement("div");
|
||||
info.className = "creator-info";
|
||||
|
||||
if (creator.name) {
|
||||
const name = document.createElement("h3");
|
||||
name.className = "creator-name";
|
||||
name.textContent = creator.name;
|
||||
info.appendChild(name);
|
||||
}
|
||||
|
||||
if (creator.role) {
|
||||
const role = document.createElement("span");
|
||||
role.className = "creator-role";
|
||||
role.textContent = creator.role;
|
||||
info.appendChild(role);
|
||||
}
|
||||
|
||||
if (creator.joined) {
|
||||
const joined = document.createElement("span");
|
||||
joined.className = "creator-joined";
|
||||
joined.textContent = "A rejoint le " + formatDate(creator.joined);
|
||||
info.appendChild(joined);
|
||||
}
|
||||
|
||||
if (creator.email) {
|
||||
const email = document.createElement("a");
|
||||
email.className = "creator-email";
|
||||
email.href = "mailto:" + creator.email;
|
||||
email.textContent = creator.email;
|
||||
info.appendChild(email);
|
||||
}
|
||||
|
||||
if (creator.links && creator.links.length > 0) {
|
||||
const links = document.createElement("div");
|
||||
links.className = "creator-links";
|
||||
for (const link of creator.links) {
|
||||
const a = document.createElement("a");
|
||||
a.className = "creator-link";
|
||||
a.href = link.url;
|
||||
a.target = "_blank";
|
||||
a.rel = "noopener noreferrer";
|
||||
a.textContent = link.label || link.url;
|
||||
links.appendChild(a);
|
||||
}
|
||||
info.appendChild(links);
|
||||
}
|
||||
|
||||
card.appendChild(info);
|
||||
return card;
|
||||
}
|
||||
|
||||
async function loadCreators() {
|
||||
const containers = document.querySelectorAll("[data-creators-src]");
|
||||
for (const container of containers) {
|
||||
const src = container.getAttribute("data-creators-src");
|
||||
if (!src) continue;
|
||||
|
||||
try {
|
||||
const response = await fetch(src, { cache: "no-store" });
|
||||
if (!response.ok) throw new Error("Erreur " + response.status);
|
||||
const creators = await response.json();
|
||||
|
||||
const grid = document.createElement("div");
|
||||
grid.className = "creators-grid";
|
||||
|
||||
for (const creator of creators) {
|
||||
grid.appendChild(createCreatorCard(creator));
|
||||
}
|
||||
|
||||
container.innerHTML = "";
|
||||
container.appendChild(grid);
|
||||
} catch (err) {
|
||||
container.innerHTML =
|
||||
'<p class="creators-error">Impossible de charger les données des créateurs.</p>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loadCreators();
|
||||
})();
|
||||
@@ -1,461 +0,0 @@
|
||||
(() => {
|
||||
const OWNER = "You-re-like-Windows-a-bitch";
|
||||
const REPO = "ISO";
|
||||
const RELEASES_URL = `https://api.github.com/repos/${OWNER}/${REPO}/releases?per_page=5`;
|
||||
const TAGS_URL = `https://api.github.com/repos/${OWNER}/${REPO}/tags?per_page=5`;
|
||||
const REPO_URL = `https://github.com/${OWNER}/${REPO}`;
|
||||
|
||||
const currentVersionNode = document.querySelector("[data-current-version]");
|
||||
const currentVersionDateNode = document.querySelector("[data-current-version-date]");
|
||||
const currentReleaseNoteNode = document.querySelector("[data-current-release-note]");
|
||||
const latestDownloadNode = document.querySelector("[data-latest-download]");
|
||||
const viewMoreNode = document.querySelector("[data-view-more]");
|
||||
const versionsListNode = document.querySelector("[data-versions-list]");
|
||||
const toggleNoteNode = document.querySelector("[data-toggle-release-note]");
|
||||
|
||||
let fullReleaseBodyHtml = "";
|
||||
const TRUNCATE_LENGTH = 600;
|
||||
|
||||
function formatDate(value) {
|
||||
if (!value) return "";
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return "";
|
||||
return date.toLocaleDateString("fr-FR", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
});
|
||||
}
|
||||
|
||||
function getReleaseLabel(entry) {
|
||||
return entry?.name || entry?.tag_name || entry?.ref || "Sans nom";
|
||||
}
|
||||
|
||||
function getReleasePageUrl(entry, mode) {
|
||||
if (mode === "releases") {
|
||||
return pickDirectDownloadUrl(entry);
|
||||
}
|
||||
|
||||
if (entry?.name) {
|
||||
return `${REPO_URL}/releases/tag/${encodeURIComponent(entry.name)}`;
|
||||
}
|
||||
|
||||
return REPO_URL;
|
||||
}
|
||||
|
||||
function escapeHtml(text) {
|
||||
return text
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">");
|
||||
}
|
||||
|
||||
function parseInline(text) {
|
||||
let result = escapeHtml(text);
|
||||
result = result.replace(/\*\*\*(.+?)\*\*\*/g, "<strong><em>$1</em></strong>");
|
||||
result = result.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>");
|
||||
result = result.replace(/\*(.+?)\*/g, "<em>$1</em>");
|
||||
result = result.replace(/`([^`]+)`/g, "<code>$1</code>");
|
||||
result = result.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, '<img alt="$1" src="$2" loading="lazy">');
|
||||
result = result.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2" target="_blank" rel="noreferrer">$1</a>');
|
||||
return result;
|
||||
}
|
||||
|
||||
function renderMarkdown(md) {
|
||||
if (!md) return "";
|
||||
|
||||
var lines = md.split(/\r?\n/);
|
||||
var html = "";
|
||||
var inCodeBlock = false;
|
||||
var codeBlockContent = "";
|
||||
var codeBlockLang = "";
|
||||
var listBuffer = "";
|
||||
var listKind = "";
|
||||
var tableRows = [];
|
||||
var tableHeader = true;
|
||||
var blockquoteBuffer = "";
|
||||
|
||||
function flushList() {
|
||||
if (listBuffer) {
|
||||
html += "<" + listKind + ">\n" + listBuffer + "</" + listKind + ">\n";
|
||||
listBuffer = "";
|
||||
listKind = "";
|
||||
}
|
||||
}
|
||||
|
||||
function flushTable() {
|
||||
if (tableRows.length) {
|
||||
html += "<table>\n" + tableRows.join("\n") + "\n</table>\n";
|
||||
tableRows = [];
|
||||
tableHeader = true;
|
||||
}
|
||||
}
|
||||
|
||||
function flushBlockquote() {
|
||||
if (blockquoteBuffer) {
|
||||
html += "<blockquote>" + blockquoteBuffer + "</blockquote>\n";
|
||||
blockquoteBuffer = "";
|
||||
}
|
||||
}
|
||||
|
||||
function parseTableCells(line) {
|
||||
var trimmed = line.replace(/^\|/, "").replace(/\|$/, "");
|
||||
return trimmed.split("|").map(function (c) { return c.trim(); });
|
||||
}
|
||||
|
||||
function isTableSep(line) {
|
||||
return /^\|?[\s|:\-]+\|?$/.test(line) && line.indexOf("-") !== -1;
|
||||
}
|
||||
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var line = lines[i];
|
||||
|
||||
if (line.startsWith("```")) {
|
||||
flushBlockquote();
|
||||
flushList();
|
||||
flushTable();
|
||||
if (inCodeBlock) {
|
||||
var langAttr = codeBlockLang ? " class=\"language-" + escapeHtml(codeBlockLang) + "\"" : "";
|
||||
html += "<pre><code" + langAttr + ">" + escapeHtml(codeBlockContent.trim()) + "</code></pre>\n";
|
||||
codeBlockContent = "";
|
||||
codeBlockLang = "";
|
||||
inCodeBlock = false;
|
||||
} else {
|
||||
inCodeBlock = true;
|
||||
codeBlockLang = line.slice(3).trim();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inCodeBlock) {
|
||||
codeBlockContent += (codeBlockContent ? "\n" : "") + line;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.trim() === "") {
|
||||
flushBlockquote();
|
||||
flushList();
|
||||
flushTable();
|
||||
continue;
|
||||
}
|
||||
|
||||
var hMatch = line.match(/^(#{1,6})\s+(.+)$/);
|
||||
if (hMatch) {
|
||||
flushBlockquote();
|
||||
flushList();
|
||||
flushTable();
|
||||
var level = hMatch[1].length;
|
||||
html += "<h" + level + ">" + parseInline(hMatch[2]) + "</h" + level + ">\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (/^[-*_]{3,}\s*$/.test(line.trim())) {
|
||||
flushBlockquote();
|
||||
flushList();
|
||||
flushTable();
|
||||
html += "<hr>\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.startsWith("> ") || line.startsWith(">")) {
|
||||
flushList();
|
||||
flushTable();
|
||||
var content = line.replace(/^>\s?/, "");
|
||||
blockquoteBuffer += "<p>" + parseInline(content) + "</p>";
|
||||
continue;
|
||||
} else {
|
||||
flushBlockquote();
|
||||
}
|
||||
|
||||
if (line.includes("|") && !isTableSep(line)) {
|
||||
flushList();
|
||||
var cells = parseTableCells(line);
|
||||
var tag = tableHeader ? "th" : "td";
|
||||
tableRows.push("<tr>" + cells.map(function (c) { return "<" + tag + ">" + parseInline(c) + "</" + tag + ">"; }).join("") + "</tr>");
|
||||
if (tableHeader) tableHeader = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isTableSep(line)) {
|
||||
tableHeader = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.includes("|")) {
|
||||
flushTable();
|
||||
}
|
||||
|
||||
var ulMatch = line.match(/^(\s*)[-*+]\s+(.+)$/);
|
||||
if (ulMatch) {
|
||||
flushTable();
|
||||
if (listKind !== "ul") {
|
||||
flushList();
|
||||
listKind = "ul";
|
||||
}
|
||||
listBuffer += "<li>" + parseInline(ulMatch[2]) + "</li>\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
var olMatch = line.match(/^(\s*)\d+\.\s+(.+)$/);
|
||||
if (olMatch) {
|
||||
flushTable();
|
||||
if (listKind !== "ol") {
|
||||
flushList();
|
||||
listKind = "ol";
|
||||
}
|
||||
listBuffer += "<li>" + parseInline(olMatch[2]) + "</li>\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (listBuffer && /^\s{2,}/.test(line)) {
|
||||
listBuffer = listBuffer.replace(/<\/li>\n$/, " " + parseInline(line.trim()) + "</li>\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
flushList();
|
||||
flushTable();
|
||||
html += "<p>" + parseInline(line) + "</p>\n";
|
||||
}
|
||||
|
||||
flushBlockquote();
|
||||
flushList();
|
||||
flushTable();
|
||||
if (inCodeBlock) {
|
||||
var langAttr2 = codeBlockLang ? " class=\"language-" + escapeHtml(codeBlockLang) + "\"" : "";
|
||||
html += "<pre><code" + langAttr2 + ">" + escapeHtml(codeBlockContent.trim()) + "</code></pre>\n";
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
function sanitizeRenderedHtml(rawHtml) {
|
||||
const wrapper = document.createElement("div");
|
||||
wrapper.innerHTML = rawHtml;
|
||||
|
||||
wrapper.querySelectorAll("script, iframe, object, embed, link, style").forEach(function (node) { node.remove(); });
|
||||
wrapper.querySelectorAll("*").forEach(function (node) {
|
||||
Array.from(node.attributes).forEach(function (attribute) {
|
||||
var name = attribute.name.toLowerCase();
|
||||
var value = attribute.value || "";
|
||||
if (name.startsWith("on")) { node.removeAttribute(attribute.name); return; }
|
||||
if ((name === "href" || name === "src") && /^javascript:/i.test(value)) { node.removeAttribute(attribute.name); }
|
||||
});
|
||||
});
|
||||
|
||||
return wrapper.innerHTML;
|
||||
}
|
||||
|
||||
function truncateHtml(fullHtml) {
|
||||
var temp = document.createElement("div");
|
||||
temp.innerHTML = fullHtml;
|
||||
var text = temp.textContent || "";
|
||||
|
||||
if (text.length <= TRUNCATE_LENGTH) {
|
||||
return { html: fullHtml, truncated: false };
|
||||
}
|
||||
|
||||
var acc = "";
|
||||
var count = 0;
|
||||
var truncatedHtml = "";
|
||||
var children = Array.from(temp.childNodes);
|
||||
|
||||
for (var ci = 0; ci < children.length; ci++) {
|
||||
var child = children[ci];
|
||||
var childText = child.textContent || "";
|
||||
|
||||
if (count + childText.length > TRUNCATE_LENGTH && count > 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (child.nodeType === Node.ELEMENT_NODE) {
|
||||
truncatedHtml += child.outerHTML;
|
||||
} else {
|
||||
var remaining = TRUNCATE_LENGTH - count;
|
||||
if (childText.length > remaining) {
|
||||
truncatedHtml += escapeHtml(childText.slice(0, remaining)) + "…";
|
||||
count = TRUNCATE_LENGTH;
|
||||
break;
|
||||
}
|
||||
truncatedHtml += escapeHtml(childText);
|
||||
}
|
||||
count += childText.length;
|
||||
}
|
||||
|
||||
return { html: truncatedHtml, truncated: true };
|
||||
}
|
||||
|
||||
function setupToggle() {
|
||||
if (!toggleNoteNode || !currentReleaseNoteNode) return;
|
||||
|
||||
toggleNoteNode.addEventListener("click", function () {
|
||||
var expanded = toggleNoteNode.dataset.expanded === "true";
|
||||
if (expanded) {
|
||||
var result = truncateHtml(fullReleaseBodyHtml);
|
||||
currentReleaseNoteNode.innerHTML = result.html;
|
||||
toggleNoteNode.textContent = "Voir plus";
|
||||
toggleNoteNode.dataset.expanded = "false";
|
||||
} else {
|
||||
currentReleaseNoteNode.innerHTML = fullReleaseBodyHtml;
|
||||
toggleNoteNode.textContent = "Voir moins";
|
||||
toggleNoteNode.dataset.expanded = "true";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setupToggle();
|
||||
|
||||
function pickDirectDownloadUrl(release) {
|
||||
const assets = Array.isArray(release?.assets) ? release.assets : [];
|
||||
const isoAsset = assets.find((asset) => /\.iso$/i.test(asset?.name || ""));
|
||||
const directAsset = isoAsset || assets[0];
|
||||
|
||||
if (directAsset) {
|
||||
return directAsset.browser_download_url || release.html_url || REPO_URL;
|
||||
}
|
||||
|
||||
return release?.zipball_url || release?.html_url || REPO_URL;
|
||||
}
|
||||
|
||||
function renderEmptyState(title, message) {
|
||||
if (!versionsListNode) return;
|
||||
versionsListNode.innerHTML = `
|
||||
<li class="version-item version-item-empty">
|
||||
<div class="version-main">
|
||||
<strong>${title}</strong>
|
||||
<span>${message}</span>
|
||||
</div>
|
||||
<div class="version-side">
|
||||
<a class="button button-secondary" href="${REPO_URL}" target="_blank" rel="noreferrer">Voir le repo</a>
|
||||
</div>
|
||||
</li>
|
||||
`;
|
||||
}
|
||||
|
||||
function renderList(items, mode) {
|
||||
if (!versionsListNode) return;
|
||||
versionsListNode.innerHTML = "";
|
||||
|
||||
const visibleItems = items.slice(1, 6);
|
||||
|
||||
if (!visibleItems.length) {
|
||||
if (items.length === 0) {
|
||||
renderEmptyState("Aucune release trouvée", "Le dépôt n'expose pas encore de release ou les releases ne sont pas accessibles.");
|
||||
} else {
|
||||
renderEmptyState(
|
||||
mode === "releases" ? "Aucune release précédente trouvée" : "Aucun tag précédent trouvé",
|
||||
mode === "releases"
|
||||
? "Il n'y a qu'une seule release publiée pour le moment."
|
||||
: "Il n'y a qu'un seul tag disponible pour le moment."
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
visibleItems.forEach((entry) => {
|
||||
const li = document.createElement("li");
|
||||
li.className = "version-item";
|
||||
|
||||
const label = getReleaseLabel(entry);
|
||||
const downloadUrl = getReleasePageUrl(entry, mode);
|
||||
const published = formatDate(entry.published_at || entry.commit?.committer?.date);
|
||||
|
||||
li.innerHTML = `
|
||||
<div class="version-main">
|
||||
<strong>${label}</strong>
|
||||
<span>${published ? `Publié le ${published}` : mode === "releases" ? "Date inconnue" : "Tag GitHub"}</span>
|
||||
</div>
|
||||
<div class="version-side">
|
||||
<a class="button button-secondary" href="${downloadUrl}" target="_blank" rel="noreferrer">Télécharger</a>
|
||||
</div>
|
||||
`;
|
||||
|
||||
versionsListNode.appendChild(li);
|
||||
});
|
||||
}
|
||||
|
||||
async function fetchJson(url) {
|
||||
const response = await fetch(url, {
|
||||
headers: { Accept: "application/vnd.github+json" },
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`GitHub API ${response.status}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function loadReleases() {
|
||||
if (currentVersionNode) currentVersionNode.textContent = "Chargement...";
|
||||
if (currentVersionDateNode) currentVersionDateNode.textContent = "";
|
||||
if (currentReleaseNoteNode) currentReleaseNoteNode.textContent = "";
|
||||
if (latestDownloadNode) latestDownloadNode.href = REPO_URL;
|
||||
if (viewMoreNode) viewMoreNode.href = `${REPO_URL}/releases`;
|
||||
|
||||
try {
|
||||
const releases = await fetchJson(RELEASES_URL);
|
||||
|
||||
if (Array.isArray(releases) && releases.length > 0) {
|
||||
const latest = releases[0];
|
||||
const latestLabel = getReleaseLabel(latest);
|
||||
const latestDownloadUrl = pickDirectDownloadUrl(latest);
|
||||
const latestDate = formatDate(latest.published_at);
|
||||
|
||||
if (currentVersionNode) currentVersionNode.textContent = latestLabel;
|
||||
if (currentVersionDateNode) currentVersionDateNode.textContent = latestDate ? ` · ${latestDate}` : "";
|
||||
if (currentReleaseNoteNode) {
|
||||
fullReleaseBodyHtml = sanitizeRenderedHtml(renderMarkdown(latest.body || ""));
|
||||
var result = truncateHtml(fullReleaseBodyHtml);
|
||||
currentReleaseNoteNode.innerHTML = result.html || "<p>Release GitHub la plus récente.</p>";
|
||||
if (toggleNoteNode) {
|
||||
toggleNoteNode.style.display = result.truncated ? "inline-block" : "none";
|
||||
toggleNoteNode.dataset.expanded = "false";
|
||||
toggleNoteNode.textContent = "Voir plus";
|
||||
}
|
||||
}
|
||||
if (latestDownloadNode) latestDownloadNode.href = latestDownloadUrl;
|
||||
|
||||
renderList(releases, "releases");
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Erreur fetch releases:", error.message);
|
||||
// On tente le fallback tags ci-dessous.
|
||||
}
|
||||
|
||||
try {
|
||||
const tags = await fetchJson(TAGS_URL);
|
||||
|
||||
if (Array.isArray(tags) && tags.length > 0) {
|
||||
const latestTag = tags[0];
|
||||
const latestLabel = getReleaseLabel(latestTag);
|
||||
const latestDownloadUrl = `${REPO_URL}/releases/tag/${encodeURIComponent(latestTag.name)}`;
|
||||
|
||||
if (currentVersionNode) currentVersionNode.textContent = `${latestLabel} (tag)`;
|
||||
if (currentVersionDateNode) currentVersionDateNode.textContent = "";
|
||||
if (currentReleaseNoteNode) {
|
||||
currentReleaseNoteNode.textContent = "Aucune release GitHub publiée pour le moment, affichage des tags du dépôt.";
|
||||
}
|
||||
if (latestDownloadNode) latestDownloadNode.href = latestDownloadUrl;
|
||||
|
||||
renderList(tags, "tags");
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentVersionNode) currentVersionNode.textContent = "Aucune release trouvée";
|
||||
if (currentReleaseNoteNode) {
|
||||
currentReleaseNoteNode.textContent = "Le dépôt ne renvoie ni release ni tag public.";
|
||||
}
|
||||
renderEmptyState("Aucune release trouvée", "Le dépôt ne renvoie ni release ni tag public.");
|
||||
} catch (error) {
|
||||
console.error("Erreur fetch tags:", error.message);
|
||||
if (currentVersionNode) currentVersionNode.textContent = "Impossible de charger les releases";
|
||||
if (currentReleaseNoteNode) {
|
||||
currentReleaseNoteNode.textContent = `Erreur: ${error.message}. Vérifie que le repo GitHub est public et qu'il expose des releases ou des tags.`;
|
||||
}
|
||||
renderEmptyState("Impossible de charger les releases", "Ouvre le repo GitHub pour vérifier les releases ou les tags.");
|
||||
}
|
||||
}
|
||||
|
||||
loadReleases();
|
||||
})();
|
||||
@@ -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";
|
||||
}
|
||||
});
|
||||
})();
|
||||
@@ -1,487 +0,0 @@
|
||||
(() => {
|
||||
const PACKAGES_SRC = "/p/paquets/packages.json";
|
||||
|
||||
let packagesPromise = null;
|
||||
|
||||
function fetchPackages() {
|
||||
if (!packagesPromise) {
|
||||
packagesPromise = fetch(PACKAGES_SRC, { cache: "no-store" })
|
||||
.then((response) => {
|
||||
if (!response.ok) throw new Error("Erreur " + response.status);
|
||||
return response.json();
|
||||
});
|
||||
}
|
||||
return packagesPromise;
|
||||
}
|
||||
|
||||
function formatDate(iso) {
|
||||
if (!iso) return null;
|
||||
try {
|
||||
return new Date(iso).toLocaleDateString("fr-FR", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
});
|
||||
} catch {
|
||||
return iso;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Menu déroulant de la barre de navigation ── */
|
||||
|
||||
function initNavDropdown() {
|
||||
const root = document.querySelector("[data-nav-dropdown]");
|
||||
if (!root) return;
|
||||
// Le script est chargé aussi dans la page « Paquets » (injection SPA) :
|
||||
// on ne câble le menu qu'une seule fois.
|
||||
if (root.dataset.navReady === "1") return;
|
||||
root.dataset.navReady = "1";
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
function closeIfOutside(event) {
|
||||
if (!root.contains(event.target)) setOpen(false);
|
||||
}
|
||||
|
||||
toggle.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
setOpen(!root.classList.contains("is-open"));
|
||||
});
|
||||
|
||||
document.addEventListener("click", closeIfOutside);
|
||||
document.addEventListener("keydown", (event) => {
|
||||
if (event.key === "Escape" && root.classList.contains("is-open")) {
|
||||
setOpen(false);
|
||||
toggle.focus();
|
||||
}
|
||||
});
|
||||
|
||||
// Refermer le menu quand on navigue vers une autre page et
|
||||
// réévaluer l'état actif une fois l'URL SPA réécrite.
|
||||
document.addEventListener("page:before-route-change", () => {
|
||||
setOpen(false);
|
||||
setTimeout(markActiveRoute, 300);
|
||||
});
|
||||
|
||||
function markActiveRoute() {
|
||||
const search = window.location.search || "";
|
||||
const active = search.includes("p=paquets") || search.includes("p/paquets");
|
||||
if (active) {
|
||||
toggle.setAttribute("aria-current", "page");
|
||||
} else {
|
||||
toggle.removeAttribute("aria-current");
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("popstate", markActiveRoute);
|
||||
markActiveRoute();
|
||||
|
||||
const list = panel.querySelector("[data-packages-nav]");
|
||||
if (!list) return;
|
||||
|
||||
fetchPackages()
|
||||
.then((packages) => {
|
||||
list.innerHTML = "";
|
||||
packages.forEach((pkg, index) => {
|
||||
const item = document.createElement("a");
|
||||
item.className = "nav-dropdown-item";
|
||||
item.href = "/?p/paquets/" + (index + 1) + "/";
|
||||
item.dataset.route = "paquets/" + (index + 1);
|
||||
|
||||
const name = document.createElement("strong");
|
||||
name.textContent = pkg.name;
|
||||
|
||||
if (pkg.latest && pkg.latest.name) {
|
||||
const version = document.createElement("span");
|
||||
version.className = "nav-dropdown-version";
|
||||
version.textContent = pkg.latest.name;
|
||||
name.appendChild(version);
|
||||
}
|
||||
|
||||
const tagline = document.createElement("small");
|
||||
tagline.textContent = pkg.tagline || "";
|
||||
|
||||
item.appendChild(name);
|
||||
item.appendChild(tagline);
|
||||
|
||||
item.addEventListener("click", () => setOpen(false));
|
||||
|
||||
list.appendChild(item);
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
list.innerHTML = '<p class="nav-dropdown-error">Impossible de charger les paquets.</p>';
|
||||
});
|
||||
}
|
||||
|
||||
/* ── Page « Paquets » ── */
|
||||
|
||||
function createEmptyState(message) {
|
||||
const p = document.createElement("p");
|
||||
p.className = "paquet-empty";
|
||||
p.textContent = message;
|
||||
return p;
|
||||
}
|
||||
|
||||
function createChangelog(pkg) {
|
||||
const wrapper = document.createElement("div");
|
||||
wrapper.className = "paquet-changelog";
|
||||
|
||||
const title = document.createElement("h3");
|
||||
title.textContent = "Historique";
|
||||
wrapper.appendChild(title);
|
||||
|
||||
if (!pkg.changelog || pkg.changelog.length === 0) {
|
||||
wrapper.appendChild(createEmptyState("Historique en cours de rédaction."));
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
const timeline = document.createElement("ol");
|
||||
timeline.className = "paquet-timeline";
|
||||
|
||||
for (const entry of pkg.changelog) {
|
||||
const li = document.createElement("li");
|
||||
li.className = "paquet-timeline-item";
|
||||
|
||||
const version = document.createElement("strong");
|
||||
version.className = "paquet-timeline-version";
|
||||
version.textContent = entry.version || "—";
|
||||
|
||||
const date = document.createElement("time");
|
||||
date.className = "paquet-timeline-date";
|
||||
date.textContent = formatDate(entry.date) || "";
|
||||
if (entry.date) date.dateTime = entry.date;
|
||||
|
||||
const notes = document.createElement("span");
|
||||
notes.className = "paquet-timeline-notes";
|
||||
notes.textContent = entry.notes || "";
|
||||
|
||||
li.appendChild(version);
|
||||
li.appendChild(date);
|
||||
if (entry.notes) li.appendChild(notes);
|
||||
timeline.appendChild(li);
|
||||
}
|
||||
|
||||
wrapper.appendChild(timeline);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
function createScreens(pkg) {
|
||||
const wrapper = document.createElement("div");
|
||||
wrapper.className = "paquet-screens";
|
||||
|
||||
const title = document.createElement("h3");
|
||||
title.textContent = "Captures d'écran";
|
||||
wrapper.appendChild(title);
|
||||
|
||||
if (!pkg.screens || pkg.screens.length === 0) {
|
||||
wrapper.appendChild(createEmptyState("Captures d'écran à venir."));
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
const grid = document.createElement("div");
|
||||
grid.className = "paquet-screens-grid";
|
||||
|
||||
for (const screen of pkg.screens) {
|
||||
const figure = document.createElement("figure");
|
||||
const img = document.createElement("img");
|
||||
img.src = screen.src;
|
||||
img.alt = screen.alt || pkg.name;
|
||||
img.loading = "lazy";
|
||||
figure.appendChild(img);
|
||||
if (screen.caption) {
|
||||
const figcaption = document.createElement("figcaption");
|
||||
figcaption.textContent = screen.caption;
|
||||
figure.appendChild(figcaption);
|
||||
}
|
||||
grid.appendChild(figure);
|
||||
}
|
||||
|
||||
wrapper.appendChild(grid);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
function createLinks(pkg) {
|
||||
const wrapper = document.createElement("div");
|
||||
wrapper.className = "paquet-links";
|
||||
|
||||
const title = document.createElement("h3");
|
||||
title.textContent = "Liens utiles";
|
||||
wrapper.appendChild(title);
|
||||
|
||||
if (!pkg.links || pkg.links.length === 0) {
|
||||
wrapper.appendChild(createEmptyState("Aucun lien pour le moment."));
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
for (const link of pkg.links) {
|
||||
const a = document.createElement("a");
|
||||
a.className = "button button-secondary";
|
||||
a.href = link.url;
|
||||
const external = /^https?:\/\//i.test(link.url);
|
||||
if (external) {
|
||||
a.target = "_blank";
|
||||
a.rel = "noopener noreferrer";
|
||||
}
|
||||
a.textContent = link.label || link.url;
|
||||
wrapper.appendChild(a);
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
function createPackageCard(pkg, position) {
|
||||
const card = document.createElement("article");
|
||||
card.className = "paquet-card";
|
||||
card.id = "paquet-" + pkg.id;
|
||||
|
||||
const head = document.createElement("header");
|
||||
head.className = "paquet-head";
|
||||
|
||||
const titleRow = document.createElement("div");
|
||||
titleRow.className = "paquet-title-row";
|
||||
|
||||
const title = document.createElement("h2");
|
||||
title.textContent = pkg.name;
|
||||
|
||||
const badge = document.createElement("span");
|
||||
badge.className = "paquet-since";
|
||||
badge.textContent = pkg.sinceLabel || "FWS";
|
||||
if (pkg.since) {
|
||||
badge.title = "Depuis le " + formatDate(pkg.since);
|
||||
}
|
||||
|
||||
const detailLink = document.createElement("a");
|
||||
detailLink.className = "paquet-detail-link";
|
||||
detailLink.href = "/?p/paquets/" + position + "/";
|
||||
detailLink.dataset.route = "paquets/" + position;
|
||||
detailLink.textContent = "Voir en grand";
|
||||
|
||||
titleRow.appendChild(title);
|
||||
titleRow.appendChild(badge);
|
||||
titleRow.appendChild(detailLink);
|
||||
head.appendChild(titleRow);
|
||||
|
||||
if (pkg.tagline) {
|
||||
const tagline = document.createElement("p");
|
||||
tagline.className = "paquet-tagline";
|
||||
tagline.textContent = pkg.tagline;
|
||||
head.appendChild(tagline);
|
||||
}
|
||||
|
||||
const latest = document.createElement("p");
|
||||
latest.className = "paquet-latest";
|
||||
if (pkg.latest && pkg.latest.name) {
|
||||
latest.textContent =
|
||||
"Dernière release : " +
|
||||
pkg.latest.name +
|
||||
(pkg.latest.date ? " — " + formatDate(pkg.latest.date) : "");
|
||||
} else {
|
||||
latest.textContent = "Aucune release publiée pour le moment.";
|
||||
}
|
||||
head.appendChild(latest);
|
||||
|
||||
if (pkg.description) {
|
||||
const description = document.createElement("p");
|
||||
description.className = "paquet-description";
|
||||
description.textContent = pkg.description;
|
||||
head.appendChild(description);
|
||||
}
|
||||
|
||||
card.appendChild(head);
|
||||
|
||||
const body = document.createElement("div");
|
||||
body.className = "paquet-body";
|
||||
body.appendChild(createChangelog(pkg));
|
||||
body.appendChild(createScreens(pkg));
|
||||
body.appendChild(createLinks(pkg));
|
||||
card.appendChild(body);
|
||||
|
||||
return card;
|
||||
}
|
||||
|
||||
function initPackagesPage(container) {
|
||||
fetchPackages()
|
||||
.then((packages) => {
|
||||
container.innerHTML = "";
|
||||
packages.forEach((pkg, index) => {
|
||||
container.appendChild(createPackageCard(pkg, index + 1));
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
container.innerHTML = "";
|
||||
container.appendChild(
|
||||
createEmptyState("Impossible de charger les paquets. Réessayez plus tard.")
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/* ── Page détail « Paquets / N » ── */
|
||||
|
||||
function packageIndexFromLocation() {
|
||||
const haystack = window.location.search + window.location.pathname;
|
||||
const match = haystack.match(/paquets\/(\d+)/);
|
||||
return match ? parseInt(match[1], 10) : 1;
|
||||
}
|
||||
|
||||
function createDetailNav(nav, position, total) {
|
||||
if (position > 1) {
|
||||
const prev = document.createElement("a");
|
||||
prev.className = "paquet-detail-prev";
|
||||
prev.href = "/?p/paquets/" + (position - 1) + "/";
|
||||
prev.dataset.route = "paquets/" + (position - 1);
|
||||
prev.textContent = "← Paquet précédent";
|
||||
nav.appendChild(prev);
|
||||
}
|
||||
|
||||
if (position < total) {
|
||||
const next = document.createElement("a");
|
||||
next.className = "paquet-detail-next";
|
||||
next.href = "/?p/paquets/" + (position + 1) + "/";
|
||||
next.dataset.route = "paquets/" + (position + 1);
|
||||
next.textContent = "Paquet suivant →";
|
||||
nav.appendChild(next);
|
||||
}
|
||||
}
|
||||
|
||||
function renderPackageDetail(container, pkg, position, total) {
|
||||
const back = document.createElement("a");
|
||||
back.className = "paquet-detail-back";
|
||||
back.href = "/?p/paquets/";
|
||||
back.dataset.route = "paquets";
|
||||
back.textContent = "← Tous les paquets";
|
||||
container.appendChild(back);
|
||||
|
||||
const hero = document.createElement("div");
|
||||
hero.className = "paquet-detail-hero";
|
||||
|
||||
const badge = document.createElement("span");
|
||||
badge.className = "paquet-since";
|
||||
badge.textContent = pkg.sinceLabel || "FWS";
|
||||
if (pkg.since) {
|
||||
badge.title = "Depuis le " + formatDate(pkg.since);
|
||||
}
|
||||
hero.appendChild(badge);
|
||||
|
||||
const title = document.createElement("h1");
|
||||
title.textContent = pkg.name;
|
||||
hero.appendChild(title);
|
||||
|
||||
if (pkg.tagline) {
|
||||
const tagline = document.createElement("p");
|
||||
tagline.className = "paquet-tagline";
|
||||
tagline.textContent = pkg.tagline;
|
||||
hero.appendChild(tagline);
|
||||
}
|
||||
|
||||
if (pkg.description) {
|
||||
const description = document.createElement("p");
|
||||
description.className = "paquet-description";
|
||||
description.textContent = pkg.description;
|
||||
hero.appendChild(description);
|
||||
}
|
||||
|
||||
const latest = document.createElement("div");
|
||||
latest.className = "paquet-detail-latest";
|
||||
if (pkg.latest && pkg.latest.name) {
|
||||
const version = document.createElement("span");
|
||||
version.className = "paquet-detail-version";
|
||||
version.textContent = pkg.latest.name;
|
||||
latest.appendChild(version);
|
||||
|
||||
if (pkg.latest.date) {
|
||||
const date = document.createElement("span");
|
||||
date.className = "paquet-detail-date";
|
||||
date.textContent = "Publiée le " + formatDate(pkg.latest.date);
|
||||
latest.appendChild(date);
|
||||
}
|
||||
} else {
|
||||
latest.textContent = "Aucune release publiée pour le moment.";
|
||||
latest.classList.add("paquet-detail-latest-empty");
|
||||
}
|
||||
hero.appendChild(latest);
|
||||
|
||||
container.appendChild(hero);
|
||||
|
||||
const body = document.createElement("div");
|
||||
body.className = "paquet-detail-body";
|
||||
body.appendChild(createChangelog(pkg));
|
||||
body.appendChild(createScreens(pkg));
|
||||
container.appendChild(body);
|
||||
|
||||
container.appendChild(createLinks(pkg));
|
||||
|
||||
const nav = document.createElement("nav");
|
||||
nav.className = "paquet-detail-nav";
|
||||
nav.setAttribute("aria-label", "Parcourir les paquets");
|
||||
createDetailNav(nav, position, total);
|
||||
if (nav.childNodes.length > 0) {
|
||||
container.appendChild(nav);
|
||||
}
|
||||
}
|
||||
|
||||
function initPackageDetail(container) {
|
||||
const position = packageIndexFromLocation();
|
||||
|
||||
fetchPackages()
|
||||
.then((packages) => {
|
||||
container.innerHTML = "";
|
||||
const pkg = packages[position - 1];
|
||||
if (!pkg) {
|
||||
container.appendChild(
|
||||
createEmptyState("Ce paquet n'existe pas (il y en a " + packages.length + ").")
|
||||
);
|
||||
const back = document.createElement("a");
|
||||
back.className = "paquet-detail-back";
|
||||
back.href = "/?p/paquets/";
|
||||
back.dataset.route = "paquets";
|
||||
back.textContent = "← Tous les paquets";
|
||||
container.appendChild(back);
|
||||
return;
|
||||
}
|
||||
|
||||
renderPackageDetail(container, pkg, position, packages.length);
|
||||
// Le routeur SPA applique le titre et le scroll après le rendu :
|
||||
// on force le vrai nom du paquet un peu plus tard.
|
||||
setTimeout(() => {
|
||||
document.title = pkg.name + " | FWS Linux";
|
||||
}, 150);
|
||||
})
|
||||
.catch(() => {
|
||||
container.innerHTML = "";
|
||||
container.appendChild(
|
||||
createEmptyState("Impossible de charger le paquet. Réessayez plus tard.")
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/* ── Initialisation ── */
|
||||
|
||||
function init() {
|
||||
const hasNav = document.querySelector("[data-nav-dropdown]") !== null;
|
||||
const hasPage = document.querySelector("[data-packages-page]") !== null;
|
||||
const hasDetail = document.querySelector("[data-package-detail]") !== null;
|
||||
if (!hasNav && !hasPage && !hasDetail) return;
|
||||
|
||||
initNavDropdown();
|
||||
|
||||
const pageContainers = document.querySelectorAll("[data-packages-page]");
|
||||
pageContainers.forEach(initPackagesPage);
|
||||
|
||||
const detailContainers = document.querySelectorAll("[data-package-detail]");
|
||||
detailContainers.forEach(initPackageDetail);
|
||||
}
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", init);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
})();
|
||||
@@ -1,222 +0,0 @@
|
||||
(() => {
|
||||
const main = document.getElementById("app-main");
|
||||
const footerYear = document.getElementById("footer-year");
|
||||
const pageStyleSelectors = "[data-page-style='true']";
|
||||
const pageScriptSelectors = "script[data-page-script='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 clearInjectedPageScripts() {
|
||||
document.dispatchEvent(new CustomEvent("page:before-route-change"));
|
||||
document.querySelectorAll(pageScriptSelectors).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);
|
||||
});
|
||||
}
|
||||
|
||||
async function injectPageScripts(parsedDocument, sourceUrl) {
|
||||
clearInjectedPageScripts();
|
||||
|
||||
const scriptNodes = Array.from(parsedDocument.querySelectorAll("script"));
|
||||
|
||||
for (const node of scriptNodes) {
|
||||
const scriptElement = document.createElement("script");
|
||||
scriptElement.setAttribute("data-page-script", "true");
|
||||
|
||||
const src = node.getAttribute("src");
|
||||
if (src) {
|
||||
scriptElement.src = new URL(src, sourceUrl).toString();
|
||||
scriptElement.async = false;
|
||||
if (node.defer) {
|
||||
scriptElement.defer = true;
|
||||
}
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
scriptElement.onload = () => resolve();
|
||||
scriptElement.onerror = () => reject(new Error(`Impossible de charger le script: ${src}`));
|
||||
document.body.appendChild(scriptElement);
|
||||
});
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
scriptElement.textContent = node.textContent;
|
||||
document.body.appendChild(scriptElement);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
// Les routes « paquets/N » affichent le détail (grand format) du paquet N.
|
||||
if (/^paquets\/\d+$/.test(route)) {
|
||||
return "p/paquets/_detail/index.html";
|
||||
}
|
||||
return `p/${route}/index.html`;
|
||||
}
|
||||
|
||||
function routeToTitle(route) {
|
||||
if (route === "index") {
|
||||
return "Accueil | FWS Linux";
|
||||
}
|
||||
|
||||
const label = route
|
||||
.split("/")
|
||||
.filter(Boolean)
|
||||
.map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
|
||||
.join(" / ");
|
||||
|
||||
return `${label} | FWS Linux`;
|
||||
}
|
||||
|
||||
async function loadRoute(route) {
|
||||
clearInjectedPageScripts();
|
||||
|
||||
const source = routeToSource(route);
|
||||
// On laisse le cache HTTP faire son travail (revalidation 304) :
|
||||
// le .htaccess renvoie « Cache-Control: no-cache » sur le HTML,
|
||||
// donc on revalide à chaque navigation sans re-télécharger le corps.
|
||||
const response = await fetch(source);
|
||||
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();
|
||||
await injectPageScripts(parsed, response.url);
|
||||
// Update document title from the fetched page if present, otherwise use generated title
|
||||
const pageTitleEl = parsed.querySelector("title");
|
||||
if (pageTitleEl && pageTitleEl.textContent && pageTitleEl.textContent.trim()) {
|
||||
document.title = pageTitleEl.textContent.trim();
|
||||
} else {
|
||||
document.title = routeToTitle(route);
|
||||
}
|
||||
}
|
||||
|
||||
function render(route, { replaceHistory = false } = {}) {
|
||||
const safeRoute = route || "index";
|
||||
|
||||
loadRoute(safeRoute)
|
||||
.then(() => {
|
||||
setActiveRoute(safeRoute);
|
||||
setCanonicalUrl(safeRoute, replaceHistory);
|
||||
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||
})
|
||||
.catch((error) => {
|
||||
main.innerHTML = `<section class="hero"><h1>Erreur de chargement</h1><p class="lead">${error.message}</p></section>`;
|
||||
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 });
|
||||
})();
|
||||
@@ -0,0 +1,35 @@
|
||||
(() => {
|
||||
/* 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]");
|
||||
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));
|
||||
});
|
||||
})();
|
||||
@@ -460,38 +460,6 @@
|
||||
grid-column: auto;
|
||||
}
|
||||
|
||||
.paquet-detail-nav {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding-top: 0.5rem;
|
||||
}
|
||||
|
||||
.paquet-detail-nav a {
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
font-size: 0.95rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 0.5rem;
|
||||
background: var(--surface);
|
||||
transition: color 160ms ease, background 160ms ease;
|
||||
}
|
||||
|
||||
.paquet-detail-nav a:hover {
|
||||
color: var(--accent-strong);
|
||||
background: var(--accent-bg);
|
||||
}
|
||||
|
||||
.paquet-detail-prev {
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.paquet-detail-next {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
/* ── Responsive ── */
|
||||
|
||||
@media (max-width: 700px) {
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Contact | FWS Linux</title>
|
||||
<meta name="description" content="Contactez l'équipe de FWS Linux — ouvrez une issue ou une pull request sur GitHub pour signaler un bug ou contribuer au projet." />
|
||||
<link rel="stylesheet" href="../assets/styles/styles.css">
|
||||
<link rel="stylesheet" href="../assets/styles/contact.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header class="contact-header">
|
||||
<h1>Contactez l'équipe de développement</h1>
|
||||
<p>Une question, un bug à signaler ou envie de contribuer ? Voici comment nous joindre.</p>
|
||||
</header>
|
||||
|
||||
<hr>
|
||||
|
||||
<main>
|
||||
<section>
|
||||
<h2>Notre seul canal officiel actuel</h2>
|
||||
<p>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.</p>
|
||||
<p>
|
||||
<strong>Suivez le projet et ouvrez des Issues / PR ici :</strong>
|
||||
</p>
|
||||
<a class="button button-primary" href="https://github.com/You-re-like-Windows-a-bitch/ISO" target="_blank" rel="noopener noreferrer">Notre GitHub</a>
|
||||
</section>
|
||||
|
||||
<hr>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* FWS Linux — page Contact (rendu serveur, contenu inchangé).
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
if (!defined('FWS_PAGE_SHELL')) {
|
||||
/* Accès direct (/p/contact/…) : on délègue au front controller. */
|
||||
require __DIR__ . '/../../page.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
$title = 'Contact | FWS Linux';
|
||||
$description = 'Contactez l\'équipe de FWS Linux — ouvrez une issue ou une pull request sur GitHub pour signaler un bug ou contribuer au projet.';
|
||||
$extraCss[] = '/p/assets/styles/contact.css';
|
||||
?>
|
||||
<header class="contact-header">
|
||||
<h1>Contactez l'équipe de développement</h1>
|
||||
<p>Une question, un bug à signaler ou envie de contribuer ? Voici comment nous joindre.</p>
|
||||
</header>
|
||||
|
||||
<hr>
|
||||
|
||||
<main>
|
||||
<section>
|
||||
<h2>Notre seul canal officiel actuel</h2>
|
||||
<p>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.</p>
|
||||
<p>
|
||||
<strong>Suivez le projet et ouvrez des Issues / PR ici :</strong>
|
||||
</p>
|
||||
<a class="button button-primary" href="https://github.com/You-re-like-Windows-a-bitch/ISO" target="_blank" rel="noopener noreferrer">Notre GitHub</a>
|
||||
</section>
|
||||
|
||||
<hr>
|
||||
</main>
|
||||
@@ -1,43 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Téléchargements | FWS Linux</title>
|
||||
<meta name="description" content="Téléchargez FWS Linux — dernière version stable et archives des versions précédentes. ISO légère basée sur Arch Linux." />
|
||||
<link rel="stylesheet" href="../assets/styles/downloads.css" />
|
||||
<link rel="icon" type="image/png" href="/p/assets/img/logo.png" />
|
||||
</head>
|
||||
<body>
|
||||
<main data-page-content>
|
||||
<section class="downloads" aria-labelledby="downloads-title">
|
||||
<header class="downloads-header">
|
||||
<h1 id="downloads-title">Téléchargements</h1>
|
||||
<div class="versions-panel">
|
||||
<div class="latest-version">
|
||||
<h2>Dernière version</h2>
|
||||
<div class="latest-row">
|
||||
<div class="latest-meta">
|
||||
<strong data-current-version>Chargement...</strong>
|
||||
<span data-current-version-date></span>
|
||||
</div>
|
||||
<div class="latest-actions">
|
||||
<a class="button" data-latest-download href="#" target="_blank" rel="noopener noreferrer">Télécharger</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="latest-note" data-current-release-note></div>
|
||||
<button class="toggle-note" data-toggle-release-note style="display:none">Voir plus</button>
|
||||
</div>
|
||||
|
||||
<div class="versions-archive">
|
||||
<h3>Versions précédentes</h3>
|
||||
<ul class="versions-list" data-versions-list role="list"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<script src="../assets/js/downloads.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/**
|
||||
* FWS Linux — page Téléchargements (rendu serveur).
|
||||
* Releases ISO : Gitea FWS/ISO s'il existe, sinon GitHub (cache 10 min).
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
if (!defined('FWS_PAGE_SHELL')) {
|
||||
/* Accès direct (/p/dl/…) : on délègue au front controller. */
|
||||
require __DIR__ . '/../../page.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
$releases = fws_site_iso_releases();
|
||||
$items = $releases['items'];
|
||||
$mode = $releases['mode'];
|
||||
|
||||
$title = 'Téléchargements | FWS Linux';
|
||||
$description = 'Téléchargez FWS Linux — dernière version stable et archives des versions précédentes. ISO légère basée sur Arch Linux.';
|
||||
$extraCss[] = '/p/assets/styles/downloads.css';
|
||||
$extraJs[] = '/p/assets/js/note-toggle.js';
|
||||
|
||||
$latest = $items[0] ?? null;
|
||||
$previous = array_slice($items, 1, 5);
|
||||
|
||||
$latestNote = '';
|
||||
$latestTruncated = false;
|
||||
$latestNoteFull = '';
|
||||
if ($latest !== null && $mode !== 'tags') {
|
||||
$latestNoteFull = fws_markdown((string) ($latest['body'] ?? ''));
|
||||
if ($latestNoteFull === '') {
|
||||
$latestNoteFull = '<p>Release la plus récente.</p>';
|
||||
}
|
||||
$tr = fws_truncate_html($latestNoteFull, 600);
|
||||
$latestNote = $tr['html'];
|
||||
$latestTruncated = $tr['truncated'];
|
||||
}
|
||||
?>
|
||||
<section class="downloads" aria-labelledby="downloads-title">
|
||||
<header class="downloads-header">
|
||||
<h1 id="downloads-title">Téléchargements</h1>
|
||||
<div class="versions-panel">
|
||||
<div class="latest-version">
|
||||
<h2>Dernière version</h2>
|
||||
<div class="latest-row">
|
||||
<div class="latest-meta">
|
||||
<strong data-current-version><?php
|
||||
if ($latest === null) {
|
||||
echo 'Aucune release trouvée';
|
||||
} else {
|
||||
echo e(fws_site_release_label($latest));
|
||||
if ($mode === 'tags') {
|
||||
echo ' (tag)';
|
||||
}
|
||||
}
|
||||
?></strong>
|
||||
<span data-current-version-date><?php
|
||||
if ($latest !== null && $mode !== 'tags') {
|
||||
$d = fws_format_date(fws_site_release_date($latest));
|
||||
echo $d !== '' ? ' · ' . e($d) : '';
|
||||
}
|
||||
?></span>
|
||||
</div>
|
||||
<div class="latest-actions">
|
||||
<a class="button" data-latest-download href="<?php
|
||||
if ($latest !== null && $mode === 'tags') {
|
||||
echo e('https://github.com/You-re-like-Windows-a-bitch/ISO/releases/tag/' . rawurlencode((string) ($latest['name'] ?? $latest['ref'] ?? '')));
|
||||
} elseif ($latest !== null) {
|
||||
echo e(fws_site_release_download_url($latest));
|
||||
} else {
|
||||
echo e('https://github.com/You-re-like-Windows-a-bitch/ISO');
|
||||
}
|
||||
?>" target="_blank" rel="noopener noreferrer">Télécharger</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="latest-note" data-current-release-note><?php
|
||||
if ($mode === 'tags' && $latest !== null) {
|
||||
echo '<p>Aucune release publiée pour le moment, affichage des tags du dépôt.</p>';
|
||||
} elseif ($latest === null) {
|
||||
echo '<p>Le dépôt ne renvoie ni release ni tag public.</p>';
|
||||
} else {
|
||||
echo $latestNote;
|
||||
}
|
||||
?><?php if ($latestTruncated): ?><template data-note-full><?= $latestNoteFull ?></template><?php endif; ?></div>
|
||||
<button class="toggle-note" data-toggle-release-note style="<?= $latestTruncated ? 'display:inline-block' : 'display:none' ?>">Voir plus</button>
|
||||
</div>
|
||||
|
||||
<div class="versions-archive">
|
||||
<h3>Versions précédentes</h3>
|
||||
<ul class="versions-list" data-versions-list role="list"><?php
|
||||
if ($items === []) {
|
||||
echo '<li class="version-item version-item-empty"><div class="version-main"><strong>Aucune release trouvée</strong><span>Le dépôt n\'expose pas encore de release ou les releases ne sont pas accessibles.</span></div>'
|
||||
. '<div class="version-side"><a class="button button-secondary" href="https://github.com/You-re-like-Windows-a-bitch/ISO" target="_blank" rel="noreferrer">Voir le repo</a></div></li>';
|
||||
} elseif ($previous === []) {
|
||||
echo '<li class="version-item version-item-empty"><div class="version-main"><strong>Aucune release précédente</strong><span>Il n\'y a qu\'une seule release publiée pour le moment.</span></div></li>';
|
||||
} 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 '<li class="version-item"><div class="version-main"><strong>' . e(fws_site_release_label($rel)) . '</strong>'
|
||||
. '<span>' . ($d !== '' ? 'Publié le ' . e($d) : ($mode === 'tags' ? 'Tag GitHub' : 'Date inconnue')) . '</span></div>'
|
||||
. '<div class="version-side"><a class="button button-secondary" href="' . e($url) . '" target="_blank" rel="noreferrer">Télécharger</a></div></li>';
|
||||
}
|
||||
}
|
||||
?></ul>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
</section>
|
||||
@@ -1,27 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>L'équipe | FWS Linux</title>
|
||||
<meta name="description" content="Découvrez les contributeurs de FWS Linux — l'équipe qui développe et maintient cette distribution open-source." />
|
||||
<link rel="stylesheet" href="../assets/styles/styles.css">
|
||||
<link rel="stylesheet" href="../assets/styles/equipe.css">
|
||||
<link rel="stylesheet" href="../assets/styles/creators.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<main data-page-content>
|
||||
<section class="equipe-hero">
|
||||
<h1>L'équipe</h1>
|
||||
<p>Les personnes qui contribuent au projet FWS Linux.</p>
|
||||
</section>
|
||||
|
||||
<section class="equipe-grid-section" aria-label="Liste des contributeurs">
|
||||
<div data-creators-src="/p/equipe/creators.json"></div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<script src="../assets/js/creators-loader.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* FWS Linux — page Équipe (rendu serveur depuis p/equipe/creators.json).
|
||||
* Remplace creators-loader.js.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
if (!defined('FWS_PAGE_SHELL')) {
|
||||
/* Accès direct (/p/equipe/…) : on délègue au front controller. */
|
||||
require __DIR__ . '/../../page.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
$title = "L'équipe | FWS Linux";
|
||||
$description = 'Découvrez les contributeurs de FWS Linux — l\'équipe qui développe et maintient cette distribution open-source.';
|
||||
$extraCss[] = '/p/assets/styles/equipe.css';
|
||||
$extraCss[] = '/p/assets/styles/creators.css';
|
||||
|
||||
$creators = [];
|
||||
$file = dirname(__DIR__) . '/equipe/creators.json';
|
||||
if (is_file($file)) {
|
||||
$data = json_decode((string) file_get_contents($file), true);
|
||||
if (is_array($data)) {
|
||||
$creators = fws_utf8_arr($data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<section class="equipe-hero">
|
||||
<h1>L'équipe</h1>
|
||||
<p>Les personnes qui contribuent au projet FWS Linux.</p>
|
||||
</section>
|
||||
|
||||
<section class="equipe-grid-section" aria-label="Liste des contributeurs">
|
||||
<?php if ($creators === []): ?>
|
||||
<p class="creators-error">Impossible de charger les données des créateurs.</p>
|
||||
<?php else: ?>
|
||||
<div class="creators-grid">
|
||||
<?php foreach ($creators as $creator): ?>
|
||||
<article class="creator-card">
|
||||
<?php if (!empty($creator['avatar'])): ?>
|
||||
<img class="creator-avatar" src="<?= e((string) $creator['avatar']) ?>" alt="<?= e((string) ($creator['name'] ?? $creator['role'] ?? '')) ?>" loading="lazy">
|
||||
<?php endif; ?>
|
||||
<div class="creator-info">
|
||||
<?php if (!empty($creator['name'])): ?>
|
||||
<h3 class="creator-name"><?= e((string) $creator['name']) ?></h3>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($creator['role'])): ?>
|
||||
<span class="creator-role"><?= e((string) $creator['role']) ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($creator['joined'])): ?>
|
||||
<span class="creator-joined">A rejoint le <?= e(fws_format_date((string) $creator['joined'])) ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($creator['email'])): ?>
|
||||
<a class="creator-email" href="mailto:<?= e((string) $creator['email']) ?>"><?= e((string) $creator['email']) ?></a>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($creator['links'])): ?>
|
||||
<div class="creator-links">
|
||||
<?php foreach ($creator['links'] as $link): ?>
|
||||
<a class="creator-link" href="<?= e((string) ($link['url'] ?? '')) ?>" target="_blank" rel="noopener noreferrer"><?= e((string) ($link['label'] ?? '') !== '' ? (string) $link['label'] : (string) ($link['url'] ?? '')) ?></a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
@@ -1,116 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Accueil | FWS Linux</title>
|
||||
<meta name="description" content="Découvrez FWS Linux — distribution open-source légère et rapide basée sur Arch Linux. Choisissez parmi KDE Plasma, Gnome, XFCE, Hyprland ou CLI." />
|
||||
<link rel="stylesheet" href="../assets/styles/main.css" />
|
||||
<link rel="icon" type="image/png" href="/p/assets/img/logo.png" />
|
||||
</head>
|
||||
<body>
|
||||
<main data-page-content>
|
||||
<section class="hero hero-carousel" aria-label="Présentation de FWS Linux">
|
||||
<div class="hero-carousel-track" data-hero-track>
|
||||
<article class="hero-slide is-active" data-hero-slide style="background-image: url('/p/assets/img/hero/xfce.webp');" aria-hidden="false"></article>
|
||||
<article class="hero-slide" data-hero-slide style="background-image: url('/p/assets/img/hero/install.webp');" aria-hidden="true"></article>
|
||||
<article class="hero-slide" data-hero-slide style="background-image: url('/p/assets/img/hero/gnome.webp');" aria-hidden="true"></article>
|
||||
</div>
|
||||
|
||||
<div class="hero-inner">
|
||||
<h1 class="hero-title">FWS Linux</h1>
|
||||
<p class="hero-subtitle">Un système léger, libre et compatible</p>
|
||||
<p class="lead">Open-source basé sur Arch Linux, FWS facilite la transition depuis Windows sans vous déposséder de vos données. Installation simplifiée, interface épurée, et compatibilité avec vos applications Windows grâce à Wine et Winboat.</p>
|
||||
<div class="hero-actions">
|
||||
<a class="button button-primary" href="/?p/dl/" data-route="dl">Télécharger</a>
|
||||
<a class="button button-secondary" href="/?p/contact/" data-route="contact">En savoir plus</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="hero-controls" aria-label="Contrôles du carrousel">
|
||||
<button class="hero-control" type="button" data-hero-prev aria-label="Image précédente">‹</button>
|
||||
<div class="hero-dots" data-hero-dots role="tablist" aria-label="Sélectionner une image"></div>
|
||||
<button class="hero-control" type="button" data-hero-next aria-label="Image suivante">›</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="features" aria-label="Fonctionnalités">
|
||||
<article class="card" tabindex="0">
|
||||
<h2>Installation simplifiée</h2>
|
||||
<p>Installateur graphique pour une configuration facile et rapide.</p>
|
||||
</article>
|
||||
<article class="card" tabindex="0">
|
||||
<h2>Léger et rapide</h2>
|
||||
<p>Conçu pour être peu gourmand en ressources : idéal pour redonner vie à d'anciens PC.</p>
|
||||
</article>
|
||||
<article class="card" tabindex="0">
|
||||
<h2>Respect de la vie privée</h2>
|
||||
<p>Pas de télémétrie intrusive ni de collecte de données : vous gardez le contrôle.</p>
|
||||
</article>
|
||||
<article class="card" tabindex="0">
|
||||
<h2>Compatibilité Windows</h2>
|
||||
<p>Exécutez vos logiciels Windows avec Wine et Winboat sans devoir rester sous Windows.</p>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="env-choices" aria-labelledby="env-choices-title">
|
||||
<header class="env-choices-header">
|
||||
<h2 id="env-choices-title">Choisissez votre environnement à l'installation</h2>
|
||||
<p>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.</p>
|
||||
</header>
|
||||
|
||||
<article class="env-row is-reverse">
|
||||
<div class="env-text">
|
||||
<h3>KDE Plasma</h3>
|
||||
<p>Interface moderne, complète et hautement personnalisable. Un excellent choix si vous voulez un bureau riche avec de nombreux outils intégrés.</p>
|
||||
</div>
|
||||
<figure class="env-media">
|
||||
<img src="/p/assets/img/hero/KDE.webp" alt="Capture d'écran de l'environnement KDE Plasma sur FWS Linux" loading="lazy" width="600" height="340" />
|
||||
</figure>
|
||||
</article>
|
||||
|
||||
<article class="env-row">
|
||||
<figure class="env-media">
|
||||
<img src="/p/assets/img/hero/gnome.webp" alt="Capture d'écran de l'environnement GNOME sur FWS Linux" loading="lazy" width="600" height="340" />
|
||||
</figure>
|
||||
<div class="env-text">
|
||||
<h3>GNOME</h3>
|
||||
<p>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.</p>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article class="env-row is-reverse">
|
||||
<div class="env-text">
|
||||
<h3>XFCE</h3>
|
||||
<p>Environnement léger et très stable, idéal pour les machines modestes ou pour privilégier les performances au quotidien.</p>
|
||||
</div>
|
||||
<figure class="env-media">
|
||||
<img src="/p/assets/img/hero/xfce.webp" alt="Capture d'écran de l'environnement XFCE sur FWS Linux" loading="lazy" width="600" height="340" />
|
||||
</figure>
|
||||
</article>
|
||||
|
||||
<article class="env-row">
|
||||
<figure class="env-media">
|
||||
<img src="/p/assets/img/hero/hyprland.webp" alt="Capture d'écran de l'environnement Hyprland sur FWS Linux" loading="lazy" width="600" height="340" />
|
||||
</figure>
|
||||
<div class="env-text">
|
||||
<h3>Hyprland</h3>
|
||||
<p>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.</p>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article class="env-row is-reverse">
|
||||
<div class="env-text">
|
||||
<h3>CLI (sans environnement)</h3>
|
||||
<p>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é.</p>
|
||||
</div>
|
||||
<figure class="env-media">
|
||||
<img src="/p/assets/img/hero/install.webp" alt="Capture d'écran de l'interface CLI de FWS Linux" loading="lazy" width="600" height="340" />
|
||||
</figure>
|
||||
</article>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<script src="../assets/js/hero-carousel.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* FWS Linux — page d'accueil (rendu serveur, markup identique à l'ancien).
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
if (!defined('FWS_PAGE_SHELL')) {
|
||||
/* Accès direct (/p/index/…) : on délègue au front controller. */
|
||||
require __DIR__ . '/../../page.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
$title = 'Accueil | FWS Linux';
|
||||
$description = 'Découvrez FWS Linux — distribution open-source légère et rapide basée sur Arch Linux. Choisissez parmi KDE Plasma, Gnome, XFCE, Hyprland ou CLI.';
|
||||
$extraCss[] = '/p/assets/styles/main.css';
|
||||
$extraJs[] = '/p/assets/js/hero-carousel.js';
|
||||
?>
|
||||
<section class="hero hero-carousel" aria-label="Présentation de FWS Linux">
|
||||
<div class="hero-carousel-track" data-hero-track>
|
||||
<article class="hero-slide is-active" data-hero-slide style="background-image: url('/p/assets/img/hero/xfce.webp');" aria-hidden="false"></article>
|
||||
<article class="hero-slide" data-hero-slide style="background-image: url('/p/assets/img/hero/install.webp');" aria-hidden="true"></article>
|
||||
<article class="hero-slide" data-hero-slide style="background-image: url('/p/assets/img/hero/gnome.webp');" aria-hidden="true"></article>
|
||||
</div>
|
||||
|
||||
<div class="hero-inner">
|
||||
<h1 class="hero-title">FWS Linux</h1>
|
||||
<p class="hero-subtitle">Un système léger, libre et compatible</p>
|
||||
<p class="lead">Open-source basé sur Arch Linux, FWS facilite la transition depuis Windows sans vous déposséder de vos données. Installation simplifiée, interface épurée, et compatibilité avec vos applications Windows grâce à Wine et Winboat.</p>
|
||||
<div class="hero-actions">
|
||||
<a class="button button-primary" href="/?p/dl/">Télécharger</a>
|
||||
<a class="button button-secondary" href="/?p/contact/">En savoir plus</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="hero-controls" aria-label="Contrôles du carrousel">
|
||||
<button class="hero-control" type="button" data-hero-prev aria-label="Image précédente">‹</button>
|
||||
<div class="hero-dots" data-hero-dots role="tablist" aria-label="Sélectionner une image"></div>
|
||||
<button class="hero-control" type="button" data-hero-next aria-label="Image suivante">›</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="features" aria-label="Fonctionnalités">
|
||||
<article class="card" tabindex="0">
|
||||
<h2>Installation simplifiée</h2>
|
||||
<p>Installateur graphique pour une configuration facile et rapide.</p>
|
||||
</article>
|
||||
<article class="card" tabindex="0">
|
||||
<h2>Léger et rapide</h2>
|
||||
<p>Conçu pour être peu gourmand en ressources : idéal pour redonner vie à d'anciens PC.</p>
|
||||
</article>
|
||||
<article class="card" tabindex="0">
|
||||
<h2>Respect de la vie privée</h2>
|
||||
<p>Pas de télémétrie intrusive ni de collecte de données : vous gardez le contrôle.</p>
|
||||
</article>
|
||||
<article class="card" tabindex="0">
|
||||
<h2>Compatibilité Windows</h2>
|
||||
<p>Exécutez vos logiciels Windows avec Wine et Winboat sans devoir rester sous Windows.</p>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="env-choices" aria-labelledby="env-choices-title">
|
||||
<header class="env-choices-header">
|
||||
<h2 id="env-choices-title">Choisissez votre environnement à l'installation</h2>
|
||||
<p>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.</p>
|
||||
</header>
|
||||
|
||||
<article class="env-row is-reverse">
|
||||
<div class="env-text">
|
||||
<h3>KDE Plasma</h3>
|
||||
<p>Interface moderne, complète et hautement personnalisable. Un excellent choix si vous voulez un bureau riche avec de nombreux outils intégrés.</p>
|
||||
</div>
|
||||
<figure class="env-media">
|
||||
<img src="/p/assets/img/hero/KDE.webp" alt="Capture d'écran de l'environnement KDE Plasma sur FWS Linux" loading="lazy" width="600" height="340" />
|
||||
</figure>
|
||||
</article>
|
||||
|
||||
<article class="env-row">
|
||||
<figure class="env-media">
|
||||
<img src="/p/assets/img/hero/gnome.webp" alt="Capture d'écran de l'environnement GNOME sur FWS Linux" loading="lazy" width="600" height="340" />
|
||||
</figure>
|
||||
<div class="env-text">
|
||||
<h3>GNOME</h3>
|
||||
<p>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.</p>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article class="env-row is-reverse">
|
||||
<div class="env-text">
|
||||
<h3>XFCE</h3>
|
||||
<p>Environnement léger et très stable, idéal pour les machines modestes ou pour privilégier les performances au quotidien.</p>
|
||||
</div>
|
||||
<figure class="env-media">
|
||||
<img src="/p/assets/img/hero/xfce.webp" alt="Capture d'écran de l'environnement XFCE sur FWS Linux" loading="lazy" width="600" height="340" />
|
||||
</figure>
|
||||
</article>
|
||||
|
||||
<article class="env-row">
|
||||
<figure class="env-media">
|
||||
<img src="/p/assets/img/hero/hyprland.webp" alt="Capture d'écran de l'environnement Hyprland sur FWS Linux" loading="lazy" width="600" height="340" />
|
||||
</figure>
|
||||
<div class="env-text">
|
||||
<h3>Hyprland</h3>
|
||||
<p>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.</p>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article class="env-row is-reverse">
|
||||
<div class="env-text">
|
||||
<h3>CLI (sans environnement)</h3>
|
||||
<p>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é.</p>
|
||||
</div>
|
||||
<figure class="env-media">
|
||||
<img src="/p/assets/img/hero/install.webp" alt="Capture d'écran de l'interface CLI de FWS Linux" loading="lazy" width="600" height="340" />
|
||||
</figure>
|
||||
</article>
|
||||
</section>
|
||||
@@ -1,18 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Paquet | FWS Linux</title>
|
||||
<link rel="stylesheet" href="../../assets/styles/styles.css">
|
||||
<link rel="stylesheet" href="../../assets/styles/paquets.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<main data-page-content>
|
||||
<section class="paquet-detail-page" data-package-detail></section>
|
||||
</main>
|
||||
|
||||
<script src="../../assets/js/packages.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* FWS Linux — page détail « /?p/paquets/N/ » (rendu serveur).
|
||||
* Le paquet N en grand : badge, tagline, description, dernière release,
|
||||
* historique, captures, liens. Pas de navigation précédent/suivant.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
if (!defined('FWS_PAGE_SHELL')) {
|
||||
/* Accès direct : /p/paquets/detail.php n'est pas une URL publique. */
|
||||
http_response_code(404);
|
||||
exit('Page introuvable.');
|
||||
}
|
||||
|
||||
/* Le paquet N est identifié par son id en base ; repli sur la position. */
|
||||
$pkg = null;
|
||||
foreach ($packages as $i => $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 '<section class="paquet-detail-page">'
|
||||
. '<p class="paquet-empty">Ce paquet n\'existe pas (il y en a ' . count($packages) . ').</p>'
|
||||
. '<a class="paquet-detail-back" href="/?p/paquets/">← Tous les paquets</a>'
|
||||
. '</section>';
|
||||
return;
|
||||
}
|
||||
|
||||
$title = $pkg['name'] . ' | FWS Linux';
|
||||
$description = (string) ($pkg['tagline'] ?? '') !== '' ? (string) $pkg['tagline'] : (string) ($pkg['description'] ?? '');
|
||||
|
||||
$latest = $pkg['latest'] ?? null;
|
||||
?>
|
||||
<section class="paquet-detail-page">
|
||||
<a class="paquet-detail-back" href="/?p/paquets/">← Tous les paquets</a>
|
||||
|
||||
<div class="paquet-detail-hero">
|
||||
<span class="paquet-since" title="<?= !empty($pkg['since']) ? e('Depuis le ' . fws_format_date((string) $pkg['since'])) : '' ?>"><?= e($pkg['sinceLabel'] !== '' ? $pkg['sinceLabel'] : 'FWS') ?></span>
|
||||
<h1><?= e($pkg['name']) ?></h1>
|
||||
<?php if (!empty($pkg['tagline'])): ?><p class="paquet-tagline"><?= e($pkg['tagline']) ?></p><?php endif; ?>
|
||||
<?php if (!empty($pkg['description'])): ?><p class="paquet-description"><?= e($pkg['description']) ?></p><?php endif; ?>
|
||||
<div class="paquet-detail-latest<?php if ($latest === null || ($latest['name'] ?? '') === ''): ?> paquet-detail-latest-empty<?php endif; ?>">
|
||||
<?php if ($latest !== null && ($latest['name'] ?? '') !== ''): ?>
|
||||
<span class="paquet-detail-version"><?= e((string) $latest['name']) ?></span>
|
||||
<?php if (!empty($latest['date'])): ?>
|
||||
<span class="paquet-detail-date">Publiée le <?= e(fws_format_date((string) $latest['date'])) ?></span>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
Aucune release publiée pour le moment.
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="paquet-detail-body">
|
||||
<?php if (empty($pkg['changelog'])): ?>
|
||||
<div class="paquet-changelog"><h3>Historique</h3><p class="paquet-empty">Historique en cours de rédaction.</p></div>
|
||||
<?php else: ?>
|
||||
<div class="paquet-changelog"><h3>Historique</h3>
|
||||
<ol class="paquet-timeline">
|
||||
<?php foreach ($pkg['changelog'] as $entry): ?>
|
||||
<li class="paquet-timeline-item">
|
||||
<strong class="paquet-timeline-version"><?= e((string) ($entry['version'] ?? '—')) ?></strong>
|
||||
<time class="paquet-timeline-date"<?= !empty($entry['date']) ? ' datetime="' . e((string) $entry['date']) . '"' : '' ?>><?= e(fws_format_date(isset($entry['date']) ? (string) $entry['date'] : null)) ?></time>
|
||||
<?php if (!empty($entry['notes'])): ?>
|
||||
<span class="paquet-timeline-notes"><?= e((string) $entry['notes']) ?></span>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (empty($pkg['screens'])): ?>
|
||||
<div class="paquet-screens"><h3>Captures d'écran</h3><p class="paquet-empty">Captures d'écran à venir.</p></div>
|
||||
<?php else: ?>
|
||||
<div class="paquet-screens"><h3>Captures d'écran</h3>
|
||||
<div class="paquet-screens-grid">
|
||||
<?php foreach ($pkg['screens'] as $screen): ?>
|
||||
<figure>
|
||||
<img src="<?= e((string) ($screen['src'] ?? '')) ?>" alt="<?= e((string) ($screen['alt'] ?? $pkg['name'])) ?>" loading="lazy">
|
||||
<?php if (!empty($screen['caption'])): ?>
|
||||
<figcaption><?= e((string) $screen['caption']) ?></figcaption>
|
||||
<?php endif; ?>
|
||||
</figure>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="paquet-links">
|
||||
<h3>Liens utiles</h3>
|
||||
<?php if (empty($pkg['links'])): ?>
|
||||
<p class="paquet-empty">Aucun lien pour le moment.</p>
|
||||
<?php else: ?>
|
||||
<?php foreach ($pkg['links'] as $link): ?>
|
||||
<?php $url = (string) ($link['url'] ?? ''); $external = (bool) preg_match('/^https?:\/\//i', $url); ?>
|
||||
<a class="button button-secondary" href="<?= e($url) ?>"<?= $external ? ' target="_blank" rel="noopener noreferrer"' : '' ?>><?= e((string) ($link['label'] ?? '') !== '' ? (string) $link['label'] : $url) ?></a>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
@@ -1,24 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Paquets | FWS Linux</title>
|
||||
<meta name="description" content="Les outils développés pour FWS Linux — historique de chaque paquet, captures d'écran et liens utiles." />
|
||||
<link rel="stylesheet" href="../assets/styles/styles.css">
|
||||
<link rel="stylesheet" href="../assets/styles/paquets.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<main data-page-content>
|
||||
<section class="paquets-hero">
|
||||
<h1>Paquets</h1>
|
||||
<p>Tous les outils développés pour FWS Linux, leur historique, leurs captures d'écran et les liens utiles.</p>
|
||||
</section>
|
||||
|
||||
<section class="paquets-list" data-packages-page aria-label="Liste des paquets FWS"></section>
|
||||
</main>
|
||||
|
||||
<script src="../assets/js/packages.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* FWS Linux — page Paquets (liste) : rendu serveur depuis la base SQLite
|
||||
* (avec releases Gitea fusionnées). Remplace packages.js.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
if (!defined('FWS_PAGE_SHELL')) {
|
||||
/* Accès direct (/p/paquets/…) : on délègue au front controller. */
|
||||
require __DIR__ . '/../../page.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
$title = 'Paquets | FWS Linux';
|
||||
$description = 'Les outils développés pour FWS Linux — historique de chaque paquet, captures d\'écran et liens utiles.';
|
||||
|
||||
function fws_packages_empty(string $message): string
|
||||
{
|
||||
return '<p class="paquet-empty">' . e($message) . '</p>';
|
||||
}
|
||||
|
||||
function fws_packages_changelog(array $pkg): string
|
||||
{
|
||||
$html = '<div class="paquet-changelog"><h3>Historique</h3>';
|
||||
if (empty($pkg['changelog'])) {
|
||||
$html .= fws_packages_empty('Historique en cours de rédaction.') . '</div>';
|
||||
return $html;
|
||||
}
|
||||
$html .= '<ol class="paquet-timeline">';
|
||||
foreach ($pkg['changelog'] as $entry) {
|
||||
$html .= '<li class="paquet-timeline-item">'
|
||||
. '<strong class="paquet-timeline-version">' . e((string) ($entry['version'] ?? '—')) . '</strong>'
|
||||
. '<time class="paquet-timeline-date"' . (empty($entry['date']) ? '' : ' datetime="' . e((string) $entry['date']) . '"') . '>'
|
||||
. e(fws_format_date(isset($entry['date']) ? (string) $entry['date'] : null)) . '</time>'
|
||||
. (!empty($entry['notes']) ? '<span class="paquet-timeline-notes">' . e((string) $entry['notes']) . '</span>' : '')
|
||||
. '</li>';
|
||||
}
|
||||
$html .= '</ol></div>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
function fws_packages_screens(array $pkg): string
|
||||
{
|
||||
$html = '<div class="paquet-screens"><h3>Captures d\'écran</h3>';
|
||||
if (empty($pkg['screens'])) {
|
||||
$html .= fws_packages_empty("Captures d'écran à venir.") . '</div>';
|
||||
return $html;
|
||||
}
|
||||
$html .= '<div class="paquet-screens-grid">';
|
||||
foreach ($pkg['screens'] as $screen) {
|
||||
$html .= '<figure><img src="' . e((string) ($screen['src'] ?? '')) . '" alt="'
|
||||
. e((string) ($screen['alt'] ?? ($pkg['name'] ?? ''))) . '" loading="lazy">';
|
||||
if (!empty($screen['caption'])) {
|
||||
$html .= '<figcaption>' . e((string) $screen['caption']) . '</figcaption>';
|
||||
}
|
||||
$html .= '</figure>';
|
||||
}
|
||||
$html .= '</div></div>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
function fws_packages_links(array $pkg): string
|
||||
{
|
||||
$html = '<div class="paquet-links"><h3>Liens utiles</h3>';
|
||||
if (empty($pkg['links'])) {
|
||||
$html .= fws_packages_empty('Aucun lien pour le moment.') . '</div>';
|
||||
return $html;
|
||||
}
|
||||
foreach ($pkg['links'] as $link) {
|
||||
$url = (string) ($link['url'] ?? '');
|
||||
$external = (bool) preg_match('/^https?:\/\//i', $url);
|
||||
$html .= '<a class="button button-secondary" href="' . e($url) . '"'
|
||||
. ($external ? ' target="_blank" rel="noopener noreferrer"' : '') . '>'
|
||||
. e((string) ($link['label'] ?? '') !== '' ? (string) $link['label'] : $url) . '</a>';
|
||||
}
|
||||
$html .= '</div>';
|
||||
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.';
|
||||
|
||||
$html = '<article class="paquet-card" id="paquet-' . e((string) $pkg['id']) . '">'
|
||||
. '<header class="paquet-head"><div class="paquet-title-row">'
|
||||
. '<h2>' . e($pkg['name']) . '</h2>'
|
||||
. '<span class="paquet-since" title="' . (!empty($pkg['since']) ? e('Depuis le ' . fws_format_date((string) $pkg['since'])) : '') . '">'
|
||||
. e($pkg['sinceLabel'] !== '' ? $pkg['sinceLabel'] : 'FWS') . '</span>'
|
||||
. '<a class="paquet-detail-link" href="/?p/paquets/' . $position . '/">Voir en grand</a>'
|
||||
. '</div>'
|
||||
. (!empty($pkg['tagline']) ? '<p class="paquet-tagline">' . e($pkg['tagline']) . '</p>' : '')
|
||||
. '<p class="paquet-latest">' . e($latestText) . '</p>'
|
||||
. (!empty($pkg['description']) ? '<p class="paquet-description">' . e($pkg['description']) . '</p>' : '')
|
||||
. '</header>'
|
||||
. '<div class="paquet-body">' . fws_packages_changelog($pkg) . fws_packages_screens($pkg) . fws_packages_links($pkg) . '</div>'
|
||||
. '</article>';
|
||||
return $html;
|
||||
}
|
||||
?>
|
||||
<section class="paquets-hero">
|
||||
<h1>Paquets</h1>
|
||||
<p>Tous les outils développés pour FWS Linux, leur historique, leurs captures d'écran et les liens utiles.</p>
|
||||
</section>
|
||||
|
||||
<section class="paquets-list" aria-label="Liste des paquets FWS">
|
||||
<?php if ($packages === []): ?>
|
||||
<?= fws_packages_empty('Aucun paquet pour le moment. Revenez bientôt !') ?>
|
||||
<?php else: ?>
|
||||
<?php foreach ($packages as $i => $pkg): ?>
|
||||
<?= fws_packages_card($pkg, max($i + 1, (int) ($pkg['dbId'] ?? 0))) . "\n" ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
@@ -0,0 +1,241 @@
|
||||
<?php
|
||||
/**
|
||||
* FWS Linux — point d'entrée unique du site (rendu 100 % serveur).
|
||||
*
|
||||
* Les URLs restent identiques : /?p/index/, /?p/dl/, /?p/paquets/,
|
||||
* /?p/paquets/1/… (les deux formes « ?p=route » et « ?p/route » marchent).
|
||||
* Chaque page inclut son corps depuis p/<route>/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 racine). */
|
||||
$path = trim((string) (parse_url((string) ($_SERVER['REQUEST_URI'] ?? '/'), PHP_URL_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'];
|
||||
if (in_array($route, $known, true)) {
|
||||
$pageFile = __DIR__ . '/p/' . $route . '/index.php';
|
||||
}
|
||||
}
|
||||
|
||||
$is404 = $pageFile === null || !is_file($pageFile);
|
||||
|
||||
/* 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',
|
||||
];
|
||||
$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;
|
||||
$canonical = 'https://fwslinux.fr/?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"' : '';
|
||||
}
|
||||
?><!doctype html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title><?= e($title) ?></title>
|
||||
<meta name="description" content="<?= e($description) ?>" />
|
||||
<meta name="robots" content="index, follow" />
|
||||
<link rel="canonical" href="<?= e($canonical) ?>" />
|
||||
|
||||
<!-- Open Graph -->
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:title" content="<?= e($title) ?>" />
|
||||
<meta property="og:description" content="<?= e($description) ?>" />
|
||||
<meta property="og:image" content="/p/assets/img/logo.png" />
|
||||
<meta property="og:locale" content="fr_FR" />
|
||||
|
||||
<link rel="stylesheet" href="/p/assets/styles/styles.css" />
|
||||
<link rel="stylesheet" href="/p/assets/styles/paquets.css" />
|
||||
<?php foreach ($extraCss as $css): ?>
|
||||
<link rel="stylesheet" href="<?= e($css) ?>" />
|
||||
<?php endforeach; ?>
|
||||
<link rel="icon" type="image/png" href="/p/assets/img/logo.png" />
|
||||
|
||||
<!-- Réseau : releases des paquets (Gitea) et de l'ISO (GitHub) -->
|
||||
<link rel="preconnect" href="https://gitea.nocode-var.tech" crossorigin />
|
||||
<link rel="dns-prefetch" href="https://gitea.nocode-var.tech" />
|
||||
<link rel="preconnect" href="https://api.github.com" crossorigin />
|
||||
<link rel="dns-prefetch" href="https://api.github.com" />
|
||||
<link rel="dns-prefetch" href="https://github.com" />
|
||||
<link rel="dns-prefetch" href="https://objects.githubusercontent.com" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a class="skip-link" href="#app-main">Aller au contenu principal</a>
|
||||
|
||||
<div class="page-shell">
|
||||
<header class="site-header" role="banner">
|
||||
<div class="header-brand-block">
|
||||
<a class="brand" href="/?p/index/" aria-label="FWS Linux — Retour à l'accueil">
|
||||
<img class="brand-mark" src="/p/assets/img/logo.png" alt="" width="44" height="44" />
|
||||
<span class="brand-text">
|
||||
<strong>FWS Linux</strong>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<nav class="site-nav" aria-label="Navigation principale">
|
||||
<a href="/?p/index/"<?= fws_site_active($route, 'index') ?>>Accueil</a>
|
||||
<a href="/?p/dl/"<?= fws_site_active($route, 'dl') ?>>Téléchargements</a>
|
||||
|
||||
<div class="nav-dropdown" data-nav-dropdown>
|
||||
<button type="button" class="nav-dropdown-toggle" aria-expanded="false" aria-haspopup="true" aria-controls="nav-paquets-panel"<?= fws_site_active($route, 'paquets') ?>>
|
||||
Paquets
|
||||
<span class="nav-dropdown-caret" aria-hidden="true"></span>
|
||||
</button>
|
||||
<div class="nav-dropdown-panel" id="nav-paquets-panel" role="group" aria-label="Liste des paquets">
|
||||
<div class="nav-dropdown-panel-inner">
|
||||
<?php if ($packages === []): ?>
|
||||
<p class="nav-dropdown-error">Aucun paquet pour le moment.</p>
|
||||
<?php else: ?>
|
||||
<?php foreach ($packages as $i => $pkg): ?>
|
||||
<a class="nav-dropdown-item" href="/?p/paquets/<?= max($i + 1, (int) $pkg['dbId']) ?>/">
|
||||
<strong><?= e($pkg['name']) ?><?php if (!empty($pkg['latest']['name'])): ?><span class="nav-dropdown-version"><?= e($pkg['latest']['name']) ?></span><?php endif; ?></strong>
|
||||
<small><?= e($pkg['tagline'] ?? '') ?></small>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<a class="nav-dropdown-all" href="/?p/paquets/">Voir tous les paquets →</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main id="app-main" class="site-main">
|
||||
<?= $body ?>
|
||||
</main>
|
||||
|
||||
<footer class="site-footer" role="contentinfo">
|
||||
<div class="footer-content">
|
||||
<div class="footer-brand-row">
|
||||
<div class="footer-brand-block">
|
||||
<img class="footer-brand-mark" src="/p/assets/img/logo.png" alt="" width="40" height="40" />
|
||||
<div>
|
||||
<strong>FWS Linux</strong>
|
||||
<p>Un système léger, libre et compatible</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer-links-grid">
|
||||
<nav aria-label="Navigation secondaire">
|
||||
<h2>Navigation</h2>
|
||||
<a href="/?p/index/">Accueil</a>
|
||||
<a href="/?p/dl/">Téléchargements</a>
|
||||
<a href="/?p/paquets/">Paquets</a>
|
||||
<a href="/?p/equipe/">Équipe</a>
|
||||
</nav>
|
||||
|
||||
<section>
|
||||
<h2>Contact</h2>
|
||||
<a href="/?p/contact/">Page de contact</a>
|
||||
<a href="/?p/equipe/">Équipe</a>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Réseaux</h2>
|
||||
<a href="https://github.com/You-re-like-Windows-a-bitch/ISO" target="_blank" rel="noopener noreferrer">GitHub</a>
|
||||
<a href="https://discord.gg/6mnpPr2jq4" target="_blank" rel="noopener noreferrer">Discord</a>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="footer-bottom">
|
||||
<p>© <?= date('Y') ?> FWS Linux</p>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<script src="/p/assets/main-nav/nav.js"></script>
|
||||
<?php foreach ($extraJs as $js): ?>
|
||||
<script src="<?= e($js) ?>"></script>
|
||||
<?php endforeach; ?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in new issue
Block a user