feat(wiki): serve the legal pages at /terms-of-service and /privacy-policy
Discord, and most platforms, ask for a terms URL and a privacy URL in a form field; pasting a `/wiki/...` address there reads like an afterthought. Both pages now answer at the root, while everything else stays under `/wiki/`. The API states each page's address instead of leaving the front to rebuild it, so there is one place that decides. Existing pages are renamed rather than recreated, keeping whatever has already been written in them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
e1b9a5cc77
commit
3d0e21d7cb
7 files changed
+83
-26
No files matched your search
@@ -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';
|
||||
@@ -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,
|
||||
|
||||
@@ -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',
|
||||
|
||||
+11
-7
@@ -17,12 +17,16 @@ const api = async (path) => {
|
||||
};
|
||||
|
||||
const currentSlug = () => {
|
||||
const path = window.location.pathname.replace(/^\/wiki\/?/, '').replace(/\/$/, '');
|
||||
// A page answers either at `/wiki/<slug>` or, for the legal ones, at
|
||||
// `/<slug>`; the last segment is the slug in both cases.
|
||||
const path = window.location.pathname.replace(/^\/wiki\/?/, '').replace(/^\/|\/$/g, '');
|
||||
return decodeURIComponent(path) || null;
|
||||
};
|
||||
|
||||
function navigate(slug, { replace = false } = {}) {
|
||||
const url = slug ? `/wiki/${encodeURIComponent(slug)}` : '/wiki';
|
||||
const pathOf = (page) => page?.path ?? (page?.slug ? `/wiki/${encodeURIComponent(page.slug)}` : '/wiki');
|
||||
|
||||
function navigate(target, { replace = false } = {}) {
|
||||
const url = typeof target === 'string' ? target : pathOf(target);
|
||||
if (replace) window.history.replaceState({}, '', url);
|
||||
else window.history.pushState({}, '', url);
|
||||
draw();
|
||||
@@ -55,13 +59,13 @@ function sidebar() {
|
||||
? h('p', { class: 'muted', text: 'Aucun résultat.' })
|
||||
: found.map((page) =>
|
||||
h('a', {
|
||||
href: `/wiki/${page.slug}`,
|
||||
href: pathOf(page),
|
||||
text: page.title,
|
||||
onClick: (event) => {
|
||||
event.preventDefault();
|
||||
search.value = '';
|
||||
mount(results);
|
||||
navigate(page.slug);
|
||||
navigate(page);
|
||||
},
|
||||
}),
|
||||
),
|
||||
@@ -90,12 +94,12 @@ function sidebar() {
|
||||
h('div', { class: 'nav-group', text: category.name }),
|
||||
category.pages.map((page) =>
|
||||
h('a', {
|
||||
href: `/wiki/${page.slug}`,
|
||||
href: pathOf(page),
|
||||
text: page.title,
|
||||
class: page.slug === state.slug ? 'active' : '',
|
||||
onClick: (event) => {
|
||||
event.preventDefault();
|
||||
navigate(page.slug);
|
||||
navigate(page);
|
||||
},
|
||||
}),
|
||||
),
|
||||
|
||||
+8
-3
@@ -11,7 +11,7 @@ import { authorize } from './auth/guard.js';
|
||||
import { broadcast, closeEventStreams, topicForPath } from './events.js';
|
||||
import { HttpError, readJsonBody, readRawBody, sendEmpty, sendJson, sendStatic } from './http.js';
|
||||
import { createRouter } from './router.js';
|
||||
import { seedWiki } from './services/wiki-seed.js';
|
||||
import { ROOT_PAGES, seedWiki } from './services/wiki-seed.js';
|
||||
|
||||
/** HTTP server of the dashboard (M16-T01). */
|
||||
|
||||
@@ -73,8 +73,13 @@ 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';
|
||||
// dashboard shell, which would send a visitor to a login screen. The
|
||||
// legal pages answer at the root, where platforms expect them.
|
||||
const isWiki =
|
||||
pathname === '/wiki' ||
|
||||
pathname.startsWith('/wiki/') ||
|
||||
ROOT_PAGES.includes(pathname.replace(/^\/|\/$/g, ''));
|
||||
const fallback = isWiki ? 'wiki.html' : 'index.html';
|
||||
const served = await sendStatic(response, publicDir, pathname, { fallback, request });
|
||||
if (!served) sendEmpty(response, 404);
|
||||
return;
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in new issue
Block a user