Compare commits
5
Commits
e1b9a5cc77
...
e3ce266225
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3ce266225 | ||
|
|
1643fcb591 | ||
|
|
1c21f6ff53 | ||
|
|
8869c74b7b | ||
|
|
3d0e21d7cb |
No files matched your search
@@ -0,0 +1,35 @@
|
||||
name: CI
|
||||
|
||||
# Lint and tests on every push and every pull request. `format:check` is
|
||||
# deliberately absent: the repository still holds CRLF files that predate the
|
||||
# Prettier configuration, so the step would fail on untouched code. Normalise
|
||||
# the line endings in a commit of their own, then add it here.
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
quality:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22'
|
||||
cache: npm
|
||||
|
||||
- name: Installer les dépendances
|
||||
run: npm ci
|
||||
|
||||
- name: Lint
|
||||
run: npm run lint
|
||||
|
||||
- name: Tests
|
||||
run: npm test
|
||||
|
||||
# The changelog is generated from the commit history, so a stale one is
|
||||
# a real defect rather than a formatting detail.
|
||||
- name: Changelog à jour
|
||||
run: npm run changelog:check
|
||||
@@ -7,6 +7,27 @@ The project follows [Semantic Versioning](https://semver.org/).
|
||||
## [Unreleased]
|
||||
|
||||
### Features
|
||||
- **projects:** _(feat)_ pull Gitea issues onto any board ([1c21f6f])
|
||||
- **wiki:** _(feat)_ serve the legal pages at /terms-of-service and /privacy-policy ([3d0e21d])
|
||||
- **projects:** _(feat)_ add the board interface ([e1b9a5c])
|
||||
- **projects:** _(feat)_ add a Kanban board per repository and one for the organization ([901ca56])
|
||||
- **web:** _(feat)_ open a repository from anywhere on its row ([95b51ab])
|
||||
- **wiki:** _(feat)_ add the reading site and its editor ([e5b7303])
|
||||
- **wiki:** _(feat)_ serve a public documentation written from the panel ([c76c0b9])
|
||||
- **web:** _(feat)_ publish the slash commands from the panel ([2622744])
|
||||
- **voice:** _(feat)_ take back the generated channels the database forgot ([b42fb10])
|
||||
- **settings:** _(feat)_ make the server settings real, and widen them ([406b5af])
|
||||
- **web:** _(feat)_ make deploying reachable from where it is looked for ([d439b1b])
|
||||
- **web:** _(feat)_ refresh the pages as the events arrive ([5481e79])
|
||||
- **web:** _(feat)_ push live updates to the dashboard ([df89cc5])
|
||||
- **web:** _(feat)_ serve the dashboard and its interface ([06a9be0])
|
||||
- **web:** _(feat)_ expose the dashboard API ([bf92bad])
|
||||
- **web:** _(feat)_ run and record release deployments ([611129b])
|
||||
- **web:** _(feat)_ read, validate and write the .env configuration ([efaaca3])
|
||||
- **web:** _(feat)_ add the HTTP layer and Discord-backed sessions ([e03b184])
|
||||
- **database:** _(feat)_ store dashboard sessions, deploy targets and deployments ([5abe713])
|
||||
- **gitea:** _(feat)_ add an organization and repository administration client ([4b0737a])
|
||||
- **config:** _(feat)_ declare the web dashboard environment variables ([e4534d4])
|
||||
- **status:** _(feat)_ rotate an editable list of bot statuses ([c785e9a])
|
||||
- **voice:** _(feat)_ guarantee an empty generated channel disappears ([76e2269])
|
||||
- **voice:** _(feat)_ support several trigger channels with their own category ([836abea])
|
||||
@@ -66,7 +87,32 @@ The project follows [Semantic Versioning](https://semver.org/).
|
||||
- **config:** _(feat)_ add colors, access levels and ticket categories ([eca9bbe])
|
||||
- **config:** _(feat)_ load and expose environment settings ([d1388b6])
|
||||
|
||||
### Bug Fixes
|
||||
- **wiki:** _(fix)_ render the public pages on the server ([8869c74])
|
||||
- **web:** _(fix)_ stop caching the interface modules ([3f4a570])
|
||||
- **web:** _(fix)_ keep the stack when a view fails ([c031b4d])
|
||||
- **web:** _(fix)_ read the interface build date instead of freezing it at startup ([92c27ae])
|
||||
- **web:** _(fix)_ stop the settings page breaking on an unexpected payload ([75d1e53])
|
||||
- **web:** _(fix)_ give static assets a validator caches can check ([539b150])
|
||||
- **web:** _(fix)_ say when the dashboard is disabled ([3bd290c])
|
||||
- **web:** _(fix)_ say out loud when the dashboard cannot listen ([afcd0e5])
|
||||
- **config:** _(fix)_ warn when a public address is announced but only loopback is bound ([40032ec])
|
||||
- **web:** _(fix)_ make the whole repository card open the repository ([e397abc])
|
||||
- **web:** _(fix)_ pin the sidebar highlight to the route, and name the build ([a44ff0c])
|
||||
- **web:** _(fix)_ always offer the bootstrap token on the sign-in page ([9c6297e])
|
||||
- **web:** _(fix)_ let a deploy target be created without a reachable Gitea ([ff15dfe])
|
||||
- **web:** _(fix)_ keep the sidebar in step with the page being shown ([a0428e0])
|
||||
- **web:** _(fix)_ derive the OAuth2 redirect from the address actually used ([20ff701])
|
||||
- **notifications:** _(fix)_ apply the channel overrides set from Discord ([92405ac])
|
||||
|
||||
### Other changes
|
||||
- **web:** _(test)_ lock the sidebar highlighting behind tests ([b793298])
|
||||
- **web:** _(docs)_ document the wiki, the settings and the command publishing ([5660235])
|
||||
- **web:** _(style)_ adopt the official FWS mark and its palette ([621f3e4])
|
||||
- **web:** _(docs)_ document the live updates ([2083133])
|
||||
- **web:** _(docs)_ document the dashboard and the configuration wizard ([e63d6aa])
|
||||
- **web:** _(test)_ cover the router, configuration, auth, deployments and server ([bd7fdea])
|
||||
- **all:** _(refactor)_ uniformisation ([50665c8])
|
||||
- **readme:** _(docs)_ translate the documentation and document the contribution workflow ([9bbe9cb])
|
||||
- **changelog:** _(build)_ generate the changelog from the commit history ([478ae41])
|
||||
- **gitignore:** _(chore)_ ignore the AI assistant data and the other toolchains ([2df33c2])
|
||||
|
||||
@@ -533,6 +533,7 @@ The rules shared by every FWS repository live in the [organisation `.profile`](h
|
||||
- FWS documentation: `[link to add]`
|
||||
- Technical documentation: [`docs/architecture.md`](docs/architecture.md)
|
||||
- Web dashboard: [`docs/web-dashboard.md`](docs/web-dashboard.md)
|
||||
- Operations (deployment, continuous integration, monitoring, backups): [`docs/exploitation.md`](docs/exploitation.md)
|
||||
- Organisation conventions: [`.profile/README.md`](https://gitea.nocode-var.tech/FWS/.profile/src/branch/main/README.en.md)
|
||||
- Changelog: [`CHANGELOG.md`](CHANGELOG.md) _(generated)_
|
||||
- Instructions for AI agents: [`AGENTS.md`](AGENTS.md)
|
||||
|
||||
@@ -538,6 +538,7 @@ Les règles communes à tous les repos FWS sont décrites dans le [`.profile` de
|
||||
- Documentation FWS : `[lien à ajouter]`
|
||||
- Documentation technique : [`docs/architecture.md`](docs/architecture.md)
|
||||
- Tableau de bord web : [`docs/web-dashboard.md`](docs/web-dashboard.md)
|
||||
- Exploitation (déploiement, intégration continue, surveillance, sauvegardes) : [`docs/exploitation.md`](docs/exploitation.md)
|
||||
- Conventions de l'organisation : [`.profile/README.md`](https://gitea.nocode-var.tech/FWS/.profile/src/branch/main/README.md)
|
||||
- Journal des modifications : [`CHANGELOG.md`](CHANGELOG.md) *(généré)*
|
||||
- Instructions pour les agents IA : [`AGENTS.md`](AGENTS.md)
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
# Exploitation
|
||||
|
||||
Comment déployer, vérifier, surveiller et sauvegarder FWS-Bot en production. Écrit pour un hébergement de type panel (Pterodactyl), qui est le cas actuel.
|
||||
|
||||
Les quatre chapitres sont indépendants et classés par valeur décroissante.
|
||||
|
||||
---
|
||||
|
||||
## 1. Déployer sans archive
|
||||
|
||||
**Le problème qu'on résout.** Téléverser un zip laisse régulièrement une copie partielle : le front plus ancien que l'API, un module oublié, une page qui plante sans raison apparente. Trois symptômes pour une seule cause, et aucun moyen simple de savoir laquelle.
|
||||
|
||||
Un déploiement reproductible supprime toute la famille.
|
||||
|
||||
> **L'onglet « Console » de Pterodactyl n'est pas un terminal** : c'est l'entrée/sortie du processus en cours. On n'y lance pas de commande shell, même avec tous les droits du panel. Si tu disposes d'un vrai shell ailleurs, suis le point 1.0 ; sinon, tout se fait depuis le tableau de bord, à partir du point 1.1.
|
||||
|
||||
### 1.0 Si tu as un accès shell
|
||||
|
||||
Assure-toi d'abord d'être **sur le bon système de fichiers** — celui que le bot lit. Un `git pull` au mauvais endroit ne produit aucune erreur et ne change rien, ce qui est le plus trompeur des résultats :
|
||||
|
||||
```bash
|
||||
cd /home/container
|
||||
ls package.json src/index.js .env && echo "bon endroit"
|
||||
```
|
||||
|
||||
Si cette commande échoue, ton shell ne voit pas le conteneur du bot : passe au point 1.1.
|
||||
|
||||
Sinon, l'amorçage se fait directement :
|
||||
|
||||
```bash
|
||||
cp .env .env.sauvegarde && tar czf data-sauvegarde.tgz data/
|
||||
|
||||
git init
|
||||
git remote add origin https://gitea.nocode-var.tech/FWS/fws-discordbot.git
|
||||
git fetch origin main
|
||||
git reset --hard origin/main
|
||||
npm ci --omit=dev
|
||||
```
|
||||
|
||||
Puis saute au point 1.3 pour déclarer la cible de production, qui te permettra de déployer d'un clic depuis le tableau de bord plutôt que de revenir ici à chaque fois.
|
||||
|
||||
> ⚠️ Ne lance **jamais** `git clean -fd` dans ce dossier : il effacerait `.env` et la base.
|
||||
|
||||
### 1.1 Autoriser l'exécution de commandes
|
||||
|
||||
**Tableau de bord → Configuration .env → Tableau de bord web** (niveau Owner) :
|
||||
|
||||
| Variable | Valeur |
|
||||
| --------------------------- | ------ |
|
||||
| `WEB_ALLOW_COMMAND_DEPLOYS` | `true` |
|
||||
| `WEB_ALLOW_RESTART` | `true` |
|
||||
|
||||
Enregistre, puis redémarre le bot depuis le panel. Ces deux valeurs ne sont lues qu'au démarrage.
|
||||
|
||||
> Elles permettent d'exécuter une commande sur la machine du bot depuis un navigateur — une exécution de code arbitraire. Réservées au niveau Owner, désactivées par défaut. N'ouvre l'accès Owner qu'à des personnes de confiance.
|
||||
|
||||
### 1.2 Amorcer le clone sans shell
|
||||
|
||||
Si le point 1.0 ne s'applique pas : le dossier du conteneur contient aujourd'hui une archive décompressée, pas un dépôt. On le convertit avec une cible jetable, exécutée par le bot lui-même.
|
||||
|
||||
**Déploiements → Nouvelle cible**
|
||||
|
||||
| Champ | Valeur |
|
||||
| --------------------- | -------------------------------- |
|
||||
| Nom | `amorçage` |
|
||||
| Dépôt | `FWS/fws-discordbot` |
|
||||
| Type | Commande shell sur l'hôte du bot |
|
||||
| Répertoire de travail | `/home/container` |
|
||||
| Commande | voir ci-dessous |
|
||||
|
||||
```bash
|
||||
git init && git remote add origin https://gitea.nocode-var.tech/FWS/fws-discordbot.git && git fetch origin main && git reset --hard origin/main
|
||||
```
|
||||
|
||||
Clique **Déployer**, puis lis le journal dans l'historique. Deux cas d'échec :
|
||||
|
||||
- **`git: not found`** — l'image du conteneur n'a pas git. Utilise la variante sans git du point 1.5.
|
||||
- **authentification refusée** — le dépôt est privé. Remplace l'URL par `https://<utilisateur>:<jeton>@gitea.nocode-var.tech/FWS/fws-discordbot.git`. Le jeton est alors stocké dans la configuration de la cible, en base : utilise un jeton dédié, en lecture seule.
|
||||
|
||||
`git reset --hard` écrase les fichiers **suivis**. Ton `.env` et ton dossier `data/` sont ignorés par git, donc intacts.
|
||||
|
||||
> ⚠️ N'ajoute **jamais** `git clean -fd` à cette commande : elle effacerait `.env` et la base.
|
||||
|
||||
Supprime ensuite la cible `amorçage` : elle ne sert qu'une fois.
|
||||
|
||||
### 1.3 Déclarer la cible de production
|
||||
|
||||
**Déploiements → Nouvelle cible**
|
||||
|
||||
| Champ | Valeur |
|
||||
| ----------------------- | ---------------------------------------------------------------------------- |
|
||||
| Nom | `production` |
|
||||
| Dépôt | `FWS/fws-discordbot` |
|
||||
| Environnement | `production` |
|
||||
| Type | Commande shell sur l'hôte du bot |
|
||||
| Répertoire de travail | `/home/container` |
|
||||
| Commande | `git fetch origin main && git reset --hard origin/main && npm ci --omit=dev` |
|
||||
| Déploiement automatique | à activer si tu veux qu'une release publiée déploie seule |
|
||||
|
||||
### 1.4 Le cycle courant
|
||||
|
||||
1. **Déploiements → Déployer** sur `production`. Le journal complet est conservé, réussite comme échec.
|
||||
2. **Paramètres → Redémarrer le bot** — le code n'est relu qu'au démarrage.
|
||||
|
||||
Contrôle, depuis n'importe où :
|
||||
|
||||
```bash
|
||||
curl -s http://node01.zi-host.ch:25571/api/health
|
||||
```
|
||||
|
||||
`buildAt` doit refléter ton dernier commit. C'est le seul indicateur fiable de ce qui tourne réellement.
|
||||
|
||||
### 1.5 Si le conteneur n'a pas git
|
||||
|
||||
Gitea sert une archive de n'importe quelle branche. La commande devient :
|
||||
|
||||
```bash
|
||||
curl -sL -H "Authorization: token TON_JETON" https://gitea.nocode-var.tech/api/v1/repos/FWS/fws-discordbot/archive/main.tar.gz | tar xz --strip-components=1 && npm ci --omit=dev
|
||||
```
|
||||
|
||||
Moins bien que git — pas d'historique, pas de moyen de savoir ce qui a changé — mais reproductible, et suffisant pour supprimer le téléversement à la main.
|
||||
|
||||
### Ce qu'il faut savoir
|
||||
|
||||
- `npm ci --omit=dev` n'installe ni ESLint, ni Prettier, ni de quoi lancer les tests. C'est voulu : ils tournent en intégration continue (chapitre 2), pas en production.
|
||||
- Si ton egg Pterodactyl réinstalle les fichiers au démarrage, il écrasera le clone. Vérifie l'option _Auto-update / Reinstall on boot_ et désactive-la.
|
||||
- Les migrations de base s'appliquent toutes seules au démarrage : rien à lancer.
|
||||
- Tout ce chapitre reste faisable en **SFTP** si tu préfères : le panel en donne les identifiants, et un client comme FileZilla remplace le téléversement par zip. Mais tu restes exposé à la copie partielle, que le déploiement par commande supprime.
|
||||
|
||||
---
|
||||
|
||||
## 2. Faire tourner les tests avant de déployer
|
||||
|
||||
**Le problème qu'on résout.** 301 tests et un lint existent, et ne tournent jamais avant une mise en production. Un déplacement de cartes cassé est passé inaperçu jusqu'à ce qu'un test l'attrape — après coup.
|
||||
|
||||
Le fichier de workflow est déjà dans le dépôt : [`.gitea/workflows/ci.yml`](../.gitea/workflows/ci.yml). Il reste à donner un exécuteur à Gitea.
|
||||
|
||||
### 2.1 Activer Actions sur l'instance
|
||||
|
||||
Côté administration Gitea, dans `app.ini` :
|
||||
|
||||
```ini
|
||||
[actions]
|
||||
ENABLED = true
|
||||
```
|
||||
|
||||
Puis redémarrer Gitea. Si l'instance ne t'appartient pas, c'est à demander à son administration.
|
||||
|
||||
### 2.2 Enregistrer un exécuteur
|
||||
|
||||
**Dépôt → Settings → Actions → Runners → Create new runner** te donne un jeton d'enregistrement.
|
||||
|
||||
Sur une machine qui a Docker et qui joint ton Gitea — ton poste, un VPS, ou le nœud lui-même :
|
||||
|
||||
```bash
|
||||
curl -sL -o act_runner \
|
||||
https://gitea.com/gitea/act_runner/releases/download/v0.2.11/act_runner-0.2.11-linux-amd64
|
||||
chmod +x act_runner
|
||||
|
||||
./act_runner register --no-interactive \
|
||||
--instance https://gitea.nocode-var.tech \
|
||||
--token <JETON_DENREGISTREMENT> \
|
||||
--name fws-runner \
|
||||
--labels ubuntu-latest:docker://node:22-bookworm
|
||||
|
||||
./act_runner daemon
|
||||
```
|
||||
|
||||
Sans Docker, remplace l'étiquette par `ubuntu-latest:host` — les tâches s'exécutent alors directement sur la machine, qui doit avoir Node 22.
|
||||
|
||||
Pour qu'il survive à un redémarrage, place-le en service systemd ou en conteneur `--restart=always`.
|
||||
|
||||
### 2.3 Vérifier
|
||||
|
||||
Pousse une branche : l'onglet **Actions** du dépôt montre le résultat, et la pull request affiche son état.
|
||||
|
||||
### Pourquoi `format:check` n'est pas dans le workflow
|
||||
|
||||
Le dépôt contient encore des fichiers en CRLF antérieurs à la configuration Prettier. L'étape échouerait sur du code que personne n'a touché.
|
||||
|
||||
Pour l'ajouter : normalise les fins de ligne dans un commit dédié (`refactor(all): normalise les fins de ligne`), puis ajoute l'étape. Tant que ce n'est pas fait, l'absence est volontaire.
|
||||
|
||||
---
|
||||
|
||||
## 3. Savoir que le bot est tombé
|
||||
|
||||
**Le problème qu'on résout.** Une soirée passée à chercher pourquoi le site ne répondait plus, alors qu'une sonde aurait répondu en trente secondes.
|
||||
|
||||
Le bot expose déjà tout ce qu'il faut :
|
||||
|
||||
```json
|
||||
GET /api/health
|
||||
{ "status": "ok", "version": "0.1.0", "buildAt": "…", "uptimeMs": 106470 }
|
||||
```
|
||||
|
||||
### 3.1 Surveiller depuis l'extérieur
|
||||
|
||||
Un bot ne peut pas signaler sa propre mort : il faut une sonde **externe**. [Uptime Kuma](https://github.com/louislam/uptime-kuma) est léger et sait écrire sur Discord.
|
||||
|
||||
```bash
|
||||
docker run -d --restart=always -p 3001:3001 \
|
||||
-v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1
|
||||
```
|
||||
|
||||
Puis, dans son interface :
|
||||
|
||||
| Réglage | Valeur |
|
||||
| ------------ | ------------------------------------------- |
|
||||
| Type | HTTP(s) - Keyword |
|
||||
| URL | `http://node01.zi-host.ch:25571/api/health` |
|
||||
| Mot-clé | `"status":"ok"` |
|
||||
| Intervalle | 60 s |
|
||||
| Notification | Webhook Discord vers ton salon de logs |
|
||||
|
||||
> **Surveille l'origine, pas le domaine public.** Cloudflare renvoie un challenge à toute requête non-navigateur : une sonde sur `https://fws-bot.laxacube.ch` signalerait une panne permanente qui n'existe pas.
|
||||
|
||||
Le mot-clé compte : une page qui répond `200` mais sans `"status":"ok"` n'est pas un bot en bonne santé.
|
||||
|
||||
### 3.2 Ce que le bot surveille déjà lui-même
|
||||
|
||||
- Chaque déploiement, réussi ou non, est annoncé sur Discord et consigné avec son journal.
|
||||
- Les erreurs d'appel Gitea partent dans le salon `errors`.
|
||||
- **Paramètres → Tester la connexion** vérifie Discord et Gitea à la demande.
|
||||
|
||||
Ça couvre les pannes partielles. Ça ne couvre pas un processus mort — d'où le point 3.1.
|
||||
|
||||
---
|
||||
|
||||
## 4. Sauvegarder hors du conteneur
|
||||
|
||||
**Le problème qu'on résout.** Le bouton _Sauvegarder la base_ écrit dans `data/backups`, **à l'intérieur du conteneur**. Une reconstruction efface les deux. C'est déjà arrivé : les salons vocaux orphelins venaient d'une base repartie de zéro.
|
||||
|
||||
### 4.1 Sauvegardes du panel (le plus simple)
|
||||
|
||||
Pterodactyl sait archiver le serveur entier, hors conteneur.
|
||||
|
||||
**Panel → Schedules → Create schedule**
|
||||
|
||||
| Réglage | Valeur |
|
||||
| ------- | ----------------------- |
|
||||
| Nom | Sauvegarde hebdomadaire |
|
||||
| Cron | `0 4 * * 1` (lundi 4 h) |
|
||||
| Tâche | _Create backup_ |
|
||||
|
||||
Les archives apparaissent dans l'onglet **Backups**, avec téléchargement. Vérifie la limite d'archives de ton offre.
|
||||
|
||||
### 4.2 Instantané cohérent de la base
|
||||
|
||||
Une archive de fichiers peut attraper la base en cours d'écriture. Le bot, lui, produit une copie cohérente (`VACUUM INTO`), même journal WAL actif.
|
||||
|
||||
Crée un jeton dans **Paramètres → Jetons d'API** (niveau Owner), puis, depuis une machine qui tourne en permanence :
|
||||
|
||||
```bash
|
||||
# Chaque nuit à 3 h
|
||||
0 3 * * * curl -sS -X POST -H "Authorization: Bearer fws_…" \
|
||||
http://node01.zi-host.ch:25571/api/settings/backup
|
||||
```
|
||||
|
||||
Le fichier atterrit dans `BACKUP_DIR`, que la sauvegarde du panel emporte ensuite.
|
||||
|
||||
### 4.3 Vraiment hors site
|
||||
|
||||
Une sauvegarde chez le même hébergeur ne protège pas d'un incident chez lui. Depuis une machine qui a l'accès SFTP du panel :
|
||||
|
||||
```bash
|
||||
rclone sync sftp-panel:/home/container/data backblaze:fws-bot-backups \
|
||||
--backup-dir backblaze:fws-bot-backups/anciens/$(date +%F)
|
||||
```
|
||||
|
||||
### 4.4 Tester la restauration
|
||||
|
||||
Une sauvegarde jamais restaurée n'est pas une sauvegarde. Une fois :
|
||||
|
||||
```bash
|
||||
cp fws-bot-2026-09-24.sqlite /tmp/test.sqlite
|
||||
DATABASE_PATH=/tmp/test.sqlite npm run db:init
|
||||
```
|
||||
|
||||
La commande doit se terminer sans erreur et appliquer les migrations.
|
||||
|
||||
---
|
||||
|
||||
## Dans quel ordre
|
||||
|
||||
1. **Chapitre 1** — supprime une famille entière de pannes, ne demande que de la configuration.
|
||||
2. **Chapitre 2** — évite de découvrir un bug en production.
|
||||
3. **Chapitre 4** — protège ce qui n'est pas remplaçable.
|
||||
4. **Chapitre 3** — utile, mais vient après ce qui empêche les pannes plutôt que ce qui les signale.
|
||||
@@ -0,0 +1,9 @@
|
||||
-- The legal pages move to the addresses platforms expect (M17)
|
||||
--
|
||||
-- Discord, and most app stores, ask for a terms URL and a privacy URL. Serving
|
||||
-- them under `/wiki/` works but reads badly in a form field, so they move to
|
||||
-- the root. Renaming rather than recreating keeps whatever the organization
|
||||
-- has already written in them.
|
||||
|
||||
UPDATE wiki_pages SET slug = 'terms-of-service' WHERE slug = 'conditions-utilisation';
|
||||
UPDATE wiki_pages SET slug = 'privacy-policy' WHERE slug = 'politique-confidentialite';
|
||||
+30
-9
@@ -407,26 +407,40 @@ export function registerProjectRoutes(router) {
|
||||
{ access: ACCESS_LEVELS.STAFF },
|
||||
);
|
||||
|
||||
/** Turns the open issues of a repository into cards, skipping the ones already there. */
|
||||
/**
|
||||
* Pulls issues from Gitea onto the board.
|
||||
*
|
||||
* An issue already on the board is skipped rather than duplicated, so the
|
||||
* button can be pressed again after a sprint without cleaning up after it.
|
||||
*/
|
||||
router.post(
|
||||
'/api/projects/:id/import',
|
||||
async ({ params, body, actor }) => {
|
||||
const found = board(params.id);
|
||||
const repository = String(body.repository ?? found.repository ?? '');
|
||||
const parts = splitRepository(repository);
|
||||
if (!parts) throw badRequest('Dépôt attendu au format `organisation/depot`.');
|
||||
if (!isGiteaConfigured()) throw badRequest('Gitea n’est pas configuré.');
|
||||
|
||||
const repository = String(body.repository ?? found.repository ?? '').trim();
|
||||
const parts = splitRepository(repository);
|
||||
if (!parts) throw badRequest('Dépôt attendu au format `organisation/depot`.');
|
||||
|
||||
const state = body.state === 'all' ? 'all' : 'open';
|
||||
const columns = listColumns(found.id);
|
||||
const target = columns.find((column) => !column.is_done) ?? columns[0];
|
||||
if (!target) throw badRequest('Ce tableau n’a aucune colonne.');
|
||||
if (columns.length === 0) throw badRequest('Ce tableau n’a aucune colonne.');
|
||||
|
||||
// Falls back to the first column that is not the finished one: importing
|
||||
// straight into « Terminé » is never what anyone means.
|
||||
const requested = body.columnId ? getColumn(Number.parseInt(body.columnId, 10)) : null;
|
||||
const target =
|
||||
requested && requested.board_id === found.id
|
||||
? requested
|
||||
: (columns.find((column) => !column.is_done) ?? columns[0]);
|
||||
|
||||
const existing = new Set(
|
||||
listCards(found.id)
|
||||
.map((card) => card.issue_ref)
|
||||
.filter(Boolean),
|
||||
);
|
||||
const issues = await repos.listIssues(parts.owner, parts.repo, { state: 'open', limit: 50 });
|
||||
const issues = await repos.listIssues(parts.owner, parts.repo, { state, limit: 100 });
|
||||
|
||||
let imported = 0;
|
||||
for (const issue of issues) {
|
||||
@@ -440,13 +454,20 @@ export function registerProjectRoutes(router) {
|
||||
body: issue.body ? String(issue.body).slice(0, 2000) : null,
|
||||
issueRef: ref,
|
||||
labels: (issue.labels ?? []).map((label) => label.name),
|
||||
dueAt: issue.due_date ? String(issue.due_date).slice(0, 10) : null,
|
||||
createdBy: actor.userId,
|
||||
});
|
||||
imported += 1;
|
||||
}
|
||||
|
||||
audit(actor, 'web.project.import', { board: found.id, repository, imported });
|
||||
return { imported, skipped: issues.length - imported, column: target.name };
|
||||
audit(actor, 'web.project.import', { board: found.id, repository, state, imported });
|
||||
return {
|
||||
imported,
|
||||
skipped: issues.length - imported,
|
||||
found: issues.length,
|
||||
column: target.name,
|
||||
repository,
|
||||
};
|
||||
},
|
||||
{ access: ACCESS_LEVELS.STAFF },
|
||||
);
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
updatePage,
|
||||
} from '../../database/repositories/wiki-repository.js';
|
||||
import { badRequest, forbidden, notFound } from '../http.js';
|
||||
import { pagePath } from '../services/wiki-seed.js';
|
||||
|
||||
/**
|
||||
* Public wiki, written from the dashboard (M17).
|
||||
@@ -26,6 +27,7 @@ const SLUG = /^[a-z0-9][a-z0-9-]{0,80}$/;
|
||||
/** Shown in a listing: everything but the body, which can be long. */
|
||||
const summarize = (page) => ({
|
||||
slug: page.slug,
|
||||
path: pagePath(page.slug),
|
||||
title: page.title,
|
||||
summary: page.summary,
|
||||
category: page.category,
|
||||
|
||||
@@ -59,6 +59,24 @@ export function sendJson(response, status, payload) {
|
||||
response.end(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a finished HTML document. Public pages carry a relaxed policy: they
|
||||
* embed no script of their own, and must stay readable to whoever fetches them.
|
||||
*/
|
||||
export function sendHtml(response, status, html) {
|
||||
const body = Buffer.from(html, 'utf8');
|
||||
response.writeHead(status, {
|
||||
...SECURITY_HEADERS,
|
||||
'Content-Security-Policy':
|
||||
"default-src 'self'; img-src 'self' data:; style-src 'self'; script-src 'none'; " +
|
||||
"frame-ancestors 'none'; base-uri 'none'; form-action 'self'",
|
||||
'Content-Type': 'text/html; charset=utf-8',
|
||||
'Content-Length': body.length,
|
||||
'Cache-Control': 'no-cache',
|
||||
});
|
||||
response.end(body);
|
||||
}
|
||||
|
||||
export function sendEmpty(response, status, headers = {}) {
|
||||
response.writeHead(status, { ...SECURITY_HEADERS, ...headers }).end();
|
||||
}
|
||||
|
||||
@@ -345,18 +345,7 @@ async function renderBoard(host, state, id) {
|
||||
h(
|
||||
'div',
|
||||
{ class: 'row' },
|
||||
board.repository &&
|
||||
button(
|
||||
'Importer les issues',
|
||||
async () => {
|
||||
const result = await api.post(`/api/projects/${board.id}/import`, {});
|
||||
toast(
|
||||
`${result.imported} carte(s) créée(s) dans « ${result.column} », ${result.skipped} déjà présente(s).`,
|
||||
);
|
||||
reload();
|
||||
},
|
||||
{ tone: 'ghost' },
|
||||
),
|
||||
button('Importer depuis Gitea', () => importIssues(board, reload), { tone: 'ghost' }),
|
||||
button('Colonne', () => addColumn(board, reload), { tone: 'ghost' }),
|
||||
level >= LEVELS.OWNER &&
|
||||
button(
|
||||
@@ -389,6 +378,73 @@ async function renderBoard(host, state, id) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pulls Gitea issues onto the board.
|
||||
*
|
||||
* Offered on every board, not only on a repository one: the organization board
|
||||
* is exactly where issues from several repositories belong together.
|
||||
*/
|
||||
async function importIssues(board, reload) {
|
||||
const { repositories } = await api.get('/api/repositories').catch(() => ({ repositories: [] }));
|
||||
|
||||
const repository =
|
||||
repositories.length > 0
|
||||
? select(
|
||||
repositories.map((entry) => ({ value: entry.fullName, label: entry.fullName })),
|
||||
{ value: board.repository ?? repositories[0]?.fullName },
|
||||
)
|
||||
: input({ value: board.repository ?? '', placeholder: 'FWS/FWS-Arch' });
|
||||
|
||||
const column = select(
|
||||
board.columns.map((entry) => ({ value: String(entry.id), label: entry.name })),
|
||||
{ value: String((board.columns.find((entry) => !entry.isDone) ?? board.columns[0])?.id) },
|
||||
);
|
||||
let closedToo = false;
|
||||
|
||||
const confirmed = await modal(
|
||||
'Importer depuis Gitea',
|
||||
() => ({
|
||||
node: h(
|
||||
'div',
|
||||
{ class: 'stack' },
|
||||
repositories.length === 0 &&
|
||||
notice(
|
||||
'La liste des dépôts est indisponible — saisis le dépôt à la main, au format `organisation/depot`.',
|
||||
'warning',
|
||||
),
|
||||
field('Dépôt', repository),
|
||||
field('Colonne d’arrivée', column),
|
||||
toggle(false, (checked) => (closedToo = checked), 'Inclure aussi les issues fermées'),
|
||||
h('p', {
|
||||
class: 'muted',
|
||||
text: 'Une issue déjà présente sur le tableau est ignorée : tu peux relancer l’import sans créer de doublon.',
|
||||
}),
|
||||
),
|
||||
submit: () => repository.value.trim() !== '',
|
||||
}),
|
||||
{ confirmLabel: 'Importer', tone: 'primary' },
|
||||
);
|
||||
if (!confirmed) return;
|
||||
|
||||
try {
|
||||
const result = await api.post(`/api/projects/${board.id}/import`, {
|
||||
repository: repository.value.trim(),
|
||||
columnId: Number(column.value),
|
||||
state: closedToo ? 'all' : 'open',
|
||||
});
|
||||
|
||||
toast(
|
||||
result.imported === 0
|
||||
? `Rien à importer : les ${result.found} issue(s) de ${result.repository} sont déjà sur le tableau.`
|
||||
: `${result.imported} carte(s) créée(s) dans « ${result.column} », ${result.skipped} déjà présente(s).`,
|
||||
result.imported === 0 ? 'info' : 'success',
|
||||
);
|
||||
reload();
|
||||
} catch (error) {
|
||||
toast(error.message, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function addColumn(board, reload) {
|
||||
const name = input({ placeholder: 'Nom de la colonne' });
|
||||
const wipLimit = input({ type: 'number', value: 0, min: 0 });
|
||||
|
||||
@@ -167,7 +167,8 @@ export function render(host, { state }) {
|
||||
'div',
|
||||
{},
|
||||
h('strong', { text: page.title }),
|
||||
h('div', { class: 'muted', text: page.summary || `/wiki/${page.slug}` }),
|
||||
h('div', { class: 'muted', text: page.summary || page.path }),
|
||||
h('div', { class: 'muted', style: { fontFamily: 'var(--mono)' }, text: page.path }),
|
||||
),
|
||||
},
|
||||
{ label: 'Catégorie', render: (page) => badge(page.category, 'info') },
|
||||
@@ -196,7 +197,7 @@ export function render(host, { state }) {
|
||||
page.published &&
|
||||
h('a', {
|
||||
class: 'btn btn-ghost btn-sm',
|
||||
href: `/wiki/${page.slug}`,
|
||||
href: page.path,
|
||||
target: '_blank',
|
||||
rel: 'noreferrer',
|
||||
text: 'Voir',
|
||||
|
||||
@@ -144,6 +144,37 @@
|
||||
margin-bottom: 1.2rem;
|
||||
}
|
||||
|
||||
.wiki-search {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.wiki-index {
|
||||
list-style: none;
|
||||
margin: 0 0 1.4rem;
|
||||
padding: 0;
|
||||
}
|
||||
.wiki-index li {
|
||||
padding: 0.35rem 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.wiki-index li:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.wiki-footer {
|
||||
margin-top: 3rem;
|
||||
padding-top: 1rem;
|
||||
border-top: 1px solid var(--border);
|
||||
font-size: 0.8rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
.wiki-footer a {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
.wiki-footer a:hover {
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.wiki-toc {
|
||||
position: sticky;
|
||||
top: 2rem;
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="fr" data-theme="dark">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="color-scheme" content="dark light" />
|
||||
<meta name="description" content="Documentation publique de l'organisation open source FWS." />
|
||||
<title>Documentation FWS</title>
|
||||
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
|
||||
<link rel="stylesheet" href="/styles.css" />
|
||||
<link rel="stylesheet" href="/wiki.css" />
|
||||
</head>
|
||||
<body class="wiki-body">
|
||||
<div id="wiki">
|
||||
<noscript>Cette documentation nécessite JavaScript.</noscript>
|
||||
</div>
|
||||
<script type="module" src="/wiki.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,183 +0,0 @@
|
||||
import { h, mount, qs } from './core/dom.js';
|
||||
import { render as renderMarkdown } from './core/markdown.js';
|
||||
|
||||
/**
|
||||
* Public documentation site (M17).
|
||||
*
|
||||
* Standalone on purpose: no session, no dashboard shell, and its own small
|
||||
* bundle — a visitor reading the privacy notice should never meet a login page.
|
||||
*/
|
||||
|
||||
const state = { tree: null, slug: null, theme: localStorage.getItem('fws.theme') ?? 'dark' };
|
||||
|
||||
const api = async (path) => {
|
||||
const response = await fetch(path, { headers: { Accept: 'application/json' } });
|
||||
if (!response.ok) throw new Error((await response.json().catch(() => null))?.error ?? 'Page introuvable.');
|
||||
return response.json();
|
||||
};
|
||||
|
||||
const currentSlug = () => {
|
||||
const path = window.location.pathname.replace(/^\/wiki\/?/, '').replace(/\/$/, '');
|
||||
return decodeURIComponent(path) || null;
|
||||
};
|
||||
|
||||
function navigate(slug, { replace = false } = {}) {
|
||||
const url = slug ? `/wiki/${encodeURIComponent(slug)}` : '/wiki';
|
||||
if (replace) window.history.replaceState({}, '', url);
|
||||
else window.history.pushState({}, '', url);
|
||||
draw();
|
||||
}
|
||||
|
||||
function sidebar() {
|
||||
const search = h('input', {
|
||||
class: 'input',
|
||||
type: 'search',
|
||||
placeholder: 'Rechercher…',
|
||||
'aria-label': 'Rechercher dans la documentation',
|
||||
});
|
||||
const results = h('div', { class: 'wiki-results' });
|
||||
|
||||
let timer = null;
|
||||
search.addEventListener('input', () => {
|
||||
clearTimeout(timer);
|
||||
const term = search.value.trim();
|
||||
if (term.length < 2) {
|
||||
mount(results);
|
||||
return;
|
||||
}
|
||||
timer = setTimeout(async () => {
|
||||
const { results: found } = await api(`/api/wiki/search?q=${encodeURIComponent(term)}`).catch(() => ({
|
||||
results: [],
|
||||
}));
|
||||
mount(
|
||||
results,
|
||||
found.length === 0
|
||||
? h('p', { class: 'muted', text: 'Aucun résultat.' })
|
||||
: found.map((page) =>
|
||||
h('a', {
|
||||
href: `/wiki/${page.slug}`,
|
||||
text: page.title,
|
||||
onClick: (event) => {
|
||||
event.preventDefault();
|
||||
search.value = '';
|
||||
mount(results);
|
||||
navigate(page.slug);
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
}, 250);
|
||||
});
|
||||
|
||||
return h(
|
||||
'aside',
|
||||
{ class: 'wiki-side' },
|
||||
h(
|
||||
'a',
|
||||
{ class: 'wiki-brand', href: '/wiki' },
|
||||
h('img', { src: '/favicon.svg', alt: '', width: 36, height: 36 }),
|
||||
h('div', {}, h('strong', { text: 'FWS' }), h('span', { text: 'Documentation' })),
|
||||
),
|
||||
search,
|
||||
results,
|
||||
h(
|
||||
'nav',
|
||||
{ class: 'wiki-nav' },
|
||||
(state.tree?.categories ?? []).map((category) =>
|
||||
h(
|
||||
'div',
|
||||
{},
|
||||
h('div', { class: 'nav-group', text: category.name }),
|
||||
category.pages.map((page) =>
|
||||
h('a', {
|
||||
href: `/wiki/${page.slug}`,
|
||||
text: page.title,
|
||||
class: page.slug === state.slug ? 'active' : '',
|
||||
onClick: (event) => {
|
||||
event.preventDefault();
|
||||
navigate(page.slug);
|
||||
},
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function tableOfContents(headings) {
|
||||
if (headings.length < 2) return null;
|
||||
return h(
|
||||
'nav',
|
||||
{ class: 'wiki-toc' },
|
||||
h('div', { class: 'nav-group', text: 'Sur cette page' }),
|
||||
headings.map((heading) =>
|
||||
h('a', { href: `#${heading.id}`, text: heading.text, dataset: { level: String(heading.level) } }),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
async function article(host) {
|
||||
const slug = state.slug ?? state.tree?.categories?.[0]?.pages?.[0]?.slug ?? null;
|
||||
if (!slug) {
|
||||
mount(host, h('p', { class: 'empty', text: 'Aucune page publiée pour l’instant.' }));
|
||||
return;
|
||||
}
|
||||
|
||||
let page;
|
||||
try {
|
||||
page = await api(`/api/wiki/pages/${encodeURIComponent(slug)}`);
|
||||
} catch (error) {
|
||||
mount(host, h('div', { class: 'notice notice-error' }, h('p', { text: error.message })));
|
||||
return;
|
||||
}
|
||||
|
||||
document.title = `${page.title} · Documentation FWS`;
|
||||
const { html, headings } = renderMarkdown(page.content);
|
||||
|
||||
const body = h('div', { class: 'wiki-content' });
|
||||
body.innerHTML = html;
|
||||
|
||||
mount(
|
||||
host,
|
||||
h(
|
||||
'div',
|
||||
{ class: 'wiki-article' },
|
||||
h(
|
||||
'article',
|
||||
{},
|
||||
h('p', { class: 'muted', text: page.category }),
|
||||
h('h1', { text: page.title }),
|
||||
page.summary && h('p', { class: 'wiki-summary', text: page.summary }),
|
||||
body,
|
||||
h('footer', {
|
||||
class: 'muted wiki-updated',
|
||||
text: `Dernière modification : ${new Date(`${page.updatedAt}Z`).toLocaleDateString('fr-FR', {
|
||||
dateStyle: 'long',
|
||||
})}`,
|
||||
}),
|
||||
),
|
||||
tableOfContents(headings),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
async function draw() {
|
||||
state.slug = currentSlug();
|
||||
const root = qs('#wiki');
|
||||
|
||||
if (!state.tree) {
|
||||
state.tree = await api('/api/wiki').catch(() => ({ categories: [], site: {} }));
|
||||
}
|
||||
|
||||
const main = h('main', { class: 'wiki-main' });
|
||||
mount(root, h('div', { class: 'wiki-shell' }, sidebar(), main));
|
||||
await article(main);
|
||||
|
||||
// In-page anchors only work once the article is on screen.
|
||||
if (window.location.hash) qs(window.location.hash)?.scrollIntoView({ block: 'start' });
|
||||
}
|
||||
|
||||
document.documentElement.dataset.theme = state.theme;
|
||||
window.addEventListener('popstate', draw);
|
||||
draw();
|
||||
+74
-6
@@ -9,13 +9,71 @@ import { registerApiRoutes } from './api/index.js';
|
||||
import { authenticate, assertSameOrigin } from './auth/session.js';
|
||||
import { authorize } from './auth/guard.js';
|
||||
import { broadcast, closeEventStreams, topicForPath } from './events.js';
|
||||
import { HttpError, readJsonBody, readRawBody, sendEmpty, sendJson, sendStatic } from './http.js';
|
||||
import { HttpError, readJsonBody, readRawBody, sendEmpty, sendHtml, sendJson, sendStatic } from './http.js';
|
||||
import { createRouter } from './router.js';
|
||||
import { seedWiki } from './services/wiki-seed.js';
|
||||
import { listPublished } from '../database/repositories/wiki-repository.js';
|
||||
import { pagePath } from './services/wiki-seed.js';
|
||||
import { renderIndex, renderNotFound, renderPage } from './services/wiki-render.js';
|
||||
import { ROOT_PAGES, seedWiki } from './services/wiki-seed.js';
|
||||
|
||||
/** HTTP server of the dashboard (M16-T01). */
|
||||
|
||||
const log = createLogger('web');
|
||||
|
||||
/**
|
||||
* The wiki address a path stands for: `''` for the index, a slug for a page,
|
||||
* `null` when the path is not the wiki's business.
|
||||
*/
|
||||
function wikiSlug(pathname) {
|
||||
const clean = pathname.replace(/\/+$/, '');
|
||||
if (clean === '/wiki' || clean === '') return clean === '/wiki' ? '' : null;
|
||||
if (clean.startsWith('/wiki/')) return decodeURIComponent(clean.slice('/wiki/'.length));
|
||||
|
||||
const root = clean.replace(/^\//, '');
|
||||
return ROOT_PAGES.includes(root) ? root : null;
|
||||
}
|
||||
|
||||
/** Answers with the finished HTML of a wiki page, or its index. */
|
||||
function sendWiki(response, slug, term) {
|
||||
let pages = [];
|
||||
try {
|
||||
pages = listPublished();
|
||||
} catch (error) {
|
||||
log.warn('Could not read the wiki pages', error);
|
||||
}
|
||||
|
||||
const categories = [];
|
||||
for (const page of pages) {
|
||||
const entry = { ...page, path: pagePath(page.slug) };
|
||||
let category = categories.find((item) => item.name === page.category);
|
||||
if (!category) categories.push((category = { name: page.category, pages: [] }));
|
||||
category.pages.push(entry);
|
||||
}
|
||||
const all = categories.flatMap((category) => category.pages);
|
||||
|
||||
if (slug === '') {
|
||||
const needle = term.trim().toLowerCase();
|
||||
const results =
|
||||
needle.length >= 2
|
||||
? all.filter((page) =>
|
||||
[page.title, page.summary, page.content].some((field) =>
|
||||
String(field ?? '')
|
||||
.toLowerCase()
|
||||
.includes(needle),
|
||||
),
|
||||
)
|
||||
: null;
|
||||
sendHtml(response, 200, renderIndex(categories, { term, results }));
|
||||
return;
|
||||
}
|
||||
|
||||
const page = all.find((entry) => entry.slug === slug);
|
||||
if (!page) {
|
||||
sendHtml(response, 404, renderNotFound(categories));
|
||||
return;
|
||||
}
|
||||
sendHtml(response, 200, renderPage(page, categories));
|
||||
}
|
||||
const publicDir = path.join(path.dirname(fileURLToPath(import.meta.url)), 'public');
|
||||
|
||||
/** Sliding window per client address, reset every minute. */
|
||||
@@ -72,10 +130,20 @@ export function createHandler({ client = null, setupOnly = false, startedAt = Da
|
||||
|
||||
const isApi = pathname.startsWith('/api/') || pathname.startsWith('/auth/');
|
||||
if (!isApi) {
|
||||
// The wiki is a separate public page: it must never fall back to the
|
||||
// dashboard shell, which would send a visitor to a login screen.
|
||||
const fallback = pathname === '/wiki' || pathname.startsWith('/wiki/') ? 'wiki.html' : 'index.html';
|
||||
const served = await sendStatic(response, publicDir, pathname, { fallback, request });
|
||||
// The wiki is rendered here rather than in the browser: a terms page
|
||||
// that needs scripts to show its text reads as blank to anything that
|
||||
// does not run them, which includes whoever checks the link before
|
||||
// approving an application.
|
||||
const slug = wikiSlug(pathname);
|
||||
if (slug !== null) {
|
||||
sendWiki(response, slug, url.searchParams.get('q') ?? '');
|
||||
return;
|
||||
}
|
||||
|
||||
const served = await sendStatic(response, publicDir, pathname, {
|
||||
fallback: 'index.html',
|
||||
request,
|
||||
});
|
||||
if (!served) sendEmpty(response, 404);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
import { env } from '../../config/env.js';
|
||||
import { render as renderMarkdown } from '../public/core/markdown.js';
|
||||
import { pagePath } from './wiki-seed.js';
|
||||
|
||||
/**
|
||||
* Server-rendered wiki (M17).
|
||||
*
|
||||
* The public documentation is delivered as finished HTML rather than assembled
|
||||
* in the browser. A terms page that needs JavaScript to show its text is a page
|
||||
* that reads as blank to anything that does not run scripts — a platform
|
||||
* checking the link before approving an application, a crawler, a reader with
|
||||
* scripts disabled — and those are exactly the readers it exists for.
|
||||
*/
|
||||
|
||||
const escape = (text) =>
|
||||
String(text ?? '')
|
||||
.replaceAll('&', '&')
|
||||
.replaceAll('<', '<')
|
||||
.replaceAll('>', '>')
|
||||
.replaceAll('"', '"');
|
||||
|
||||
const document = ({ title, description, body, noindex = false }) => `<!doctype html>
|
||||
<html lang="fr" data-theme="dark">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="color-scheme" content="dark light" />
|
||||
<meta name="description" content="${escape(description)}" />
|
||||
<meta name="robots" content="${noindex ? 'noindex, nofollow' : 'index, follow'}" />
|
||||
<title>${escape(title)}</title>
|
||||
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
|
||||
<link rel="stylesheet" href="/styles.css" />
|
||||
<link rel="stylesheet" href="/wiki.css" />
|
||||
</head>
|
||||
<body class="wiki-body">
|
||||
${body}
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
|
||||
/** Sidebar: the page tree and a search box that works without scripts. */
|
||||
function sidebar(categories, currentSlug, term = '') {
|
||||
const groups = categories
|
||||
.map(
|
||||
(category) => `
|
||||
<div class="nav-group">${escape(category.name)}</div>
|
||||
${category.pages
|
||||
.map(
|
||||
(page) =>
|
||||
`<a href="${escape(page.path ?? pagePath(page.slug))}"${
|
||||
page.slug === currentSlug ? ' class="active" aria-current="page"' : ''
|
||||
}>${escape(page.title)}</a>`,
|
||||
)
|
||||
.join('\n ')}`,
|
||||
)
|
||||
.join('\n');
|
||||
|
||||
return ` <aside class="wiki-side">
|
||||
<a class="wiki-brand" href="/wiki">
|
||||
<img src="/favicon.svg" alt="" width="36" height="36" />
|
||||
<div><strong>FWS</strong><span>Documentation</span></div>
|
||||
</a>
|
||||
<form class="wiki-search" method="get" action="/wiki">
|
||||
<input class="input" type="search" name="q" value="${escape(term)}" placeholder="Rechercher…" aria-label="Rechercher dans la documentation" />
|
||||
</form>
|
||||
<nav class="wiki-nav">
|
||||
${groups}
|
||||
</nav>
|
||||
</aside>`;
|
||||
}
|
||||
|
||||
/** Table of contents, built from the headings the renderer collected. */
|
||||
const contents = (headings) =>
|
||||
headings.length < 2
|
||||
? ''
|
||||
: ` <nav class="wiki-toc">
|
||||
<div class="nav-group">Sur cette page</div>
|
||||
${headings
|
||||
.map(
|
||||
(heading) =>
|
||||
`<a href="#${escape(heading.id)}" data-level="${heading.level}">${escape(heading.text)}</a>`,
|
||||
)
|
||||
.join('\n ')}
|
||||
</nav>`;
|
||||
|
||||
const footerLinks = () => {
|
||||
const links = [
|
||||
env.links.website && `<a href="${escape(env.links.website)}">Site</a>`,
|
||||
env.links.docs && `<a href="${escape(env.links.docs)}">Documentation</a>`,
|
||||
`<a href="/terms-of-service">Conditions d'utilisation</a>`,
|
||||
`<a href="/privacy-policy">Politique de confidentialité</a>`,
|
||||
].filter(Boolean);
|
||||
return `<footer class="wiki-footer">${links.join(' · ')}</footer>`;
|
||||
};
|
||||
|
||||
const shell = (categories, currentSlug, main, term) => ` <div class="wiki-shell">
|
||||
${sidebar(categories, currentSlug, term)}
|
||||
<main class="wiki-main">
|
||||
${main}
|
||||
${footerLinks()}
|
||||
</main>
|
||||
</div>`;
|
||||
|
||||
/** A page, with its body already turned into HTML. */
|
||||
export function renderPage(page, categories) {
|
||||
const { html, headings } = renderMarkdown(page.content);
|
||||
const updated = new Date(`${page.updated_at}Z`);
|
||||
|
||||
const main = ` <div class="wiki-article">
|
||||
<article>
|
||||
<p class="muted">${escape(page.category)}</p>
|
||||
<h1>${escape(page.title)}</h1>
|
||||
${page.summary ? `<p class="wiki-summary">${escape(page.summary)}</p>` : ''}
|
||||
<div class="wiki-content">
|
||||
${html}
|
||||
</div>
|
||||
<footer class="muted wiki-updated">
|
||||
Dernière modification :
|
||||
<time datetime="${escape(updated.toISOString())}">${updated.toLocaleDateString('fr-FR', {
|
||||
dateStyle: 'long',
|
||||
})}</time>
|
||||
</footer>
|
||||
</article>
|
||||
${contents(headings)}
|
||||
</div>`;
|
||||
|
||||
return document({
|
||||
title: `${page.title} · Documentation FWS`,
|
||||
description: page.summary || `${page.title} — documentation de l'organisation FWS.`,
|
||||
body: shell(categories, page.slug, main),
|
||||
});
|
||||
}
|
||||
|
||||
/** Landing page, and the search results when a term is given. */
|
||||
export function renderIndex(categories, { term = '', results = null } = {}) {
|
||||
const list = (pages) =>
|
||||
pages.length === 0
|
||||
? '<p class="empty">Aucun résultat.</p>'
|
||||
: `<ul class="wiki-index">${pages
|
||||
.map(
|
||||
(page) =>
|
||||
`<li><a href="${escape(page.path ?? pagePath(page.slug))}">${escape(page.title)}</a>${
|
||||
page.summary ? ` — <span class="muted">${escape(page.summary)}</span>` : ''
|
||||
}</li>`,
|
||||
)
|
||||
.join('')}</ul>`;
|
||||
|
||||
const main = results
|
||||
? ` <article>
|
||||
<h1>Recherche</h1>
|
||||
<p class="muted">${results.length} résultat(s) pour « ${escape(term)} ».</p>
|
||||
${list(results)}
|
||||
</article>`
|
||||
: ` <article>
|
||||
<h1>Documentation FWS</h1>
|
||||
<p class="wiki-summary">Tout ce qu'il faut savoir sur le bot et l'organisation.</p>
|
||||
${categories
|
||||
.map((category) => `<h2>${escape(category.name)}</h2>${list(category.pages)}`)
|
||||
.join('\n ')}
|
||||
</article>`;
|
||||
|
||||
return document({
|
||||
title: 'Documentation FWS',
|
||||
description: "Documentation publique de l'organisation open source FWS.",
|
||||
body: shell(categories, null, main, term),
|
||||
});
|
||||
}
|
||||
|
||||
export function renderNotFound(categories) {
|
||||
const main = ` <article>
|
||||
<h1>Page introuvable</h1>
|
||||
<p class="muted">Cette page n'existe pas, ou n'est pas encore publiée.</p>
|
||||
<p><a href="/wiki">Revenir à la documentation</a></p>
|
||||
</article>`;
|
||||
|
||||
return document({
|
||||
title: 'Page introuvable · Documentation FWS',
|
||||
description: 'Page introuvable.',
|
||||
body: shell(categories, null, main),
|
||||
noindex: true,
|
||||
});
|
||||
}
|
||||
@@ -15,6 +15,17 @@ import { countPages, createPage, getPageBySlug } from '../../database/repositori
|
||||
|
||||
const log = createLogger('wiki');
|
||||
|
||||
/**
|
||||
* Pages served at the root rather than under `/wiki/`.
|
||||
*
|
||||
* Discord, and most platforms, ask for a terms URL and a privacy URL; pasting
|
||||
* `/wiki/...` in those fields reads like an afterthought.
|
||||
*/
|
||||
export const ROOT_PAGES = Object.freeze(['terms-of-service', 'privacy-policy']);
|
||||
|
||||
/** Public address of a page, root pages included. */
|
||||
export const pagePath = (slug) => (ROOT_PAGES.includes(slug) ? `/${slug}` : `/wiki/${slug}`);
|
||||
|
||||
const TERMS = `## 1. Objet
|
||||
|
||||
Ces conditions régissent l'utilisation du bot Discord **FWS-Bot** et de son tableau de bord, exploités par **[NOM DE L'ENTITÉ RESPONSABLE]** (ci-après « nous »).
|
||||
@@ -185,8 +196,8 @@ Ces pages sont rédigées et publiées depuis le tableau de bord du bot : elles
|
||||
|
||||
## Pour commencer
|
||||
|
||||
- **Conditions d'utilisation** — ce à quoi tu t'engages en utilisant le bot.
|
||||
- **Politique de confidentialité** — quelles données sont traitées, pourquoi, et tes droits.
|
||||
- [**Conditions d'utilisation**](/terms-of-service) — ce à quoi tu t'engages en utilisant le bot.
|
||||
- [**Politique de confidentialité**](/privacy-policy) — quelles données sont traitées, pourquoi, et tes droits.
|
||||
|
||||
## Contribuer
|
||||
|
||||
@@ -206,7 +217,7 @@ const DEFAULT_PAGES = [
|
||||
isProtected: false,
|
||||
},
|
||||
{
|
||||
slug: 'conditions-utilisation',
|
||||
slug: 'terms-of-service',
|
||||
title: 'Conditions d’utilisation',
|
||||
summary: 'Ce à quoi tu t’engages en utilisant le bot FWS.',
|
||||
category: 'Légal',
|
||||
@@ -216,7 +227,7 @@ const DEFAULT_PAGES = [
|
||||
isProtected: true,
|
||||
},
|
||||
{
|
||||
slug: 'politique-confidentialite',
|
||||
slug: 'privacy-policy',
|
||||
title: 'Politique de confidentialité',
|
||||
summary: 'Données traitées, durées de conservation et droits, selon la LPD suisse.',
|
||||
category: 'Légal',
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { createServer } from 'node:http';
|
||||
import { after, before, beforeEach, describe, it } from 'node:test';
|
||||
|
||||
/**
|
||||
* Importing Gitea issues onto a board (M18).
|
||||
*
|
||||
* A stand-in forge answers on a real socket, and the environment is set before
|
||||
* the modules that read it are loaded — hence the dynamic imports.
|
||||
*/
|
||||
|
||||
let issues = [];
|
||||
|
||||
const forge = createServer((request, response) => {
|
||||
if (!request.url.includes('/issues')) {
|
||||
response.writeHead(404).end();
|
||||
return;
|
||||
}
|
||||
const state = new URL(request.url, 'http://x').searchParams.get('state');
|
||||
const body = state === 'all' ? issues : issues.filter((issue) => issue.state === 'open');
|
||||
|
||||
response.writeHead(200, { 'Content-Type': 'application/json' }).end(JSON.stringify(body));
|
||||
});
|
||||
await new Promise((resolve) => forge.listen(0, '127.0.0.1', resolve));
|
||||
|
||||
process.env.GITEA_URL = `http://127.0.0.1:${forge.address().port}`;
|
||||
process.env.GITEA_TOKEN = 'jeton-de-test';
|
||||
process.env.GITEA_OWNER = 'FWS';
|
||||
|
||||
const { closeDatabase, getDatabase, initDatabase } = await import('../src/database/index.js');
|
||||
const { createBoard, listCards, listColumns } = await import(
|
||||
'../src/database/repositories/project-repository.js'
|
||||
);
|
||||
const { createApiToken } = await import('../src/database/repositories/web-session-repository.js');
|
||||
const { hashToken } = await import('../src/web/auth/session.js');
|
||||
const { createHandler } = await import('../src/web/server.js');
|
||||
|
||||
const TOKEN = 'fws_import-test';
|
||||
|
||||
describe('importing issues from Gitea', () => {
|
||||
let app;
|
||||
let board;
|
||||
let columns;
|
||||
|
||||
before(async () => {
|
||||
initDatabase(':memory:');
|
||||
createApiToken({ name: 'import', tokenHash: hashToken(TOKEN), prefix: 'fws_impo', accessLevel: 3 });
|
||||
app = createServer(createHandler({ client: null }));
|
||||
await new Promise((resolve) => app.listen(0, '127.0.0.1', resolve));
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await new Promise((resolve) => app.close(resolve));
|
||||
await new Promise((resolve) => forge.close(resolve));
|
||||
closeDatabase();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
getDatabase().exec('DELETE FROM project_boards;');
|
||||
board = createBoard({ guildId: '', scope: 'org', name: 'Organisation' });
|
||||
columns = listColumns(board.id);
|
||||
|
||||
issues = [
|
||||
{ number: 1, title: 'Corriger le démarrage', state: 'open', body: 'Détails', labels: [{ name: 'bug' }] },
|
||||
{ number: 2, title: 'Documenter le wiki', state: 'open', body: null, labels: [] },
|
||||
{ number: 3, title: 'Ancienne demande', state: 'closed', body: null, labels: [] },
|
||||
];
|
||||
});
|
||||
|
||||
const call = (path, body) =>
|
||||
fetch(`http://127.0.0.1:${app.address().port}${path}`, {
|
||||
method: 'POST',
|
||||
headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
const importInto = (body = {}) =>
|
||||
call(`/api/projects/${board.id}/import`, { repository: 'FWS/FWS-Arch', ...body }).then((response) =>
|
||||
response.json(),
|
||||
);
|
||||
|
||||
it('creates one card per open issue', async () => {
|
||||
const result = await importInto();
|
||||
|
||||
assert.equal(result.imported, 2);
|
||||
assert.equal(result.column, 'À faire');
|
||||
assert.deepEqual(
|
||||
listCards(board.id)
|
||||
.map((card) => card.title)
|
||||
.sort(),
|
||||
['Corriger le démarrage', 'Documenter le wiki'],
|
||||
);
|
||||
});
|
||||
|
||||
it('records the issue each card came from', async () => {
|
||||
await importInto();
|
||||
const card = listCards(board.id).find((entry) => entry.title === 'Corriger le démarrage');
|
||||
|
||||
assert.equal(card.issue_ref, 'FWS/FWS-Arch#1');
|
||||
assert.deepEqual(card.labels, ['bug']);
|
||||
assert.match(card.body, /Détails/);
|
||||
});
|
||||
|
||||
/** The button has to survive being pressed twice. */
|
||||
it('skips what is already on the board', async () => {
|
||||
await importInto();
|
||||
const second = await importInto();
|
||||
|
||||
assert.equal(second.imported, 0);
|
||||
assert.equal(second.skipped, 2);
|
||||
assert.equal(listCards(board.id).length, 2);
|
||||
});
|
||||
|
||||
it('brings the closed issues in when asked', async () => {
|
||||
const result = await importInto({ state: 'all' });
|
||||
assert.equal(result.imported, 3);
|
||||
});
|
||||
|
||||
it('imports into the chosen column', async () => {
|
||||
const review = columns.find((column) => column.name === 'En revue');
|
||||
const result = await importInto({ columnId: review.id });
|
||||
|
||||
assert.equal(result.column, 'En revue');
|
||||
assert.ok(listCards(board.id).every((card) => card.column_id === review.id));
|
||||
});
|
||||
|
||||
/** Importing straight into « Terminé » is never what anyone means. */
|
||||
it('never imports into a column of another board', async () => {
|
||||
const other = createBoard({ guildId: '', scope: 'repo', repository: 'FWS/site', name: 'Site' });
|
||||
const foreign = listColumns(other.id)[0];
|
||||
|
||||
const result = await importInto({ columnId: foreign.id });
|
||||
assert.equal(result.column, 'À faire');
|
||||
assert.equal(listCards(other.id).length, 0);
|
||||
});
|
||||
|
||||
it('reports what it found even when nothing is new', async () => {
|
||||
issues = [];
|
||||
const result = await importInto();
|
||||
|
||||
assert.equal(result.found, 0);
|
||||
assert.equal(result.imported, 0);
|
||||
assert.equal(result.repository, 'FWS/FWS-Arch');
|
||||
});
|
||||
});
|
||||
@@ -325,6 +325,23 @@ describe('projects over HTTP', () => {
|
||||
assert.equal(response.status, 400);
|
||||
});
|
||||
|
||||
it('refuses to import when Gitea is not configured', async () => {
|
||||
const created = await (await call('POST', '/api/projects', { scope: 'org', name: 'Org' })).json();
|
||||
const response = await call('POST', `/api/projects/${created.id}/import`, {
|
||||
repository: 'FWS/FWS-Arch',
|
||||
});
|
||||
|
||||
// `GITEA_TOKEN` is unset in the tests, so the import cannot run.
|
||||
assert.equal(response.status, 400);
|
||||
assert.match((await response.json()).error, /Gitea/);
|
||||
});
|
||||
|
||||
it('refuses a repository that is not owner/name', async () => {
|
||||
const created = await (await call('POST', '/api/projects', { scope: 'org', name: 'Org' })).json();
|
||||
const response = await call('POST', `/api/projects/${created.id}/import`, { repository: 'nope' });
|
||||
assert.equal(response.status, 400);
|
||||
});
|
||||
|
||||
it('asks for the name before deleting a board', async () => {
|
||||
const created = await (await call('POST', '/api/projects', { scope: 'org', name: 'Org' })).json();
|
||||
|
||||
|
||||
+75
-12
@@ -127,19 +127,19 @@ describe('wiki seeding', () => {
|
||||
|
||||
it('creates the welcome page and both legal pages', () => {
|
||||
assert.equal(seedWiki(), 3);
|
||||
assert.ok(getPageBySlug('conditions-utilisation').published);
|
||||
assert.ok(getPageBySlug('politique-confidentialite').published);
|
||||
assert.ok(getPageBySlug('terms-of-service').published);
|
||||
assert.ok(getPageBySlug('privacy-policy').published);
|
||||
});
|
||||
|
||||
it('marks the legal pages as protected', () => {
|
||||
seedWiki();
|
||||
assert.equal(getPageBySlug('politique-confidentialite').protected, true);
|
||||
assert.equal(getPageBySlug('privacy-policy').protected, true);
|
||||
assert.equal(getPageBySlug('accueil').protected, false);
|
||||
});
|
||||
|
||||
it('names the Swiss law it is written against', () => {
|
||||
seedWiki();
|
||||
const privacy = getPageBySlug('politique-confidentialite').content;
|
||||
const privacy = getPageBySlug('privacy-policy').content;
|
||||
assert.match(privacy, /LPD/);
|
||||
assert.match(privacy, /PFPDT/);
|
||||
assert.match(privacy, /art\. 25 LPD/);
|
||||
@@ -147,18 +147,18 @@ describe('wiki seeding', () => {
|
||||
|
||||
it('never overwrites what the organisation has written', () => {
|
||||
seedWiki();
|
||||
updatePage(getPageBySlug('conditions-utilisation').id, { content: 'Notre propre texte.' });
|
||||
updatePage(getPageBySlug('terms-of-service').id, { content: 'Notre propre texte.' });
|
||||
|
||||
assert.equal(seedWiki(), 0);
|
||||
assert.equal(getPageBySlug('conditions-utilisation').content, 'Notre propre texte.');
|
||||
assert.equal(getPageBySlug('terms-of-service').content, 'Notre propre texte.');
|
||||
});
|
||||
|
||||
it('brings a deleted legal page back, but not the welcome one', () => {
|
||||
seedWiki();
|
||||
getDatabase().exec("DELETE FROM wiki_pages WHERE slug IN ('politique-confidentialite', 'accueil')");
|
||||
getDatabase().exec("DELETE FROM wiki_pages WHERE slug IN ('privacy-policy', 'accueil')");
|
||||
|
||||
assert.equal(seedWiki(), 1);
|
||||
assert.ok(getPageBySlug('politique-confidentialite'));
|
||||
assert.ok(getPageBySlug('privacy-policy'));
|
||||
assert.equal(getPageBySlug('accueil'), null);
|
||||
});
|
||||
});
|
||||
@@ -188,7 +188,7 @@ describe('wiki over HTTP', () => {
|
||||
});
|
||||
|
||||
it('serves a published page without a session', async () => {
|
||||
const response = await get('/api/wiki/pages/conditions-utilisation');
|
||||
const response = await get('/api/wiki/pages/terms-of-service');
|
||||
assert.equal(response.status, 200);
|
||||
assert.match((await response.json()).content, /droit suisse/);
|
||||
});
|
||||
@@ -203,13 +203,76 @@ describe('wiki over HTTP', () => {
|
||||
assert.ok(Array.isArray(body.results));
|
||||
});
|
||||
|
||||
it('serves the legal pages at the root, where platforms expect them', async () => {
|
||||
for (const path of ['/terms-of-service', '/privacy-policy']) {
|
||||
const response = await get(path);
|
||||
assert.equal(response.status, 200, `${path} ne répond pas`);
|
||||
assert.match(response.headers.get('content-type'), /text\/html/);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* The point of the whole exercise: whoever checks these links before
|
||||
* approving an application does not run scripts.
|
||||
*/
|
||||
it('delivers the legal text without any script', async () => {
|
||||
const terms = await get('/terms-of-service').then((response) => response.text());
|
||||
const privacy = await get('/privacy-policy').then((response) => response.text());
|
||||
|
||||
assert.match(terms, /droit suisse/, 'les conditions ne sont pas dans le HTML');
|
||||
assert.match(privacy, /LPD/, 'la politique n’est pas dans le HTML');
|
||||
assert.match(privacy, /PFPDT/);
|
||||
assert.doesNotMatch(terms, /<script/i, 'la page embarque un script');
|
||||
assert.doesNotMatch(privacy, /<script/i, 'la page embarque un script');
|
||||
});
|
||||
|
||||
it('lets itself be indexed, unlike the dashboard', async () => {
|
||||
const terms = await get('/terms-of-service').then((response) => response.text());
|
||||
assert.match(terms, /name="robots" content="index, follow"/);
|
||||
});
|
||||
|
||||
it('links both legal pages from every page of the wiki', async () => {
|
||||
const index = await get('/wiki').then((response) => response.text());
|
||||
assert.match(index, /href="\/terms-of-service"/);
|
||||
assert.match(index, /href="\/privacy-policy"/);
|
||||
});
|
||||
|
||||
it('searches without scripts, through a plain query string', async () => {
|
||||
const results = await get('/wiki?q=confidentialit').then((response) => response.text());
|
||||
assert.match(results, /résultat\(s\)/);
|
||||
assert.match(results, /privacy-policy/);
|
||||
});
|
||||
|
||||
it('answers 404 on an unknown page rather than a blank shell', async () => {
|
||||
const response = await get('/wiki/inexistante');
|
||||
assert.equal(response.status, 404);
|
||||
assert.match(await response.text(), /introuvable/);
|
||||
});
|
||||
|
||||
it('tells each page where it lives', async () => {
|
||||
const body = await get('/api/wiki').then((response) => response.json());
|
||||
const pages = body.categories.flatMap((category) => category.pages);
|
||||
|
||||
assert.equal(pages.find((page) => page.slug === 'terms-of-service').path, '/terms-of-service');
|
||||
assert.equal(pages.find((page) => page.slug === 'privacy-policy').path, '/privacy-policy');
|
||||
assert.equal(pages.find((page) => page.slug === 'accueil').path, '/wiki/accueil');
|
||||
});
|
||||
|
||||
it('keeps an ordinary page under /wiki', async () => {
|
||||
createPage({ slug: 'guide', title: 'Guide', content: 'x', published: true });
|
||||
|
||||
// Not a legal page: `/guide` belongs to the dashboard, not to the wiki.
|
||||
assert.doesNotMatch(await get('/guide').then((r) => r.text()), /wiki-shell/);
|
||||
assert.match(await get('/wiki/guide').then((r) => r.text()), /wiki-shell/);
|
||||
});
|
||||
|
||||
it('keeps the administration behind the login', async () => {
|
||||
assert.equal((await get('/api/wiki/admin')).status, 401);
|
||||
});
|
||||
|
||||
it('serves its own page rather than the dashboard shell', async () => {
|
||||
const body = await get('/wiki/conditions-utilisation').then((response) => response.text());
|
||||
assert.match(body, /wiki\.js/);
|
||||
it('serves the documentation rather than the dashboard shell', async () => {
|
||||
const body = await get('/wiki/terms-of-service').then((response) => response.text());
|
||||
assert.match(body, /wiki-shell/);
|
||||
assert.doesNotMatch(body, /id="app"/);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user