Merge remote-tracking branch 'gitea/main' into feat/aep-socle-perf
This commit is contained in:
@@ -103,6 +103,8 @@ Contenus de détail en place : `/` → `FicheDetail` (`compact`, `etiquettes-cli
|
||||
|
||||
**Troisième page en place : `/outils?tab=partir-de-soi` (B6-M2)** — sept fiches, une par mot de la slide 17 (`components/OutilsPartirDeSoi.vue`, adaptateur `toMiniMot`). Trois extensions optionnelles du composant, sans effet sur `/` et `/agences` : tri `ordre` (ordre du tableau d'entrée) avec `config.triDefaut` (tri sans filtre ; la pertinence reste prioritaire dès qu'un filtre est actif) et `config.libellesTri` ; prop `libelles-vue` (`{ carte: 'Graphe' }` : le bouton, et « Voir dans le graphe » au lieu de « Voir sur la carte » ; l'URL garde `vue=carte`). Le slot `#carte` y est `GrapheMots.vue`, un SVG statique (nœud central, mots en couronne, ressources en feuilles) dans le vocabulaire du motif maillage. La page vit dans un onglet : `tab=` est un paramètre que la vue ne gère pas, donc recopié à chaque écriture.
|
||||
|
||||
**Quatrième page : `/connaissances` (B19, retouches B19b 29/10/2026)** — la couche de connaissances partagées (`data/connaissances/`, domaine pur dans `utils/connaissances/` : `valider`, `vocabulaire`, `lire`, `graphe` ; adaptateur `toMiniConnaissance`). Deux extensions optionnelles de plus, sans effet sur les autres pages : option `etatDefaut` en troisième argument de `useVueFiches(fiches, config, { etatDefaut: 'carte' })` (l'état rendu quand l'URL ne porte pas `vue=` ; l'URL prime toujours) ; prop `navigation-lineaire` de `VueFiches` (défaut `true` ; à `false`, Précédente / Suivante, le rang et la ligne d'aide des flèches disparaissent, les flèches clavier restent). Le slot `#carte` y est `GrapheConnaissances.vue` (SVG serveur, graine fixe, légende visible : rond = concept, carré = source, trait plein = énoncé par la source, pointillé = posé par AEP). La fiche se lit en trois étages : titre et en-tête de propriétés (`dl.cf__props`), texte (`cf__texte`), crédit et licence repliés (`details.cf__fond`).
|
||||
|
||||
**`FicheMiniCard`** : racine `<article>`, toute la carte ouvre la fiche par un bouton étiré (`::after`) ; avec `etiquettes-cliquables`, les chips deviennent des boutons (impossible dans l'ancienne racine `<button>`). Props `actif` (liseré safran au survol d'épingle), `etiquettes-actives`. Résumé et « Sans localisation » en `color-mix(--text 78 %)` : `--text-muted` et `--text-subtle` échouaient au contraste.
|
||||
|
||||
## Intention d'abord
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
Layout : force simple à graine fixe, calculé depuis nœuds et liens (aucune position en
|
||||
données), mis en cache par signature du graphe (une fois par processus serveur), puis
|
||||
projeté sur la taille mesurée. Liens : trait plein = énoncé par la source, tirets = posé
|
||||
par la curation.
|
||||
par la curation. La géométrie (disposer, cache, voisinage, boîte) vit dans
|
||||
`utils/connaissances/graphe.ts`, testée (B19b M4).
|
||||
-->
|
||||
<template>
|
||||
<div ref="racine" class="gc" :class="{ 'gc--fige': fige }">
|
||||
@@ -82,152 +83,19 @@
|
||||
@click="pas = o.v"
|
||||
>{{ o.libelle }}</button>
|
||||
</div>
|
||||
<p class="gc__legende" aria-hidden="true">
|
||||
<span class="gc__legende-trait gc__legende-trait--source" />source
|
||||
<span class="gc__legende-trait gc__legende-trait--curation" />curation
|
||||
</p>
|
||||
<!-- Légende visible (retour de Jules du 27/10, n° 6 : « pourquoi des carrés, pourquoi des ronds ») -->
|
||||
<ul class="gc__legende" aria-label="Légende du graphe">
|
||||
<li><span class="gc__legende-rond" aria-hidden="true" />Concept</li>
|
||||
<li><span class="gc__legende-carre" aria-hidden="true" />Source (texte, organisation, outil)</li>
|
||||
<li><span class="gc__legende-trait" aria-hidden="true" />Énoncé par la source</li>
|
||||
<li><span class="gc__legende-trait gc__legende-trait--curation" aria-hidden="true" />Posé par AEP</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
/** Un nœud : `kind` dit sa forme (principal si dans `kindsPrincipaux`, sinon secondaire). */
|
||||
export interface NoeudGraphe { id: string; libelle: string; kind: string; poids?: number }
|
||||
export interface LienGraphe { de: string; vers: string; type: string; provenance: string }
|
||||
export type Pas = 1 | 2 | 'tout'
|
||||
|
||||
type Pt = { x: number; y: number }
|
||||
|
||||
/** PRNG à graine fixe (mulberry32) : même graphe, même dessin, au serveur comme au navigateur. */
|
||||
function alea(graine: number) {
|
||||
let a = graine >>> 0
|
||||
return () => {
|
||||
a = (a + 0x6d2b79f5) >>> 0
|
||||
let t = a
|
||||
t = Math.imul(t ^ (t >>> 15), t | 1)
|
||||
t ^= t + Math.imul(t ^ (t >>> 7), t | 61)
|
||||
return ((t ^ (t >>> 14)) >>> 0) / 4294967296
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Force simple (Fruchterman-Reingold), graine fixe, nombre de pas fixe : positions dans un
|
||||
* repère sans unité, centré, d'étendue 1. Fonction pure de (nœuds, liens, principaux).
|
||||
*/
|
||||
export function disposer(noeuds: NoeudGraphe[], liens: LienGraphe[], principaux: Set<string>): Map<string, Pt> {
|
||||
const n = noeuds.length
|
||||
const pos = new Map<string, Pt>()
|
||||
if (!n) return pos
|
||||
const rnd = alea(0x9e3779b9)
|
||||
const index = new Map(noeuds.map((x, i) => [x.id, i]))
|
||||
const aretes = liens
|
||||
.map((l) => [index.get(l.de), index.get(l.vers)] as const)
|
||||
.filter((a): a is readonly [number, number] => a[0] != null && a[1] != null && a[0] !== a[1])
|
||||
const voisins: number[][] = noeuds.map(() => [])
|
||||
for (const [a, b] of aretes) { voisins[a].push(b); voisins[b].push(a) }
|
||||
|
||||
// Départ : les principaux en cercle, chaque secondaire au barycentre de ses voisins principaux.
|
||||
const prin = noeuds.map((x, i) => (principaux.has(x.kind) ? i : -1)).filter((i) => i >= 0)
|
||||
const X = new Float64Array(n)
|
||||
const Y = new Float64Array(n)
|
||||
prin.forEach((i, k) => {
|
||||
const t = (2 * Math.PI * k) / Math.max(prin.length, 1)
|
||||
X[i] = 0.4 * Math.cos(t)
|
||||
Y[i] = 0.4 * Math.sin(t)
|
||||
})
|
||||
noeuds.forEach((x, i) => {
|
||||
if (principaux.has(x.kind)) return
|
||||
const v = voisins[i].filter((j) => principaux.has(noeuds[j].kind))
|
||||
if (v.length) {
|
||||
X[i] = (v.reduce((s, j) => s + X[j], 0) / v.length) * 1.35 + (rnd() - 0.5) * 0.08
|
||||
Y[i] = (v.reduce((s, j) => s + Y[j], 0) / v.length) * 1.35 + (rnd() - 0.5) * 0.08
|
||||
} else {
|
||||
X[i] = (rnd() - 0.5) * 0.9
|
||||
Y[i] = (rnd() - 0.5) * 0.9
|
||||
}
|
||||
})
|
||||
|
||||
const k = 0.9 * Math.sqrt(1 / n)
|
||||
const ITER = 350
|
||||
const dx = new Float64Array(n)
|
||||
const dy = new Float64Array(n)
|
||||
for (let it = 0; it < ITER; it++) {
|
||||
const temp = 0.08 * (1 - it / ITER) + 0.002
|
||||
dx.fill(0)
|
||||
dy.fill(0)
|
||||
for (let i = 0; i < n; i++) {
|
||||
for (let j = i + 1; j < n; j++) {
|
||||
let ex = X[i] - X[j]
|
||||
let ey = Y[i] - Y[j]
|
||||
let d = Math.hypot(ex, ey)
|
||||
if (d < 1e-4) { ex = (rnd() - 0.5) * 1e-3; ey = (rnd() - 0.5) * 1e-3; d = Math.hypot(ex, ey) }
|
||||
const f = (k * k) / d
|
||||
dx[i] += (ex / d) * f; dy[i] += (ey / d) * f
|
||||
dx[j] -= (ex / d) * f; dy[j] -= (ey / d) * f
|
||||
}
|
||||
}
|
||||
for (const [a, b] of aretes) {
|
||||
const ex = X[a] - X[b]
|
||||
const ey = Y[a] - Y[b]
|
||||
const d = Math.max(Math.hypot(ex, ey), 1e-4)
|
||||
const f = (d * d) / k
|
||||
dx[a] -= (ex / d) * f; dy[a] -= (ey / d) * f
|
||||
dx[b] += (ex / d) * f; dy[b] += (ey / d) * f
|
||||
}
|
||||
for (let i = 0; i < n; i++) {
|
||||
dx[i] -= X[i] * 0.9 * k * 4
|
||||
dy[i] -= Y[i] * 0.9 * k * 4
|
||||
const d = Math.hypot(dx[i], dy[i])
|
||||
if (d > 0) {
|
||||
const m = Math.min(d, temp)
|
||||
X[i] += (dx[i] / d) * m
|
||||
Y[i] += (dy[i] / d) * m
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Centré, étendue 1 (le plus grand côté de la boîte englobante)
|
||||
let x0 = Infinity, x1 = -Infinity, y0 = Infinity, y1 = -Infinity
|
||||
for (let i = 0; i < n; i++) { x0 = Math.min(x0, X[i]); x1 = Math.max(x1, X[i]); y0 = Math.min(y0, Y[i]); y1 = Math.max(y1, Y[i]) }
|
||||
const e = Math.max(x1 - x0, y1 - y0) || 1
|
||||
noeuds.forEach((x, i) => pos.set(x.id, { x: (X[i] - (x0 + x1) / 2) / e, y: (Y[i] - (y0 + y1) / 2) / e }))
|
||||
return pos
|
||||
}
|
||||
|
||||
/** Cache par signature du graphe : au serveur, une fois par processus, pas une fois par requête. */
|
||||
const CACHE = new Map<string, Map<string, Pt>>()
|
||||
export function disposerEnCache(noeuds: NoeudGraphe[], liens: LienGraphe[], principaux: Set<string>): Map<string, Pt> {
|
||||
const sig = JSON.stringify([noeuds.map((x) => [x.id, x.kind]), liens.map((l) => [l.de, l.vers]), [...principaux]])
|
||||
let p = CACHE.get(sig)
|
||||
if (!p) {
|
||||
p = disposer(noeuds, liens, principaux)
|
||||
if (CACHE.size > 24) CACHE.delete(CACHE.keys().next().value as string)
|
||||
CACHE.set(sig, p)
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
/** Identifiants à `pas` liens au plus de `id` (le nœud compris) ; `tout` = tous. */
|
||||
export function voisinage(liens: LienGraphe[], id: string, pas: Pas): Set<string> | null {
|
||||
if (pas === 'tout') return null
|
||||
const adj = new Map<string, string[]>()
|
||||
for (const l of liens) {
|
||||
if (!adj.has(l.de)) adj.set(l.de, [])
|
||||
if (!adj.has(l.vers)) adj.set(l.vers, [])
|
||||
adj.get(l.de)!.push(l.vers)
|
||||
adj.get(l.vers)!.push(l.de)
|
||||
}
|
||||
const vus = new Set([id])
|
||||
let front = [id]
|
||||
for (let p = 0; p < pas; p++) {
|
||||
const suite: string[] = []
|
||||
for (const x of front) for (const y of adj.get(x) ?? []) if (!vus.has(y)) { vus.add(y); suite.push(y) }
|
||||
front = suite
|
||||
}
|
||||
return vus
|
||||
}
|
||||
</script>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { boite, disposerEnCache, voisinage, type LienGraphe, type NoeudGraphe, type Pas, type Pt } from '~/utils/connaissances/graphe'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
noeuds: NoeudGraphe[]
|
||||
liens: LienGraphe[]
|
||||
@@ -262,8 +130,8 @@ const OPTIONS_PAS: { v: Pas; libelle: string }[] = [
|
||||
{ v: 'tout', libelle: 'tout' },
|
||||
]
|
||||
const DUREE = 600 // recadrage : ≤ 700 ms, puis immobile
|
||||
const MARGE = { haut: 52, bas: 44, gauche: 96, droite: 96 }
|
||||
const MARGE_TEL = { haut: 52, bas: 84, gauche: 64, droite: 64 } // < 768 : le pied de la vue fiches couvre le bas ; les libellés sont tenus dans le cadre par la borne de `ecran`
|
||||
const MARGE = { haut: 52, bas: 88, gauche: 96, droite: 96 } // bas : la légende (une ligne) et le libellé du dernier nœud, qui pend sous son rond
|
||||
const MARGE_TEL = { haut: 52, bas: 116, gauche: 64, droite: 64 } // < 768 : la légende tient sur deux lignes en bas ; les libellés sont tenus dans le cadre par la borne de `ecran`
|
||||
|
||||
// ── Taille mesurée (le rendu serveur part d'une taille plausible, comme GrapheMots) ──
|
||||
const racine = ref<HTMLElement | null>(null)
|
||||
@@ -311,13 +179,13 @@ const zone = computed(() => {
|
||||
const m = taille.w < 768 ? MARGE_TEL : MARGE
|
||||
return { x: m.gauche, y: m.haut, w: Math.max(40, taille.w - m.gauche - m.droite), h: Math.max(40, taille.h - m.haut - m.bas) }
|
||||
})
|
||||
/** Portrait d'écran et dessin paysage (ou l'inverse) : on tourne le dessin d'un quart. Projection, rien en base. */
|
||||
const tourne = computed(() => {
|
||||
let x0 = Infinity, x1 = -Infinity, y0 = Infinity, y1 = -Infinity
|
||||
for (const p of monde.value.values()) { x0 = Math.min(x0, p.x); x1 = Math.max(x1, p.x); y0 = Math.min(y0, p.y); y1 = Math.max(y1, p.y) }
|
||||
const paysage = x1 - x0 >= y1 - y0
|
||||
return paysage !== zone.value.w >= zone.value.h
|
||||
/** Le dessin est-il en paysage ? Calculé une fois par layout (le monde est en cache), pas à chaque redimensionnement. */
|
||||
const paysage = computed(() => {
|
||||
const b = boite(monde.value.values())
|
||||
return b.x1 - b.x0 >= b.y1 - b.y0
|
||||
})
|
||||
/** Portrait d'écran et dessin paysage (ou l'inverse) : on tourne le dessin d'un quart. Projection, rien en base. */
|
||||
const tourne = computed(() => paysage.value !== zone.value.w >= zone.value.h)
|
||||
const pt = (id: string): Pt | null => {
|
||||
const p = monde.value.get(id)
|
||||
if (!p) return null
|
||||
@@ -326,13 +194,11 @@ const pt = (id: string): Pt | null => {
|
||||
|
||||
const cible = computed<Camera>(() => {
|
||||
const vis = visibles.value
|
||||
let x0 = Infinity, x1 = -Infinity, y0 = Infinity, y1 = -Infinity
|
||||
for (const x of props.noeuds) {
|
||||
if (vis && !vis.has(x.id)) continue
|
||||
const p = pt(x.id)
|
||||
if (!p) continue
|
||||
x0 = Math.min(x0, p.x); x1 = Math.max(x1, p.x); y0 = Math.min(y0, p.y); y1 = Math.max(y1, p.y)
|
||||
}
|
||||
const points = props.noeuds
|
||||
.filter((x) => !vis || vis.has(x.id))
|
||||
.map((x) => pt(x.id))
|
||||
.filter((p): p is Pt => !!p)
|
||||
const { x0, x1, y0, y1 } = boite(points)
|
||||
if (!Number.isFinite(x0)) return { cx: 0, cy: 0, s: 1 }
|
||||
const z = zone.value
|
||||
const plein = Math.min(z.w, z.h) // échelle du graphe entier (étendue 1)
|
||||
@@ -477,14 +343,14 @@ const liensVus = computed(() => props.liens
|
||||
.gc__lien {
|
||||
stroke: color-mix(in srgb, var(--text) 38%, transparent);
|
||||
stroke-width: 1.1;
|
||||
transition: stroke 160ms ease-out, stroke-width 160ms ease-out, opacity 160ms ease-out;
|
||||
transition: stroke var(--dur-fast) var(--ease-out), stroke-width var(--dur-fast) var(--ease-out), opacity var(--dur-fast) var(--ease-out);
|
||||
}
|
||||
.gc__lien--curation { stroke-dasharray: 4 3; }
|
||||
.gc__lien--vif { stroke: var(--text); stroke-width: 1.8; }
|
||||
.gc__lien--eteint { opacity: 0.25; }
|
||||
|
||||
/* Sources : carrés gris, hors tabulation (au clavier, on y va par la liste des fiches) */
|
||||
.gc__source { cursor: pointer; transition: opacity 160ms ease-out; }
|
||||
.gc__source { cursor: pointer; transition: opacity var(--dur-fast) var(--ease-out); }
|
||||
.gc__carre {
|
||||
fill: color-mix(in srgb, var(--text) 52%, var(--bg-alt));
|
||||
stroke: var(--bg-alt);
|
||||
@@ -496,8 +362,8 @@ const liensVus = computed(() => props.liens
|
||||
.gc__source--loin { opacity: 0.6; }
|
||||
.gc__source-texte {
|
||||
fill: color-mix(in srgb, var(--text) 80%, transparent);
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
font-size: var(--fs-xs);
|
||||
font-weight: var(--fw-medium);
|
||||
paint-order: stroke;
|
||||
stroke: var(--bg-alt);
|
||||
stroke-width: 3px;
|
||||
@@ -523,7 +389,7 @@ const liensVus = computed(() => props.liens
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
pointer-events: auto;
|
||||
transition: opacity 160ms ease-out;
|
||||
transition: opacity var(--dur-fast) var(--ease-out);
|
||||
}
|
||||
.gc__rond {
|
||||
width: calc(2 * var(--gc-r));
|
||||
@@ -531,16 +397,16 @@ const liensVus = computed(() => props.liens
|
||||
border-radius: 50%;
|
||||
background: var(--surface);
|
||||
border: 2px solid var(--text);
|
||||
transition: background 160ms ease-out, border-color 160ms ease-out;
|
||||
transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
|
||||
}
|
||||
.gc__libelle {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
font-size: var(--fs-xs);
|
||||
font-weight: var(--fw-semibold);
|
||||
line-height: 1.2;
|
||||
text-align: center;
|
||||
overflow-wrap: anywhere;
|
||||
padding: 0 3px;
|
||||
border-radius: 4px;
|
||||
border-radius: var(--radius-sm);
|
||||
background: color-mix(in srgb, var(--bg-alt) 82%, transparent);
|
||||
}
|
||||
.gc__noeud--survol .gc__rond { border-width: 3px; }
|
||||
@@ -581,24 +447,33 @@ const liensVus = computed(() => props.liens
|
||||
.gc__pas[aria-pressed='true'] { background: var(--text); color: var(--surface); }
|
||||
.gc__pas:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
|
||||
|
||||
/* Légende : une ligne en bas du graphe (deux au téléphone), hors de la poignée et de la barre des pas */
|
||||
.gc__legende {
|
||||
position: absolute;
|
||||
top: var(--space-xs);
|
||||
right: var(--space-sm);
|
||||
left: var(--space-lg);
|
||||
bottom: var(--space-xs);
|
||||
max-width: calc(100% - var(--space-lg) - var(--space-sm));
|
||||
margin: 0;
|
||||
padding: var(--space-2xs) var(--space-xs);
|
||||
list-style: none;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 11px;
|
||||
gap: var(--space-2xs) var(--space-sm);
|
||||
border-radius: var(--radius-sm);
|
||||
background: color-mix(in srgb, var(--bg-alt) 88%, transparent);
|
||||
font-size: var(--fs-xs);
|
||||
line-height: 1.3;
|
||||
color: color-mix(in srgb, var(--text) 78%, transparent);
|
||||
pointer-events: none;
|
||||
}
|
||||
.gc__legende-trait { display: inline-block; width: 18px; border-top: 1.5px solid currentColor; margin-left: 6px; }
|
||||
.gc__legende li { display: inline-flex; align-items: center; gap: var(--space-2xs); }
|
||||
.gc__legende-rond { width: 10px; height: 10px; border-radius: var(--radius-full); border: 2px solid var(--text); background: var(--surface); }
|
||||
.gc__legende-carre { width: 9px; height: 9px; border-radius: 2px; background: color-mix(in srgb, var(--text) 52%, var(--bg-alt)); }
|
||||
.gc__legende-trait { width: 18px; border-top: 1.5px solid currentColor; }
|
||||
.gc__legende-trait--curation { border-top-style: dashed; }
|
||||
@media (max-width: 639.98px) { .gc__legende { display: none; } }
|
||||
@media (max-width: 767.98px) {
|
||||
.gc__noeud { max-width: 8rem; }
|
||||
.gc__libelle { font-size: 12px; }
|
||||
}
|
||||
|
||||
/* Mouvement réduit : état final, sans transition (la caméra saute aussi, côté script) */
|
||||
|
||||
@@ -228,7 +228,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Fiche à fiche : en tête sur ordinateur, en pied au téléphone (même élément, ordre CSS) -->
|
||||
<nav v-if="vf.position" class="vf-detail__nav" aria-label="Fiche à fiche">
|
||||
<nav v-if="vf.position && navigationLineaire" class="vf-detail__nav" aria-label="Fiche à fiche">
|
||||
<button type="button" class="vf-detail__pas" :disabled="!vf.position.precedente" @click="vf.fichePrecedente()">
|
||||
<span aria-hidden="true">‹ </span>Précédente
|
||||
</button>
|
||||
@@ -253,7 +253,7 @@
|
||||
<span class="vf-detail__statut" role="status">{{ statutLien }}</span>
|
||||
</div>
|
||||
<slot name="detail" :fiche="vf.ficheOuverte" :filtrer="filtrerDepuisDetail" />
|
||||
<p class="vf-detail__aide">← → pour passer d'une fiche à l'autre · Échap pour fermer</p>
|
||||
<p class="vf-detail__aide">{{ navigationLineaire ? "← → pour passer d'une fiche à l'autre · Échap pour fermer" : 'Échap pour fermer' }}</p>
|
||||
</template>
|
||||
<p v-else class="vf-etat-vide">{{ pending ? 'Chargement de la fiche…' : 'Fiche introuvable : elle a peut-être été retirée.' }}</p>
|
||||
</div>
|
||||
@@ -302,7 +302,7 @@ import type { MiniFiche } from '~/composables/useFicheAdapter'
|
||||
import type { VueFichesEtat } from '~/composables/useVueFiches'
|
||||
import { LIBELLES_TRI, type EtatVue, type TriFiches } from '~/utils/vueFiches'
|
||||
|
||||
const props = defineProps<{
|
||||
const props = withDefaults(defineProps<{
|
||||
vf: VueFichesEtat
|
||||
/** Une ligne, « intention d'abord » (DESIGN-SYSTEM §Intention d'abord). */
|
||||
intention?: string
|
||||
@@ -313,7 +313,13 @@ const props = defineProps<{
|
||||
lienPage?: (f: MiniFiche) => string | null
|
||||
/** Libellés des trois états quand « Carte » n'est pas le mot juste (ex. { carte: 'Graphe' }). Le paramètre d'URL reste `vue=carte`. */
|
||||
libellesVue?: Partial<Record<EtatVue, string>>
|
||||
}>()
|
||||
/**
|
||||
* Boutons Précédente / Suivante (et le rang « N / total ») dans le détail. false = masqués
|
||||
* (B19b, `/connaissances` : sur un graphe, l'ordre de la liste n'est pas un ordre de lecture) ;
|
||||
* les flèches ← → et le balayage restent.
|
||||
*/
|
||||
navigationLineaire?: boolean
|
||||
}>(), { navigationLineaire: true })
|
||||
|
||||
const emit = defineEmits<{
|
||||
select: [fiche: MiniFiche]
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
import type { Org } from '~/types/org'
|
||||
import type { StructureV2 } from '~/types/structure-v2'
|
||||
import type { JeuConnaissances, ObjetConnaissance } from '../utils/connaissances/valider'
|
||||
import { lecture, porteursDe, estRendu, type Lecture } from '../utils/connaissances/lire'
|
||||
import { ECHELLES, LIBELLES_NATURE, RE_PREFIXE } from '../utils/connaissances/vocabulaire'
|
||||
|
||||
export interface MiniFiche {
|
||||
id: string | number
|
||||
@@ -194,65 +197,21 @@ export function toMiniMot(fiche: FicheMot, ressources: RessourceMot[]): MiniFich
|
||||
}
|
||||
|
||||
// ── Connaissances partagées (B19-M1) : un objet de la couche = une fiche ──────
|
||||
|
||||
/**
|
||||
* Un objet de `data/connaissances/` (schéma B18). Type local, volontairement lâche :
|
||||
* le contrat fait foi dans `data/connaissances/schema.json`, le contrôle dans
|
||||
* `utils/connaissances/valider.ts`.
|
||||
*/
|
||||
export interface ObjetCouche {
|
||||
id: string
|
||||
nature: 'texte' | 'organisation' | 'outil' | 'concept'
|
||||
nom_canonique: string
|
||||
etat: string
|
||||
definition_courte?: string
|
||||
libelle_source?: string
|
||||
variantes?: string[]
|
||||
porteur_ids?: string[]
|
||||
echelles?: string[]
|
||||
couche?: string
|
||||
date_original?: string | null
|
||||
credit?: string | null
|
||||
[champ: string]: unknown
|
||||
}
|
||||
export interface JeuCouche {
|
||||
objets: ObjetCouche[]
|
||||
relations: { type: string; de: string; vers: string; provenance: string; etat: string; note?: string }[]
|
||||
[champ: string]: unknown
|
||||
}
|
||||
|
||||
export const LIBELLES_NATURE: Record<ObjetCouche['nature'], string> = {
|
||||
concept: 'Concept',
|
||||
texte: 'Texte',
|
||||
organisation: 'Organisation',
|
||||
outil: 'Outil',
|
||||
}
|
||||
|
||||
/**
|
||||
* Ce que la page rend : les objets publiés. Un objet écarté reste en base et n'est jamais
|
||||
* rendu ; `en_file`, `a_trier` et `a_creuser` non plus, tant qu'un humain n'a pas tranché
|
||||
* (interdit n° 2 de la CONCEPTION §5).
|
||||
*/
|
||||
export const estRendu = (o: { etat: string }) => o.etat === 'publie'
|
||||
// Types : `utils/connaissances/valider.ts` (les seuls de la couche). Vocabulaire :
|
||||
// `utils/connaissances/vocabulaire.ts`. Lecture du jeu (index, porteurs) : `lire.ts`.
|
||||
|
||||
/** `org:holosapiens` → `holosapiens` : la forme d'un porteur dans l'URL (`porteur=holosapiens`). */
|
||||
export const valeurPorteur = (id: string) => id.replace(/^[a-z]+:/, '')
|
||||
|
||||
/** Porteurs d'un objet : ses `porteur_ids` qui sont des organisations rendues ; une organisation se porte elle-même. */
|
||||
function porteursDe(o: ObjetCouche, rendus: Map<string, ObjetCouche>): ObjetCouche[] {
|
||||
if (o.nature === 'organisation') return [o]
|
||||
return (o.porteur_ids ?? []).map((id) => rendus.get(id)).filter((p): p is ObjetCouche => !!p && p.nature === 'organisation')
|
||||
}
|
||||
export const valeurPorteur = (id: string) => id.replace(RE_PREFIXE, '')
|
||||
|
||||
/** Échelles d'un objet : les siennes ; pour une source, celles des concepts publiés qui en sont extraits (projection, rien en base). */
|
||||
function echellesDe(o: ObjetCouche, jeu: JeuCouche, rendus: Map<string, ObjetCouche>): string[] {
|
||||
function echellesDe(o: ObjetConnaissance, l: Lecture): string[] {
|
||||
if (o.echelles?.length) return [...o.echelles]
|
||||
const out = new Set<string>()
|
||||
for (const r of jeu.relations) {
|
||||
for (const r of l.jeu.relations) {
|
||||
if (r.type !== 'extrait_de' || r.vers !== o.id) continue
|
||||
for (const e of rendus.get(r.de)?.echelles ?? []) out.add(e)
|
||||
for (const e of l.rendus.get(r.de)?.echelles ?? []) out.add(e)
|
||||
}
|
||||
return ['S', 'M', 'XL'].filter((e) => out.has(e))
|
||||
return ECHELLES.filter((e) => out.has(e))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,17 +220,18 @@ function echellesDe(o: ObjetCouche, jeu: JeuCouche, rendus: Map<string, ObjetCou
|
||||
* Pas de géographie : `geoloc: true`, comme `toMiniMot` (sinon la vue annoncerait « N sans
|
||||
* adresse » et n'offrirait pas « Voir dans le graphe »).
|
||||
*/
|
||||
export function toMiniConnaissance(objet: ObjetCouche, jeu: JeuCouche): MiniFiche {
|
||||
const rendus = new Map(jeu.objets.filter(estRendu).map((o) => [o.id, o]))
|
||||
const porteurs = porteursDe(objet, rendus)
|
||||
const echelles = echellesDe(objet, jeu, rendus)
|
||||
export function toMiniConnaissance(objet: ObjetConnaissance, jeu: JeuConnaissances): MiniFiche {
|
||||
// L'index du jeu est construit une fois par jeu (`lecture`, mémorisé), pas une fois par fiche.
|
||||
const l = lecture(jeu)
|
||||
const porteurs = porteursDe(l, objet)
|
||||
const echelles = echellesDe(objet, l)
|
||||
const nomsPorteurs = porteurs.filter((p) => p.id !== objet.id).map((p) => p.nom_canonique)
|
||||
// Une organisation se porte elle-même : « titre — porteur » redirait son nom ; on dit son statut et son adresse.
|
||||
const domaine = typeof objet.url_canonique === 'string' ? objet.url_canonique.replace(/^https?:\/\/(www\.)?/, '').replace(/\/.*$/, '') : ''
|
||||
const resume = objet.nature === 'concept'
|
||||
? (objet.definition_courte ?? '')
|
||||
: objet.nature === 'organisation'
|
||||
? [objet.statut ? `statut : ${objet.statut}` : '', domaine].filter(Boolean).join(' · ')
|
||||
? [objet.statut ? `statut : ${objet.statut}` : '', domaine].filter(Boolean).join(', ')
|
||||
: [objet.nom_canonique, nomsPorteurs.join(', ')].filter(Boolean).join(', ')
|
||||
return {
|
||||
id: objet.id,
|
||||
@@ -295,26 +255,24 @@ export function toMiniConnaissance(objet: ObjetCouche, jeu: JeuCouche): MiniFich
|
||||
}
|
||||
|
||||
/** Les fiches de la page : objets publiés, dans l'ordre du jeu. */
|
||||
export function fichesConnaissances(jeu: JeuCouche): MiniFiche[] {
|
||||
return jeu.objets.filter(estRendu).map((o) => toMiniConnaissance(o, jeu))
|
||||
export function fichesConnaissances(jeu: JeuConnaissances): MiniFiche[] {
|
||||
return [...lecture(jeu).rendus.values()].map((o) => toMiniConnaissance(o, jeu))
|
||||
}
|
||||
|
||||
/**
|
||||
* Nœuds et liens du graphe, depuis les seuls objets publiés et les relations publiées
|
||||
* entre eux (`renvoie_a` et les porteurs du registre restent hors du graphe : ils visent
|
||||
* une autre base). Aucune position : `GrapheConnaissances` la calcule.
|
||||
* une autre base). Aucune position ni degré : `GrapheConnaissances` les calcule, une fois.
|
||||
*/
|
||||
export function grapheConnaissances(jeu: JeuCouche): {
|
||||
noeuds: { id: string; libelle: string; kind: string; poids: number }[]
|
||||
export function grapheConnaissances(jeu: JeuConnaissances): {
|
||||
noeuds: { id: string; libelle: string; kind: string }[]
|
||||
liens: { de: string; vers: string; type: string; provenance: string }[]
|
||||
} {
|
||||
const rendus = new Map(jeu.objets.filter(estRendu).map((o) => [o.id, o]))
|
||||
const { rendus } = lecture(jeu)
|
||||
const liens = jeu.relations
|
||||
.filter((r) => r.etat === 'publie' && r.type !== 'renvoie_a' && rendus.has(r.de) && rendus.has(r.vers))
|
||||
.filter((r) => estRendu(r) && r.type !== 'renvoie_a' && rendus.has(r.de) && rendus.has(r.vers))
|
||||
.map((r) => ({ de: r.de, vers: r.vers, type: r.type, provenance: r.provenance }))
|
||||
const degre = new Map<string, number>()
|
||||
for (const l of liens) for (const id of [l.de, l.vers]) degre.set(id, (degre.get(id) ?? 0) + 1)
|
||||
const noeuds = [...rendus.values()].map((o) => ({ id: o.id, libelle: o.nom_canonique, kind: o.nature, poids: degre.get(o.id) ?? 0 }))
|
||||
const noeuds = [...rendus.values()].map((o) => ({ id: o.id, libelle: o.nom_canonique, kind: o.nature }))
|
||||
return { noeuds, liens }
|
||||
}
|
||||
|
||||
|
||||
+36
-18
@@ -26,9 +26,42 @@ export type Largeur = 'telephone' | 'tablette' | 'ordinateur' | null
|
||||
|
||||
const CLE_REPLI = 'aep_vue_fiches_liste_repliee'
|
||||
|
||||
/**
|
||||
* État rendu (logique pure, testée par `scripts/test-vue-fiches.mjs`). `auto` avant le
|
||||
* montage quand l'URL ne tranche pas (ou dit `mixte`) : la CSS rend Mixte à partir de
|
||||
* 1024 px et Fiches en dessous, sans saut à l'hydratation. Mixte n'existe pas sous 1024 px :
|
||||
* il se lit Fiches. B19b : `etatDefaut` (option de la page) tient lieu de `vue=` absent ;
|
||||
* sans lui, rien ne change. L'URL prime toujours.
|
||||
*/
|
||||
export function vueRendue(
|
||||
vue: EtatVue | null,
|
||||
etats: EtatVue[],
|
||||
largeur: Largeur,
|
||||
listeRepliee: boolean,
|
||||
etatDefaut: EtatVue | null = null,
|
||||
): EtatVue | 'auto' {
|
||||
const v = vue ?? (etatDefaut && etats.includes(etatDefaut) ? etatDefaut : null)
|
||||
// `auto` rend Mixte à partir de 1024 px : seulement pour une page qui a cet état
|
||||
if (largeur === null) return v && v !== 'mixte' ? v : etats.includes('mixte') ? 'auto' : 'fiches'
|
||||
const ordinateur = largeur === 'ordinateur'
|
||||
if (v === 'mixte' || v === null) {
|
||||
if (!ordinateur || !etats.includes('mixte')) return 'fiches'
|
||||
if (v === null && listeRepliee) return 'carte'
|
||||
return 'mixte'
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
/** Options de la page, hors configuration des filtres (B19b). */
|
||||
export interface OptionsVueFiches {
|
||||
/** État quand l'URL n'a pas de `vue=` (défaut : Mixte ou Fiches selon la largeur). */
|
||||
etatDefaut?: EtatVue
|
||||
}
|
||||
|
||||
export function useVueFiches(
|
||||
fiches: MaybeRefOrGetter<MiniFiche[]>,
|
||||
config: MaybeRefOrGetter<ConfigVueFiches>,
|
||||
options: OptionsVueFiches = {},
|
||||
) {
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -124,24 +157,9 @@ export function useVueFiches(
|
||||
try { listeRepliee.value = sessionStorage.getItem(CLE_REPLI) === '1' } catch {}
|
||||
})
|
||||
|
||||
/**
|
||||
* État rendu. `auto` avant le montage quand l'URL ne tranche pas (ou dit
|
||||
* `mixte`) : la CSS rend Mixte à partir de 1024 px et Fiches en dessous, sans
|
||||
* saut à l'hydratation. Mixte n'existe pas sous 1024 px : il se lit Fiches.
|
||||
*/
|
||||
const vueAffichee = computed<EtatVue | 'auto'>(() => {
|
||||
const etats = cfg.value.etats
|
||||
const v = etat.value.vue
|
||||
// `auto` rend Mixte à partir de 1024 px : seulement pour une page qui a cet état
|
||||
if (largeur.value === null) return v && v !== 'mixte' ? v : etats.includes('mixte') ? 'auto' : 'fiches'
|
||||
const ordinateur = largeur.value === 'ordinateur'
|
||||
if (v === 'mixte' || v === null) {
|
||||
if (!ordinateur || !etats.includes('mixte')) return 'fiches'
|
||||
if (v === null && listeRepliee.value) return 'carte'
|
||||
return 'mixte'
|
||||
}
|
||||
return v
|
||||
})
|
||||
/** État rendu : `vueRendue`, ci-dessus. */
|
||||
const vueAffichee = computed<EtatVue | 'auto'>(() =>
|
||||
vueRendue(etat.value.vue, cfg.value.etats, largeur.value, listeRepliee.value, options.etatDefaut ?? null))
|
||||
|
||||
function setVue(v: EtatVue) {
|
||||
if (largeur.value === 'ordinateur' && (v === 'mixte' || v === 'carte')) {
|
||||
|
||||
+232
-183
@@ -5,8 +5,13 @@
|
||||
fiche de l'objet dans #detail. URL partageable : ?vue=mixte&fiche=cpt:holoptisme.
|
||||
|
||||
Données : la fixture de B18, importée au build (aucune route serveur : /api/connaissances
|
||||
est B20). Seuls les objets publiés sont rendus. Rien n'est lu du vault, rien n'est copié de
|
||||
Holosapiens au-delà des titres, URL et dates ; la dette de forme se dit dans le bandeau.
|
||||
est B20). Seuls les objets publiés ont un nœud et une fiche ; la fiche nomme aussi ses
|
||||
sources à creuser et ses relations vers un objet non publié. Rien n'est lu du vault, rien
|
||||
n'est copié de Holosapiens au-delà des titres, URL et dates ; la dette de forme se dit dans
|
||||
le bandeau.
|
||||
|
||||
B19b (retours de Jules du 27/10) : graphe par défaut, sans Précédente / Suivante ; la fiche
|
||||
en trois étages (propriétés, texte, fond replié) ; la logique dans utils/connaissances/.
|
||||
-->
|
||||
<template>
|
||||
<main class="cn">
|
||||
@@ -16,7 +21,7 @@
|
||||
Premier jeu : {{ nombreEnLettres(nbConcepts) }} concepts et leurs sources.
|
||||
La couche se nourrit des ressources proposées par les membres, triées à la main.
|
||||
Navigation inspirée de
|
||||
<a href="https://holosapiens.earth" target="_blank" rel="noopener noreferrer">l’explorateur Holosapiens<span class="cn-sr"> (nouvel onglet)</span></a>
|
||||
<a href="https://holosapiens.earth" target="_blank" rel="noopener noreferrer">l’explorateur Holosapiens<span class="sr-only"> (nouvel onglet)</span></a>
|
||||
(CC BY-SA 4.0).
|
||||
</p>
|
||||
</header>
|
||||
@@ -28,6 +33,7 @@
|
||||
libelle-recherche="Rechercher un concept, une source…"
|
||||
:libelles-vue="{ carte: 'Graphe' }"
|
||||
:lien-page="() => null"
|
||||
:navigation-lineaire="false"
|
||||
>
|
||||
<template #carte>
|
||||
<GrapheConnaissances
|
||||
@@ -44,103 +50,133 @@
|
||||
</template>
|
||||
|
||||
<template #detail="{ fiche, filtrer }">
|
||||
<article v-if="objetDe(fiche.id)" class="cf">
|
||||
<p class="cf__nature">{{ LIBELLES_NATURE[objetDe(fiche.id)!.nature] }}</p>
|
||||
<h2 class="cf__titre">{{ objetDe(fiche.id)!.nom_canonique }}</h2>
|
||||
<!--
|
||||
Trois étages (retours de Jules du 27/10, n° 1 et 3) : ① le titre et l'en-tête de
|
||||
propriétés, dense et atténué, comme les propriétés d'Obsidian ; ② le texte, l'étage
|
||||
qu'on lit ; ③ crédit, licence, dettes et vacances, repliés en bas.
|
||||
-->
|
||||
<article v-if="objetOuvert" class="cf">
|
||||
<h2 class="cf__titre">{{ objetOuvert.nom_canonique }}</h2>
|
||||
|
||||
<ChipGroup v-if="fiche.etiquettes?.echelle?.length" :aria-label="`Échelles de ${fiche.nom}`" class="cf__chips">
|
||||
<Chip
|
||||
v-for="e in fiche.etiquettes.echelle"
|
||||
:key="e"
|
||||
:label="e"
|
||||
variant="echelle"
|
||||
:active="(vf.etat.filtres.echelle ?? []).includes(e)"
|
||||
:aria-label="`Filtrer par échelle : ${e}`"
|
||||
@toggle="filtrer('echelle', e)"
|
||||
/>
|
||||
</ChipGroup>
|
||||
<!-- ① Propriétés : une ligne par propriété, une ligne par type de relation -->
|
||||
<dl class="cf__props">
|
||||
<dt>Nature</dt>
|
||||
<dd>{{ LIBELLES_NATURE[objetOuvert.nature] }}</dd>
|
||||
|
||||
<!-- Concept : la définition, dans nos mots -->
|
||||
<template v-if="objetDe(fiche.id)!.nature === 'concept'">
|
||||
<p class="cf__definition">{{ objetDe(fiche.id)!.definition_courte }}</p>
|
||||
<p class="cf__mention">Définition écrite par AEP, dans ses mots.</p>
|
||||
</template>
|
||||
|
||||
<!-- Objet : date de l'original, lien sortant -->
|
||||
<dl v-else class="cf__faits">
|
||||
<template v-if="objetDe(fiche.id)!.date_original">
|
||||
<dt>{{ objetDe(fiche.id)!.date_original_nature === 'vue' ? 'En ligne au' : 'Date de l’original' }}</dt>
|
||||
<template v-if="fiche.etiquettes?.echelle?.length">
|
||||
<dt class="cf__k cf__k--chips">Échelles</dt>
|
||||
<dd>
|
||||
{{ dateFr(objetDe(fiche.id)!.date_original) }}
|
||||
<span v-if="objetDe(fiche.id)!.date_original_nature === 'vue'" class="cf__discret">(aucune date affichée)</span>
|
||||
<ChipGroup :aria-label="`Échelles de ${fiche.nom}`" class="cf__chips">
|
||||
<Chip
|
||||
v-for="e in fiche.etiquettes.echelle"
|
||||
:key="e"
|
||||
:label="e"
|
||||
variant="echelle"
|
||||
:active="(vf.etat.filtres.echelle ?? []).includes(e)"
|
||||
:aria-label="`Filtrer par échelle : ${e}`"
|
||||
@toggle="filtrer('echelle', e)"
|
||||
/>
|
||||
</ChipGroup>
|
||||
</dd>
|
||||
</template>
|
||||
<template v-if="objetDe(fiche.id)!.statut">
|
||||
|
||||
<template v-if="porteursOuverts.length">
|
||||
<dt class="cf__k cf__k--cible">{{ porteursOuverts.length > 1 ? 'Porteurs' : 'Porteur' }}</dt>
|
||||
<dd>
|
||||
<ul class="cf__cibles">
|
||||
<li v-for="p in porteursOuverts" :key="p.id">
|
||||
<button type="button" class="cf__vers" @click="vf.ouvrirFiche(p.id)">{{ p.nom_canonique }}</button>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
</template>
|
||||
|
||||
<template v-if="objetOuvert.couche">
|
||||
<dt>Couche</dt>
|
||||
<dd>{{ LIBELLES_COUCHE[objetOuvert.couche] }}</dd>
|
||||
</template>
|
||||
|
||||
<!-- Objet (texte, organisation, outil) : date de l'original, statut, adresse -->
|
||||
<template v-if="objetOuvert.nature !== 'concept' && objetOuvert.date_original">
|
||||
<dt>{{ objetOuvert.date_original_nature === 'vue' ? 'En ligne au' : 'Date de l’original' }}</dt>
|
||||
<dd>
|
||||
{{ dateFr(objetOuvert.date_original) }}
|
||||
<span v-if="objetOuvert.date_original_nature === 'vue'">(aucune date affichée)</span>
|
||||
</dd>
|
||||
</template>
|
||||
<template v-if="objetOuvert.nature !== 'concept' && objetOuvert.statut">
|
||||
<dt>Statut</dt>
|
||||
<dd>{{ objetDe(fiche.id)!.statut }}</dd>
|
||||
<dd>{{ objetOuvert.statut }}</dd>
|
||||
</template>
|
||||
<template v-if="objetDe(fiche.id)!.url_canonique">
|
||||
<dt>Adresse</dt>
|
||||
<template v-if="objetOuvert.nature !== 'concept' && objetOuvert.url_canonique">
|
||||
<dt class="cf__k cf__k--cible">Adresse</dt>
|
||||
<dd>
|
||||
<a :href="String(objetDe(fiche.id)!.url_canonique)" target="_blank" rel="noopener noreferrer" class="cf__lien">{{ urlCourte(String(objetDe(fiche.id)!.url_canonique)) }}<span aria-hidden="true"> ↗</span><span class="cn-sr"> (nouvel onglet)</span></a>
|
||||
<a :href="objetOuvert.url_canonique" target="_blank" rel="noopener noreferrer" class="cf__lien cf__lien--cible">{{ urlCourte(objetOuvert.url_canonique) }}<span class="sr-only"> (nouvel onglet)</span></a>
|
||||
</dd>
|
||||
</template>
|
||||
|
||||
<!-- Sources (extrait_de), publiées ou non : une source à creuser se dit -->
|
||||
<template v-if="sourcesOuvertes.length">
|
||||
<dt class="cf__k cf__k--cible">{{ sourcesOuvertes.length > 1 ? 'Sources' : 'Source' }}</dt>
|
||||
<dd>
|
||||
<ul class="cf__cibles cf__cibles--colonne">
|
||||
<li v-for="s in sourcesOuvertes" :key="s.id" class="cf__source">
|
||||
<button v-if="estRendu(s)" type="button" class="cf__vers" @click="vf.ouvrirFiche(s.id)">{{ s.nom_canonique }}</button>
|
||||
<span v-else class="cf__cible-texte">{{ s.nom_canonique }}</span>
|
||||
<span class="cf__cible-texte">({{ dateSource(s) }}<template v-if="!estRendu(s)">, à creuser</template>)</span>
|
||||
<a v-if="s.url_canonique" :href="s.url_canonique" target="_blank" rel="noopener noreferrer" class="cf__lien cf__lien--cible">lien<span class="sr-only"> vers {{ s.nom_canonique }} (nouvel onglet)</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
</template>
|
||||
|
||||
<!-- Relations typées : le libellé du type, puis les cibles et leur provenance -->
|
||||
<template v-for="g in relationsOuvertes" :key="g.libelle">
|
||||
<dt class="cf__k cf__k--cible">{{ libelleLigne(g.libelle) }}</dt>
|
||||
<dd>
|
||||
<ul class="cf__cibles">
|
||||
<li v-for="r in g.relations" :key="r.cle" class="cf__relation">
|
||||
<button v-if="estRendu(r.cible)" type="button" class="cf__vers" @click="vf.ouvrirFiche(r.cible.id)">{{ r.cible.nom_canonique }}</button>
|
||||
<span v-else class="cf__cible-texte">{{ r.cible.nom_canonique }} (non publié)</span>
|
||||
<span class="cf__provenance" :class="`cf__provenance--${r.provenance}`">{{ r.provenance === 'source' ? 'énoncé par la source' : 'posé par AEP' }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
</template>
|
||||
|
||||
<template v-if="objetOuvert.registre_id">
|
||||
<dt>Registre</dt>
|
||||
<dd>Renvoie au registre des œuvres : <code>{{ objetOuvert.registre_id }}</code></dd>
|
||||
</template>
|
||||
</dl>
|
||||
|
||||
<!-- Sources d'un concept -->
|
||||
<section v-if="sourcesDe(fiche.id).length" class="cf__bloc" :aria-labelledby="`cf-sources-${idDom(fiche.id)}`">
|
||||
<h3 :id="`cf-sources-${idDom(fiche.id)}`" class="cf__soustitre">Sources</h3>
|
||||
<ul class="cf__liste">
|
||||
<li v-for="s in sourcesDe(fiche.id)" :key="s.id" class="cf__source">
|
||||
<button v-if="estRendu(s)" type="button" class="cf__vers" @click="vf.ouvrirFiche(s.id)">{{ s.nom_canonique }}</button>
|
||||
<span v-else>{{ s.nom_canonique }}</span>
|
||||
<span class="cf__discret">
|
||||
· {{ s.date_original ? (s.date_original_nature === 'vue' ? `en ligne au ${dateFr(s.date_original)}` : dateFr(s.date_original)) : 'date à relever' }}
|
||||
<template v-if="!estRendu(s)"> · à creuser</template>
|
||||
</span>
|
||||
<a v-if="s.url_canonique" :href="String(s.url_canonique)" target="_blank" rel="noopener noreferrer" class="cf__lien cf__lien--ext">
|
||||
lien<span aria-hidden="true"> ↗</span><span class="cn-sr"> vers {{ s.nom_canonique }} (nouvel onglet)</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
<!-- ② Le texte, dans nos mots : un bloc qui accueillera plusieurs paragraphes (option B) -->
|
||||
<div v-if="objetOuvert.nature === 'concept'" class="cf__texte">
|
||||
<p>{{ objetOuvert.definition_courte }}</p>
|
||||
</div>
|
||||
<p v-if="objetOuvert.nature === 'concept'" class="cf__mention">Définition écrite par AEP, dans ses mots.</p>
|
||||
|
||||
<!-- Relations typées, avec leur provenance -->
|
||||
<section v-if="relationsDe(fiche.id).length" class="cf__bloc" :aria-labelledby="`cf-rel-${idDom(fiche.id)}`">
|
||||
<h3 :id="`cf-rel-${idDom(fiche.id)}`" class="cf__soustitre">Relations</h3>
|
||||
<ul class="cf__liste">
|
||||
<li v-for="r in relationsDe(fiche.id)" :key="r.cle" class="cf__relation">
|
||||
<span class="cf__type">{{ r.libelle }}</span>
|
||||
<button v-if="r.cible && estRendu(r.cible)" type="button" class="cf__vers" @click="vf.ouvrirFiche(r.cible.id)">{{ r.cible.nom_canonique }}</button>
|
||||
<span v-else-if="r.cible">{{ r.cible.nom_canonique }} <span class="cf__discret">(non publié)</span></span>
|
||||
<span class="cf__provenance" :class="`cf__provenance--${r.provenance}`">{{ r.provenance === 'source' ? 'énoncé par la source' : 'posé par AEP' }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<p v-if="objetDe(fiche.id)!.registre_id" class="cf__registre">
|
||||
Renvoie au registre des œuvres : <code>{{ objetDe(fiche.id)!.registre_id }}</code>
|
||||
</p>
|
||||
|
||||
<!-- Crédit, licence, dettes -->
|
||||
<section class="cf__bloc cf__credit" :aria-labelledby="`cf-credit-${idDom(fiche.id)}`">
|
||||
<h3 :id="`cf-credit-${idDom(fiche.id)}`" class="cf__soustitre">Crédit et licence</h3>
|
||||
<p v-if="objetDe(fiche.id)!.credit">Crédit : {{ objetDe(fiche.id)!.credit }}</p>
|
||||
<p v-if="objetDe(fiche.id)!.nature === 'concept'">Cette fiche : {{ jeu.licence_couche }}, couche de connaissances AEP.</p>
|
||||
<p v-else-if="objetDe(fiche.id)!.licence">Licence de l’original : {{ objetDe(fiche.id)!.licence }}.</p>
|
||||
<template v-if="dettesDe(fiche.id).length">
|
||||
<p class="cf__dettes-titre">Dettes non créditées par la source :</p>
|
||||
<ul class="cf__dettes">
|
||||
<li v-for="d in dettesDe(fiche.id)" :key="d">{{ d }}</li>
|
||||
</ul>
|
||||
</template>
|
||||
<template v-if="vacancesDe(fiche.id).length">
|
||||
<p class="cf__dettes-titre">Ce qu’on n’a pas trouvé :</p>
|
||||
<ul class="cf__dettes">
|
||||
<li v-for="v in vacancesDe(fiche.id)" :key="v.enonce">{{ v.enonce }} <span class="cf__discret">(constaté le {{ dateFr(v.date) }})</span></li>
|
||||
</ul>
|
||||
</template>
|
||||
</section>
|
||||
<!-- ③ Le fond : crédit, licence, dettes non créditées, vacances, repliés par défaut -->
|
||||
<details v-if="aUnFond" class="cf__fond">
|
||||
<summary class="cf__fond-titre">Crédit, licence et dettes</summary>
|
||||
<div class="cf__fond-corps">
|
||||
<p v-if="objetOuvert.credit">Crédit : {{ objetOuvert.credit }}</p>
|
||||
<p v-if="objetOuvert.nature === 'concept'">Cette fiche : {{ jeu.licence_couche }}, couche de connaissances AEP.</p>
|
||||
<p v-else-if="objetOuvert.licence">Licence de l’original : {{ objetOuvert.licence }}.</p>
|
||||
<template v-if="dettesOuvertes.length">
|
||||
<p class="cf__fond-sous">Dettes non créditées par la source :</p>
|
||||
<ul class="cf__fond-liste">
|
||||
<li v-for="d in dettesOuvertes" :key="d">{{ d }}</li>
|
||||
</ul>
|
||||
</template>
|
||||
<template v-if="vacancesOuvertes.length">
|
||||
<p class="cf__fond-sous">Ce qu’on n’a pas trouvé :</p>
|
||||
<ul class="cf__fond-liste">
|
||||
<li v-for="v in vacancesOuvertes" :key="v.enonce">{{ v.enonce }} (constaté le {{ dateFr(v.date) }})</li>
|
||||
</ul>
|
||||
</template>
|
||||
</div>
|
||||
</details>
|
||||
</article>
|
||||
</template>
|
||||
</VueFiches>
|
||||
@@ -151,29 +187,27 @@
|
||||
<script setup lang="ts">
|
||||
import jeuBrut from '~/data/connaissances/fixture-lot2.json'
|
||||
import type { ConfigVueFiches } from '~/utils/vueFiches'
|
||||
import {
|
||||
fichesConnaissances, grapheConnaissances, estRendu, valeurPorteur, LIBELLES_NATURE,
|
||||
type JeuCouche, type ObjetCouche,
|
||||
} from '~/composables/useFicheAdapter'
|
||||
|
||||
type Nature = ObjetCouche['nature']
|
||||
import type { JeuConnaissances, ObjetConnaissance } from '~/utils/connaissances/valider'
|
||||
import { lecture, estRendu, sourcesDe, porteursDe, relationsParLibelle, dettesDe, vacancesDe } from '~/utils/connaissances/lire'
|
||||
import { NATURES, ECHELLES, COUCHES, LIBELLES_NATURE, LIBELLES_COUCHE, type Nature } from '~/utils/connaissances/vocabulaire'
|
||||
import { fichesConnaissances, grapheConnaissances, valeurPorteur } from '~/composables/useFicheAdapter'
|
||||
|
||||
// Données au build : import statique de la fixture B18 (B20 branchera /api/connaissances).
|
||||
const jeu = jeuBrut as unknown as JeuCouche & { licence_couche: string }
|
||||
const parId = new Map(jeu.objets.map((o) => [o.id, o]))
|
||||
const objetDe = (id: string | number) => parId.get(String(id)) as (ObjetCouche & Record<string, any>) | undefined
|
||||
const jeu = jeuBrut as unknown as JeuConnaissances
|
||||
const lu = lecture(jeu)
|
||||
|
||||
const fiches = fichesConnaissances(jeu)
|
||||
const graphe = grapheConnaissances(jeu)
|
||||
const nbConcepts = jeu.objets.filter((o) => o.nature === 'concept' && estRendu(o)).length
|
||||
const nbConcepts = [...lu.rendus.values()].filter((o) => o.nature === 'concept').length
|
||||
|
||||
// ── Configuration de la vue fiches : nature, échelle, porteur, couche ──
|
||||
const NATURES: Nature[] = ['concept', 'texte', 'organisation', 'outil']
|
||||
// Ordre d'affichage des natures : les concepts d'abord (le vocabulaire les tient dans l'ordre du schéma).
|
||||
const ORDRE_NATURES: Nature[] = ['concept', ...NATURES.filter((n) => n !== 'concept')]
|
||||
const presentes = (dim: string) => new Set(fiches.flatMap((f) => f.etiquettes?.[dim] ?? []))
|
||||
const config: ConfigVueFiches = {
|
||||
dimensions: [
|
||||
{ cle: 'nature', libelle: 'Nature', variante: 'fonction', valeurs: NATURES.filter((n) => presentes('nature').has(n)).map((n) => ({ valeur: n, libelle: LIBELLES_NATURE[n] })) },
|
||||
{ cle: 'echelle', libelle: 'Échelle', variante: 'echelle', valeurs: ['S', 'M', 'XL'].filter((e) => presentes('echelle').has(e)).map((e) => ({ valeur: e, libelle: e })) },
|
||||
{ cle: 'nature', libelle: 'Nature', variante: 'fonction', valeurs: ORDRE_NATURES.filter((n) => presentes('nature').has(n)).map((n) => ({ valeur: n, libelle: LIBELLES_NATURE[n] })) },
|
||||
{ cle: 'echelle', libelle: 'Échelle', variante: 'echelle', valeurs: ECHELLES.filter((e) => presentes('echelle').has(e)).map((e) => ({ valeur: e, libelle: e })) },
|
||||
{
|
||||
cle: 'porteur',
|
||||
libelle: 'Porteur',
|
||||
@@ -182,7 +216,7 @@ const config: ConfigVueFiches = {
|
||||
.filter((o) => o.nature === 'organisation' && estRendu(o) && presentes('porteur').has(valeurPorteur(o.id)))
|
||||
.map((o) => ({ valeur: valeurPorteur(o.id), libelle: o.nom_canonique })),
|
||||
},
|
||||
{ cle: 'couche', libelle: 'Couche', variante: 'echelle', valeurs: ['socle', 'actualite'].filter((c) => presentes('couche').has(c)).map((c) => ({ valeur: c, libelle: c === 'socle' ? 'Socle' : 'Actualité' })) },
|
||||
{ cle: 'couche', libelle: 'Couche', variante: 'echelle', valeurs: COUCHES.filter((c) => presentes('couche').has(c)).map((c) => ({ valeur: c, libelle: LIBELLES_COUCHE[c] })) },
|
||||
],
|
||||
tris: ['nom', 'recent', 'pertinence'],
|
||||
triDefaut: 'nom',
|
||||
@@ -192,47 +226,39 @@ const config: ConfigVueFiches = {
|
||||
etats: ['carte', 'mixte', 'fiches'],
|
||||
}
|
||||
|
||||
const vf = useVueFiches(fiches, config)
|
||||
// Retour de Jules du 27/10 n° 4 : « je laisserais l’échelle du graphe par défaut ». L’URL (vue=) prime.
|
||||
const vf = useVueFiches(fiches, config, { etatDefaut: 'carte' })
|
||||
|
||||
// ── Détail ──
|
||||
const LIBELLES_RELATION: Record<string, [string, string]> = {
|
||||
extrait_de: ['extrait de', 'source de'],
|
||||
porte_par: ['porté par', 'porte'],
|
||||
republication_de: ['republication de', 'republié par'],
|
||||
meme_objet_que: ['même objet que', 'même objet que'],
|
||||
recoupe: ['recoupe', 'recoupe'],
|
||||
precise: ['précise', 'précisé par'],
|
||||
contredit: ['contredit', 'contredit par'],
|
||||
condition_de: ['condition de', 'a pour condition'],
|
||||
homonyme_de: ['homonyme de, fusion refusée :', 'homonyme de, fusion refusée :'],
|
||||
// ── Détail : l'objet de la fiche ouverte, typé, lu une fois par fiche (utils/connaissances/lire.ts) ──
|
||||
const objetOuvert = computed<ObjetConnaissance | undefined>(() => (vf.ficheOuverte ? lu.rendus.get(String(vf.ficheOuverte.id)) : undefined))
|
||||
const sourcesOuvertes = computed(() => (objetOuvert.value ? sourcesDe(lu, objetOuvert.value.id) : []))
|
||||
/** Une ligne de l'en-tête par type de relation (dans un sens), les cibles à la suite. */
|
||||
const relationsOuvertes = computed(() => (objetOuvert.value ? relationsParLibelle(lu, objetOuvert.value.id) : []))
|
||||
/**
|
||||
* Porteurs, sauf l'objet lui-même (une organisation se porte elle-même : rien à dire) et sauf
|
||||
* ceux qu'une relation « porté par » nomme déjà, avec sa provenance, dans l'en-tête.
|
||||
*/
|
||||
const porteursOuverts = computed(() => {
|
||||
const o = objetOuvert.value
|
||||
if (!o) return []
|
||||
const dejaDits = new Set(relationsOuvertes.value.flatMap((g) => g.relations).filter((r) => r.type === 'porte_par' && r.sens === 0).map((r) => r.cible.id))
|
||||
return porteursDe(lu, o).filter((p) => p.id !== o.id && !dejaDits.has(p.id))
|
||||
})
|
||||
const dettesOuvertes = computed(() => dettesDe(objetOuvert.value))
|
||||
const vacancesOuvertes = computed(() => vacancesDe(objetOuvert.value))
|
||||
/** L'étage du fond existe dès qu'il a une ligne à dire. */
|
||||
const aUnFond = computed(() => {
|
||||
const o = objetOuvert.value
|
||||
return !!o && (!!o.credit || o.nature === 'concept' || !!o.licence || dettesOuvertes.value.length > 0 || vacancesOuvertes.value.length > 0)
|
||||
})
|
||||
/** Clé d'une ligne de relation : « condition de » → « Condition de » ; « homonyme de, fusion refusée : » perd ses deux-points. */
|
||||
const libelleLigne = (l: string) => {
|
||||
const s = l.replace(/\s*:$/, '')
|
||||
return s.charAt(0).toUpperCase() + s.slice(1)
|
||||
}
|
||||
|
||||
/** Sources d'un concept (extrait_de), publiées ou non : une source à creuser se dit, elle ne disparaît pas. */
|
||||
function sourcesDe(id: string | number) {
|
||||
return jeu.relations
|
||||
.filter((r) => r.type === 'extrait_de' && r.de === String(id))
|
||||
.map((r) => objetDe(r.vers))
|
||||
.filter((o): o is ObjetCouche & Record<string, any> => !!o && o.etat !== 'ecarte')
|
||||
}
|
||||
|
||||
/** Relations de l'objet, sauf ses sources (au-dessus) et le registre (une autre base, pas un nœud de la couche). */
|
||||
function relationsDe(id: string | number) {
|
||||
const i = String(id)
|
||||
const out: { cle: string; libelle: string; cible: (ObjetCouche & Record<string, any>) | undefined; provenance: string }[] = []
|
||||
jeu.relations.forEach((r, k) => {
|
||||
if (r.etat === 'ecarte' || r.type === 'renvoie_a' || !LIBELLES_RELATION[r.type]) return
|
||||
if (r.de === i && r.type === 'extrait_de') return
|
||||
const sens = r.de === i ? 0 : r.vers === i ? 1 : -1
|
||||
if (sens < 0) return
|
||||
const cible = objetDe(sens === 0 ? r.vers : r.de)
|
||||
if (!cible || cible.etat === 'ecarte') return
|
||||
out.push({ cle: `${k}`, libelle: LIBELLES_RELATION[r.type][sens], cible, provenance: r.provenance })
|
||||
})
|
||||
return out
|
||||
}
|
||||
|
||||
const dettesDe = (id: string | number) => (objetDe(id)?.dettes_non_creditees as string[] | undefined) ?? []
|
||||
const vacancesDe = (id: string | number) => (objetDe(id)?.vacances as { enonce: string; date: string }[] | undefined) ?? []
|
||||
/** Date d'une source, entre parenthèses dans l'en-tête (jamais de point médian). */
|
||||
const dateSource = (s: ObjetConnaissance) =>
|
||||
s.date_original ? (s.date_original_nature === 'vue' ? `en ligne au ${dateFr(s.date_original)}` : dateFr(s.date_original)) : 'date à relever'
|
||||
|
||||
const MOIS = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre']
|
||||
function dateFr(d: unknown): string {
|
||||
@@ -269,12 +295,12 @@ useSeoMeta({
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
gap: var(--space-2xs, 0.25rem) var(--space-md);
|
||||
gap: var(--space-2xs) var(--space-md);
|
||||
padding: var(--space-xs) var(--space-md);
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: var(--surface);
|
||||
}
|
||||
.cn-tete__titre { margin: 0; font-size: 1.25rem; font-weight: var(--fw-bold); line-height: 1.25; }
|
||||
.cn-tete__titre { margin: 0; font-size: var(--fs-lg); font-weight: var(--fw-bold); line-height: 1.25; }
|
||||
.cn-bandeau {
|
||||
flex: 1 1 32rem;
|
||||
min-width: 0;
|
||||
@@ -287,38 +313,47 @@ useSeoMeta({
|
||||
.cn-bandeau a:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--radius-sm); }
|
||||
.cn-vue { flex: 1 1 0; min-height: 0; min-width: 0; }
|
||||
|
||||
.cn-sr {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* ── Fiche d'un objet ── */
|
||||
/* ── Fiche d'un objet : trois étages ── */
|
||||
.cf { min-width: 0; overflow-wrap: anywhere; }
|
||||
.cf p { margin: 0; }
|
||||
.cf__nature {
|
||||
font-size: var(--fs-xs, 0.75rem);
|
||||
font-weight: var(--fw-semibold);
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
color: color-mix(in srgb, var(--text) 78%, transparent);
|
||||
/* Texte atténué : DESIGN-SYSTEM §Texte atténué (78 %, pas --text-muted ni opacity) */
|
||||
.cf { --cf-attenue: color-mix(in srgb, var(--text) 78%, transparent); }
|
||||
.cf__titre { margin: 0 0 var(--space-xs); font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: var(--lh-tight); }
|
||||
|
||||
/* ① En-tête de propriétés : dense, atténué, une grille clé / valeur */
|
||||
.cf__props {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
|
||||
gap: 0 var(--space-sm);
|
||||
margin: 0 0 var(--space-md);
|
||||
padding-bottom: var(--space-xs);
|
||||
border-bottom: 1px solid var(--border);
|
||||
font-size: var(--fs-sm);
|
||||
line-height: 1.45;
|
||||
color: var(--cf-attenue);
|
||||
}
|
||||
.cf__titre { margin: 2px 0 var(--space-xs); font-size: 1.25rem; font-weight: var(--fw-bold); line-height: 1.25; }
|
||||
.cf__chips { margin-bottom: var(--space-sm); }
|
||||
.cf__definition { font-size: 1rem; line-height: 1.55; }
|
||||
.cf__mention { margin-top: 2px !important; font-size: var(--fs-xs, 0.75rem); color: color-mix(in srgb, var(--text) 78%, transparent); }
|
||||
.cf__faits { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px var(--space-sm); margin: 0; font-size: var(--fs-sm); }
|
||||
.cf__faits dt { font-weight: var(--fw-semibold); }
|
||||
.cf__faits dd { margin: 0; min-width: 0; }
|
||||
.cf__bloc { margin-top: var(--space-md); }
|
||||
.cf__soustitre { margin: 0 0 var(--space-2xs, 0.25rem); font-size: var(--fs-sm); font-weight: var(--fw-bold); }
|
||||
.cf__liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2xs, 0.25rem); font-size: var(--fs-sm); line-height: 1.45; }
|
||||
.cf__props dt,
|
||||
.cf__props dd { margin: 0; min-width: 0; padding: var(--space-2xs) 0; }
|
||||
.cf__props dt { max-width: 9rem; font-weight: var(--fw-medium); }
|
||||
.cf__props dd { color: var(--text); }
|
||||
/* Une clé s'aligne sur la première cible de sa ligne (bouton de 44 px, chip de 32 px) */
|
||||
.cf__k { display: flex; align-items: center; align-self: start; }
|
||||
.cf__k--cible { min-height: calc(44px + 2 * var(--space-2xs)); padding-block: 0 !important; }
|
||||
.cf__k--chips { min-height: calc(32px + 2 * var(--space-2xs)); }
|
||||
.cf__props dd:has(> .cf__cibles) { padding-block: 0; }
|
||||
.cf__props dd:has(> .cf__chips) { padding-block: var(--space-2xs); }
|
||||
.cf__cibles { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--space-sm); }
|
||||
.cf__cibles--colonne { flex-direction: column; align-items: flex-start; }
|
||||
/* Une cible par élément de liste, en ligne : le bouton (44 px) donne sa hauteur à la ligne, la date et le lien suivent comme du texte */
|
||||
.cf__cibles > li { display: block; }
|
||||
.cf__cibles > li > * + * { margin-left: var(--space-2xs); }
|
||||
.cf__cible-texte { color: var(--cf-attenue); }
|
||||
.cf__vers {
|
||||
padding: var(--space-2xs) 0;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 44px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
background: none;
|
||||
color: var(--text);
|
||||
@@ -330,29 +365,43 @@ useSeoMeta({
|
||||
cursor: pointer;
|
||||
}
|
||||
.cf__lien { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
|
||||
.cf__lien--ext { margin-left: 4px; }
|
||||
.cf__lien--cible { display: inline-flex; align-items: center; min-height: 44px; }
|
||||
.cf__source .cf__lien--cible { display: inline; min-height: 0; }
|
||||
.cf__vers:focus-visible,
|
||||
.cf__lien:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--radius-sm); }
|
||||
.cf__discret { color: color-mix(in srgb, var(--text) 78%, transparent); }
|
||||
.cf__type { margin-right: 4px; }
|
||||
/* Provenance d'une relation : bordure seule, pleine = la source l'énonce, tirets = AEP la pose */
|
||||
.cf__provenance {
|
||||
display: inline-block;
|
||||
margin-left: 6px;
|
||||
padding: 0 6px;
|
||||
border-radius: 999px;
|
||||
padding: 0 var(--space-2xs);
|
||||
border-radius: var(--radius-full);
|
||||
border: 1px solid var(--border-strong, var(--border));
|
||||
font-size: var(--fs-xs, 0.75rem);
|
||||
color: color-mix(in srgb, var(--text) 82%, transparent);
|
||||
font-size: var(--fs-xs);
|
||||
line-height: 1.4;
|
||||
color: var(--cf-attenue);
|
||||
}
|
||||
.cf__provenance--curation { border-style: dashed; }
|
||||
.cf__registre { margin-top: var(--space-sm) !important; font-size: var(--fs-sm); }
|
||||
.cf__credit { font-size: var(--fs-sm); line-height: 1.5; }
|
||||
.cf__dettes-titre { margin-top: var(--space-xs) !important; font-weight: var(--fw-semibold); }
|
||||
.cf__dettes { margin: 2px 0 0; padding-left: 1.1rem; }
|
||||
.cf__props code { font-size: var(--fs-xs); }
|
||||
|
||||
/* ② Le texte : corps principal, l'étage qu'on lit ; plusieurs paragraphes demain */
|
||||
.cf__texte { max-width: 65ch; font-size: var(--fs-base); line-height: var(--lh-base); }
|
||||
.cf .cf__texte > * + * { margin-top: var(--space-sm); }
|
||||
.cf__mention { margin-top: var(--space-2xs) !important; font-size: var(--fs-xs); color: var(--cf-attenue); }
|
||||
|
||||
/* ③ Le fond : petit, atténué, replié */
|
||||
.cf__fond { margin-top: var(--space-lg); padding-top: var(--space-xs); border-top: 1px solid var(--border); font-size: var(--fs-xs); line-height: 1.5; color: var(--cf-attenue); }
|
||||
.cf__fond-titre {
|
||||
padding-block: calc((44px - 1.5em) / 2);
|
||||
font-weight: var(--fw-medium);
|
||||
cursor: pointer;
|
||||
list-style-position: inside;
|
||||
}
|
||||
.cf__fond-titre:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--radius-sm); }
|
||||
.cf__fond-corps { display: flex; flex-direction: column; gap: var(--space-2xs); padding-bottom: var(--space-xs); }
|
||||
.cf__fond-sous { margin-top: var(--space-xs) !important; font-weight: var(--fw-semibold); }
|
||||
.cf__fond-liste { margin: 0; padding-left: var(--space-md); }
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.cn-tete { padding: var(--space-2xs, 0.25rem) var(--space-sm); }
|
||||
.cn-tete__titre { font-size: 1.1rem; }
|
||||
.cn-bandeau { font-size: var(--fs-xs, 0.75rem); }
|
||||
.cn-tete { padding: var(--space-2xs) var(--space-sm); }
|
||||
.cn-bandeau { font-size: var(--fs-xs); }
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* Tests de la couche de connaissances partagées (B18 M5) : schéma, validateur, fixture du
|
||||
* lot 2, jointure registre_id. Charge les VRAIS utils/connaissances/*.ts via jiti (même
|
||||
* patron que test-seo.mjs). Aucun accès réseau, aucune lecture du vault.
|
||||
* B19b M4 : vocabulaire égal au schéma, géométrie du graphe (graphe.ts), lecture d’une fiche (lire.ts).
|
||||
* Usage : node scripts/test-connaissances.mjs
|
||||
*/
|
||||
|
||||
@@ -101,7 +102,7 @@ for (const [type, de, vers, prov] of TABLE) {
|
||||
// Rien de copié : définitions dans nos mots, rien du vault
|
||||
for (const c of fixture.objets.filter((o) => o.nature === 'concept')) {
|
||||
const k = V.plusLongueSuiteCommune(c.definition_courte, c.libelle_source)
|
||||
ok(k <= 12, `${c.id} : aucune suite de plus de douze mots commune avec libelle_source (${k})`)
|
||||
ok(k <= V.MOTS_COPIE_MAX, `${c.id} : aucune suite de plus de ${V.MOTS_COPIE_MAX} mots commune avec libelle_source (${k})`)
|
||||
}
|
||||
const texte = JSON.stringify(fixture)
|
||||
ok(!/\[\[|Dropbox|IPCJRA|\.md\b|1 PROJETS|2 CASQUETTES/.test(texte), 'fixture : aucune note ni chemin du vault')
|
||||
@@ -194,6 +195,7 @@ const A = await jiti.import(join(racine, 'composables', 'useFicheAdapter.ts'))
|
||||
ok(t.kind === 'texte' && t.resume.includes('Les signaux faibles') && t.resume.includes('Holosapiens'), 'adaptateur : résumé d’un objet = titre et porteur', t.resume)
|
||||
ok(JSON.stringify(t.etiquettes.echelle) === JSON.stringify(['XL']), 'adaptateur : échelles d’une source = celles de ses concepts (projection)', JSON.stringify(t.etiquettes.echelle))
|
||||
ok(fiches.find((f) => f.id === 'org:holosapiens').etiquettes.porteur[0] === 'holosapiens', 'adaptateur : une organisation se porte elle-même')
|
||||
ok(fiches.every((f) => !f.resume.includes('·')), 'adaptateur : aucun point médian dans les résumés (Lois /atis-design, B19b)', fiches.map((f) => f.resume).filter((r) => r.includes('·')).join(' | '))
|
||||
|
||||
const g = A.grapheConnaissances(fixture)
|
||||
ok(g.noeuds.length === fiches.length, 'graphe : un nœud par fiche')
|
||||
@@ -201,10 +203,100 @@ const A = await jiti.import(join(racine, 'composables', 'useFicheAdapter.ts'))
|
||||
ok(!g.liens.some((l) => l.type === 'renvoie_a' || l.type === 'homonyme_de'), 'graphe : ni renvoie_a ni homonyme vers un non-publié')
|
||||
ok(g.noeuds.every((x) => !('x' in x) && !('y' in x)), 'graphe : aucune position dans les données')
|
||||
// Le croisement architectures invisibles ↔ matrice (curation, Jules 08/10) devient un lien du graphe dès que cpt:matrice-aep est publié ; a_trier le 27/10 : le lien attend.
|
||||
const matriceRendue = A.estRendu(objet(fixture, 'cpt:matrice-aep'))
|
||||
const matriceRendue = objet(fixture, 'cpt:matrice-aep').etat === 'publie'
|
||||
ok(g.liens.some((l) => l.type === 'recoupe' && l.de === 'cpt:architectures-invisibles' && l.vers === 'cpt:matrice-aep') === matriceRendue, `graphe : le croisement architectures invisibles ↔ matrice est un lien si et seulement si la matrice est rendue (${matriceRendue})`)
|
||||
ok(g.liens.some((l) => l.type === 'condition_de' && l.de === 'cpt:holoptisme' && l.vers === 'cpt:economie-du-don'), 'graphe : holoptisme → économie du don (source) est un lien')
|
||||
}
|
||||
|
||||
// ── B19b M4 : le vocabulaire, écrit une fois, égal au schéma ────
|
||||
const W = await jiti.import(join(racine, 'utils', 'connaissances', 'vocabulaire.ts'))
|
||||
const trieCles = (o) => Object.fromEntries(Object.keys(o).sort().map((k) => [k, o[k]]))
|
||||
{
|
||||
const memes = (a, b) => JSON.stringify([...a]) === JSON.stringify([...b])
|
||||
ok(memes(W.NATURES, D.objet.properties.nature.enum), 'vocabulaire : natures = schéma', JSON.stringify(W.NATURES))
|
||||
ok(memes(W.ECHELLES, D.objet.properties.echelles.items.enum), 'vocabulaire : échelles = schéma', JSON.stringify(W.ECHELLES))
|
||||
ok(memes(W.COUCHES, D.objet.properties.couche.enum), 'vocabulaire : couches = schéma', JSON.stringify(W.COUCHES))
|
||||
ok(memes(W.ETATS, D.etat.enum) && W.ETATS.includes(W.ETAT_RENDU), 'vocabulaire : états = schéma, l’état rendu en fait partie', JSON.stringify(W.ETATS))
|
||||
// Préfixes : le motif d'identifiant du schéma, et le `allOf` nature → ^préfixe:
|
||||
const duMotif = D.id.pattern.match(/^\^\(([^)]+)\)/)[1].split('|')
|
||||
const duAllOf = Object.fromEntries(D.objet.allOf.map((r) => [r.if.properties.nature.const, r.then.properties.id.pattern.replace(/^\^/, '').replace(/:$/, '')]))
|
||||
ok(memes(Object.values(W.PREFIXES).sort(), [...duMotif].sort()), 'vocabulaire : préfixes = motif d’identifiant du schéma', duMotif.join(','))
|
||||
ok(JSON.stringify(trieCles(W.PREFIXES)) === JSON.stringify(trieCles(duAllOf)), 'vocabulaire : préfixe de chaque nature = allOf du schéma', JSON.stringify(duAllOf))
|
||||
ok(W.NATURES.every((x) => W.LIBELLES_NATURE[x]) && W.COUCHES.every((c) => W.LIBELLES_COUCHE[c]), 'vocabulaire : un libellé par nature et par couche')
|
||||
ok(V.MOTS_COPIE_MAX === W.MOTS_COPIE_MAX && V.PREFIXES === W.PREFIXES && V.NATURES === W.NATURES, 'vocabulaire : le validateur réexporte le même vocabulaire (aucune recopie)')
|
||||
ok(W.RE_PREFIXE.test('cpt:x') && W.RE_PREFIXE.test('org:aep') && !W.RE_PREFIXE.test('registre:x'), 'vocabulaire : motif de préfixe (cpt:, org: oui ; registre: non)')
|
||||
}
|
||||
|
||||
// ── B19b M4 : géométrie du graphe (utils/connaissances/graphe.ts) ──
|
||||
const G = await jiti.import(join(racine, 'utils', 'connaissances', 'graphe.ts'))
|
||||
{
|
||||
const { noeuds, liens } = A.grapheConnaissances(fixture)
|
||||
const prin = new Set(['concept'])
|
||||
const p1 = G.disposer(noeuds, liens, prin)
|
||||
const p2 = G.disposer(copie(noeuds), copie(liens), prin)
|
||||
const plat = (p) => JSON.stringify([...p].map(([id, { x, y }]) => [id, x, y]))
|
||||
ok(p1.size === noeuds.length && plat(p1) === plat(p2), `graphe : graine fixe, deux calculs = mêmes positions (${p1.size} nœuds)`)
|
||||
const b = G.boite(p1.values())
|
||||
ok(Math.abs(Math.max(b.x1 - b.x0, b.y1 - b.y0) - 1) < 1e-9 && Math.abs(b.x0 + b.x1) < 1e-9 && Math.abs(b.y0 + b.y1) < 1e-9, 'graphe : dessin centré, d’étendue 1', JSON.stringify(b))
|
||||
ok([...p1.values()].every((p) => Number.isFinite(p.x) && Number.isFinite(p.y)), 'graphe : aucune position infinie ou NaN')
|
||||
ok(G.disposerEnCache(noeuds, liens, prin) === G.disposerEnCache(copie(noeuds), copie(liens), prin), 'graphe : cache par signature (même graphe, même objet rendu)')
|
||||
ok(plat(G.disposerEnCache(noeuds, liens, prin)) === plat(p1), 'graphe : le cache rend les positions de disposer')
|
||||
ok(G.disposer([], [], prin).size === 0 && !Number.isFinite(G.boite([]).x0), 'graphe : graphe vide → aucune position ; boîte vide → bornes infinies')
|
||||
const L = [
|
||||
{ de: 'a', vers: 'b', type: 't', provenance: 'source' },
|
||||
{ de: 'b', vers: 'c', type: 't', provenance: 'source' },
|
||||
{ de: 'd', vers: 'c', type: 't', provenance: 'curation' },
|
||||
]
|
||||
const tri = (s) => [...s].sort().join(',')
|
||||
ok(tri(G.voisinage(L, 'a', 1)) === 'a,b', 'voisinage : un pas (le nœud compris)')
|
||||
ok(tri(G.voisinage(L, 'a', 2)) === 'a,b,c', 'voisinage : deux pas')
|
||||
ok(tri(G.voisinage(L, 'c', 1)) === 'b,c,d', 'voisinage : les liens se suivent dans les deux sens')
|
||||
ok(G.voisinage(L, 'a', 'tout') === null, 'voisinage : « tout » = null (tout le graphe)')
|
||||
ok(tri(G.voisinage(L, 'z', 2)) === 'z', 'voisinage : nœud isolé → lui seul')
|
||||
ok(tri(G.voisinage(liens, 'cpt:holoptisme', 1)) === tri(['cpt:holoptisme', 'txt:hs-holo-sapiens-fr', 'txt:hs-economie-du-don', 'cpt:economie-du-don', 'cpt:quatre-formes-ic']), 'voisinage : holoptisme à un pas = ses deux sources et ses deux concepts liés', tri(G.voisinage(liens, 'cpt:holoptisme', 1)))
|
||||
}
|
||||
|
||||
// ── B19b M4 : lecture d'une fiche (utils/connaissances/lire.ts) ──
|
||||
const R = await jiti.import(join(racine, 'utils', 'connaissances', 'lire.ts'))
|
||||
{
|
||||
const l = R.lecture(fixture)
|
||||
ok(R.lecture(fixture) === l, 'lecture : l’index est construit une fois par jeu (mémorisé)')
|
||||
ok(l.rendus.size === fixture.objets.filter((o) => o.etat === 'publie').length && [...l.rendus.values()].every(R.estRendu), 'lecture : rendus = objets publiés')
|
||||
const ids = (xs) => xs.map((x) => x.id).sort().join(',')
|
||||
ok(ids(R.sourcesDe(l, 'cpt:holoptisme')) === 'txt:hs-economie-du-don,txt:hs-holo-sapiens-fr', 'sourcesDe : les deux sources d’holoptisme', ids(R.sourcesDe(l, 'cpt:holoptisme')))
|
||||
ok(R.sourcesDe(l, 'cpt:economie-du-don').some((s) => s.etat === 'a_creuser'), 'sourcesDe : une source à creuser se dit (elle ne disparaît pas)')
|
||||
{
|
||||
const j = copie(fixture)
|
||||
objet(j, 'txt:hs-economie-du-don').etat = 'ecarte'
|
||||
ok(ids(R.sourcesDe(R.lecture(j), 'cpt:holoptisme')) === 'txt:hs-holo-sapiens-fr', 'sourcesDe : une source écartée n’est pas dite')
|
||||
}
|
||||
const rel = (id) => R.relationsDe(l, id).map((r) => `${r.libelle}>${r.cible.id}>${r.provenance}`)
|
||||
const h = rel('cpt:holoptisme')
|
||||
ok(h.includes('condition de>cpt:economie-du-don>source') && h.includes('précise>cpt:quatre-formes-ic>curation'), 'relationsDe : sens direct, libellé et provenance', h.join(' | '))
|
||||
ok(!h.some((x) => x.startsWith('extrait de')), 'relationsDe : les sources restent dans sourcesDe (pas en double)')
|
||||
ok(rel('cpt:economie-du-don').includes('a pour condition>cpt:holoptisme>source'), 'relationsDe : sens inverse (libellé de l’autre bout)', rel('cpt:economie-du-don').join(' | '))
|
||||
ok(rel('txt:hs-holo-sapiens-fr').includes('source de>cpt:holoptisme>source'), 'relationsDe : un texte dit de quels concepts il est la source', rel('txt:hs-holo-sapiens-fr').join(' | '))
|
||||
ok(rel('cpt:signaux-faibles-noubel').some((x) => x.startsWith('homonyme de, fusion refusée :>cpt:signaux-faibles-ansoff')), 'relationsDe : homonyme_de libellé « fusion refusée »', rel('cpt:signaux-faibles-noubel').join(' | '))
|
||||
{
|
||||
const j = copie(fixture)
|
||||
j.relations.find((r) => r.type === 'precise' && r.de === 'cpt:holoptisme').etat = 'ecarte'
|
||||
j.relations.push({ type: 'renvoie_a', de: 'cpt:holoptisme', vers: 'registre:P2-18', provenance: 'curation', etat: 'publie' })
|
||||
const r = R.relationsDe(R.lecture(j), 'cpt:holoptisme')
|
||||
ok(!r.some((x) => x.type === 'precise'), 'relationsDe : une relation écartée est ignorée')
|
||||
ok(!r.some((x) => x.type === 'renvoie_a'), 'relationsDe : renvoie_a exclu (le registre, une autre base)')
|
||||
}
|
||||
{
|
||||
const g = R.relationsParLibelle(l, 'cpt:quatre-formes-ic')
|
||||
ok(g.length > 0 && g.every((x) => x.relations.every((r) => r.libelle === x.libelle)) && new Set(g.map((x) => x.libelle)).size === g.length, 'relationsParLibelle : une ligne par libellé', g.map((x) => `${x.libelle}(${x.relations.length})`).join(' '))
|
||||
}
|
||||
ok(R.dettesDe(objet(fixture, 'cpt:holoptisme')).length === 1 && R.dettesDe(undefined).length === 0, 'dettesDe : celles de l’objet ; aucun objet → aucune')
|
||||
{
|
||||
const avecVacance = fixture.objets.find((o) => (o.vacances ?? []).length)
|
||||
ok(!!avecVacance && R.vacancesDe(avecVacance).length === avecVacance.vacances.length && R.vacancesDe(undefined).length === 0, `vacancesDe : celles de l’objet (${avecVacance?.id}) ; aucun objet → aucune`)
|
||||
}
|
||||
ok(R.porteursDe(l, objet(fixture, 'cpt:holoptisme')).map((p) => p.id).join() === 'org:holosapiens' && R.porteursDe(l, objet(fixture, 'org:holosapiens'))[0].id === 'org:holosapiens', 'porteursDe : l’organisation rendue ; une organisation se porte elle-même')
|
||||
ok(Object.keys(R.LIBELLES_RELATION).every((t) => D.relation.properties.type.enum.includes(t)) && !('renvoie_a' in R.LIBELLES_RELATION), 'LIBELLES_RELATION : des types du schéma, sans renvoie_a')
|
||||
}
|
||||
|
||||
console.log(`\n${n - echecs}/${n} OK${echecs ? ` · ${echecs} ÉCHEC(S)` : ''}`)
|
||||
process.exit(echecs ? 1 : 0)
|
||||
|
||||
@@ -243,5 +243,29 @@ const qMot = V.ecrireQuery(eMot, cfgMots, { tab: 'partir-de-soi', acces: 'don-li
|
||||
ok(qMot.tab === 'partir-de-soi' && qMot.fiche === 'quete-de-sens' && qMot.acces === 'don-libre' && qMot.format === 'film,retraite', 'tab= et fiche= survivent à l’écriture des filtres')
|
||||
ok(V.queryAvecFiche({ tab: 'partir-de-soi', vue: 'carte' }, 'sante-mentale').tab === 'partir-de-soi' && V.queryAvecFiche({ tab: 'partir-de-soi', fiche: 'x' }, null).tab === 'partir-de-soi', 'tab= survit à l’ouverture et à la fermeture d’une fiche')
|
||||
|
||||
// ── B19b : état par défaut (option de useVueFiches) et navigation linéaire (prop de VueFiches) ──
|
||||
{
|
||||
const racine = join(__dirname, '..')
|
||||
const jitiAlias = createJiti(import.meta.url, { alias: { '~': racine } })
|
||||
const U = await jitiAlias.import(join(racine, 'composables', 'useVueFiches.ts'))
|
||||
const trois = ['carte', 'mixte', 'fiches']
|
||||
const LARGEURS = [null, 'telephone', 'tablette', 'ordinateur']
|
||||
// Sans etatDefaut : le comportement d'avant, case par case (/, /agences, /outils n'en passent pas)
|
||||
const attendu = { null: 'auto', telephone: 'fiches', tablette: 'fiches', ordinateur: 'mixte' }
|
||||
ok(LARGEURS.every((l) => U.vueRendue(null, trois, l, false) === attendu[String(l)]), 'sans etatDefaut, sans vue= : auto avant montage, Fiches sous 1024, Mixte au-delà (inchangé)')
|
||||
ok(U.vueRendue(null, trois, 'ordinateur', true) === 'carte' && U.vueRendue(null, ['carte', 'fiches'], null, false) === 'fiches', 'sans etatDefaut : liste repliée → Carte ; page sans Mixte → Fiches (inchangé)')
|
||||
// Avec etatDefaut: 'carte' (/connaissances, B19b)
|
||||
ok(LARGEURS.every((l) => U.vueRendue(null, trois, l, false, 'carte') === 'carte'), 'etatDefaut carte, sans vue= : le graphe à toutes les largeurs, dès le rendu serveur')
|
||||
ok(U.vueRendue(null, trois, 'ordinateur', false, 'carte') === 'carte' && U.vueRendue(null, trois, 'ordinateur', true, 'carte') === 'carte', 'etatDefaut carte : le repli de session ne change rien')
|
||||
ok(U.vueRendue('mixte', trois, 'ordinateur', false, 'carte') === 'mixte' && U.vueRendue('fiches', trois, null, false, 'carte') === 'fiches', 'etatDefaut carte : l’URL prime (vue=mixte, vue=fiches)')
|
||||
ok(U.vueRendue('mixte', trois, null, false, 'carte') === 'auto' && U.vueRendue('mixte', trois, 'telephone', false, 'carte') === 'fiches', 'etatDefaut carte, vue=mixte : auto avant montage, Fiches au téléphone (inchangé)')
|
||||
ok(U.vueRendue(null, ['mixte', 'fiches'], 'ordinateur', false, 'carte') === 'mixte', 'etatDefaut hors des états de la page : ignoré')
|
||||
// Prop navigationLineaire : lue dans le source (le rendu se constate au curl, RECAP B19b)
|
||||
const { readFileSync } = await import('node:fs')
|
||||
const src = readFileSync(join(racine, 'components', 'VueFiches.vue'), 'utf8')
|
||||
ok(/<nav v-if="vf\.position && navigationLineaire" class="vf-detail__nav"/.test(src) && /\{ navigationLineaire: true \}/.test(src), 'VueFiches : Précédente / Suivante sous navigationLineaire, vrai par défaut (/, /agences, /outils inchangés)')
|
||||
ok(/e\.key === 'ArrowLeft'\) props\.vf\.fichePrecedente\(\)/.test(src) && /if \(dx < 0\) props\.vf\.ficheSuivante\(\)/.test(src), 'VueFiches : les flèches ← → et le balayage ne dépendent pas de navigationLineaire')
|
||||
}
|
||||
|
||||
console.log(`\n${n - fail}/${n}`)
|
||||
process.exit(fail ? 1 : 0)
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
/**
|
||||
* graphe — B19b M4. La géométrie de `GrapheConnaissances`, sortie du `.vue` (DESIGN-SYSTEM
|
||||
* §Vue fiches : la logique pure vit dans `utils/`) et testée par
|
||||
* `scripts/test-connaissances.mjs`. Fonctions pures, mêmes signatures qu'en B19 ; aucune
|
||||
* connaissance de la couche, de la vue fiches ni du DOM : B9 réécrit les reprend telles quelles.
|
||||
*
|
||||
* - `disposer` : force simple à graine fixe, positions dans un repère sans unité, centré,
|
||||
* d'étendue 1 (aucune position en données) ;
|
||||
* - `disposerEnCache` : la même, mémorisée par signature du graphe (une fois par processus) ;
|
||||
* - `voisinage` : identifiants à `pas` liens au plus d'un nœud (graphe local d'Obsidian) ;
|
||||
* - `boite` : boîte englobante d'un ensemble de points, une seule écriture pour le dessin et la caméra.
|
||||
*/
|
||||
|
||||
/** Un nœud : `kind` dit sa forme (principal si dans `kindsPrincipaux`, sinon secondaire). */
|
||||
export interface NoeudGraphe { id: string; libelle: string; kind: string; poids?: number }
|
||||
export interface LienGraphe { de: string; vers: string; type: string; provenance: string }
|
||||
export type Pas = 1 | 2 | 'tout'
|
||||
export type Pt = { x: number; y: number }
|
||||
export interface Boite { x0: number; x1: number; y0: number; y1: number }
|
||||
|
||||
/** Boîte englobante ; vide = bornes infinies (`Number.isFinite(b.x0)` est faux). */
|
||||
export function boite(points: Iterable<Pt>): Boite {
|
||||
let x0 = Infinity, x1 = -Infinity, y0 = Infinity, y1 = -Infinity
|
||||
for (const p of points) { x0 = Math.min(x0, p.x); x1 = Math.max(x1, p.x); y0 = Math.min(y0, p.y); y1 = Math.max(y1, p.y) }
|
||||
return { x0, x1, y0, y1 }
|
||||
}
|
||||
|
||||
/** PRNG à graine fixe (mulberry32) : même graphe, même dessin, au serveur comme au navigateur. */
|
||||
function alea(graine: number) {
|
||||
let a = graine >>> 0
|
||||
return () => {
|
||||
a = (a + 0x6d2b79f5) >>> 0
|
||||
let t = a
|
||||
t = Math.imul(t ^ (t >>> 15), t | 1)
|
||||
t ^= t + Math.imul(t ^ (t >>> 7), t | 61)
|
||||
return ((t ^ (t >>> 14)) >>> 0) / 4294967296
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Force simple (Fruchterman-Reingold), graine fixe, nombre de pas fixe : positions dans un
|
||||
* repère sans unité, centré, d'étendue 1. Fonction pure de (nœuds, liens, principaux).
|
||||
*/
|
||||
export function disposer(noeuds: NoeudGraphe[], liens: LienGraphe[], principaux: Set<string>): Map<string, Pt> {
|
||||
const n = noeuds.length
|
||||
const pos = new Map<string, Pt>()
|
||||
if (!n) return pos
|
||||
const rnd = alea(0x9e3779b9)
|
||||
const index = new Map(noeuds.map((x, i) => [x.id, i]))
|
||||
const aretes = liens
|
||||
.map((l) => [index.get(l.de), index.get(l.vers)] as const)
|
||||
.filter((a): a is readonly [number, number] => a[0] != null && a[1] != null && a[0] !== a[1])
|
||||
const voisins: number[][] = noeuds.map(() => [])
|
||||
for (const [a, b] of aretes) { voisins[a].push(b); voisins[b].push(a) }
|
||||
|
||||
// Départ : les principaux en cercle, chaque secondaire au barycentre de ses voisins principaux.
|
||||
const prin = noeuds.map((x, i) => (principaux.has(x.kind) ? i : -1)).filter((i) => i >= 0)
|
||||
const X = new Float64Array(n)
|
||||
const Y = new Float64Array(n)
|
||||
prin.forEach((i, k) => {
|
||||
const t = (2 * Math.PI * k) / Math.max(prin.length, 1)
|
||||
X[i] = 0.4 * Math.cos(t)
|
||||
Y[i] = 0.4 * Math.sin(t)
|
||||
})
|
||||
noeuds.forEach((x, i) => {
|
||||
if (principaux.has(x.kind)) return
|
||||
const v = voisins[i].filter((j) => principaux.has(noeuds[j].kind))
|
||||
if (v.length) {
|
||||
X[i] = (v.reduce((s, j) => s + X[j], 0) / v.length) * 1.35 + (rnd() - 0.5) * 0.08
|
||||
Y[i] = (v.reduce((s, j) => s + Y[j], 0) / v.length) * 1.35 + (rnd() - 0.5) * 0.08
|
||||
} else {
|
||||
X[i] = (rnd() - 0.5) * 0.9
|
||||
Y[i] = (rnd() - 0.5) * 0.9
|
||||
}
|
||||
})
|
||||
|
||||
const k = 0.9 * Math.sqrt(1 / n)
|
||||
const ITER = 350
|
||||
const dx = new Float64Array(n)
|
||||
const dy = new Float64Array(n)
|
||||
for (let it = 0; it < ITER; it++) {
|
||||
const temp = 0.08 * (1 - it / ITER) + 0.002
|
||||
dx.fill(0)
|
||||
dy.fill(0)
|
||||
for (let i = 0; i < n; i++) {
|
||||
for (let j = i + 1; j < n; j++) {
|
||||
let ex = X[i] - X[j]
|
||||
let ey = Y[i] - Y[j]
|
||||
let d = Math.hypot(ex, ey)
|
||||
if (d < 1e-4) { ex = (rnd() - 0.5) * 1e-3; ey = (rnd() - 0.5) * 1e-3; d = Math.hypot(ex, ey) }
|
||||
const f = (k * k) / d
|
||||
dx[i] += (ex / d) * f; dy[i] += (ey / d) * f
|
||||
dx[j] -= (ex / d) * f; dy[j] -= (ey / d) * f
|
||||
}
|
||||
}
|
||||
for (const [a, b] of aretes) {
|
||||
const ex = X[a] - X[b]
|
||||
const ey = Y[a] - Y[b]
|
||||
const d = Math.max(Math.hypot(ex, ey), 1e-4)
|
||||
const f = (d * d) / k
|
||||
dx[a] -= (ex / d) * f; dy[a] -= (ey / d) * f
|
||||
dx[b] += (ex / d) * f; dy[b] += (ey / d) * f
|
||||
}
|
||||
for (let i = 0; i < n; i++) {
|
||||
dx[i] -= X[i] * 0.9 * k * 4
|
||||
dy[i] -= Y[i] * 0.9 * k * 4
|
||||
const d = Math.hypot(dx[i], dy[i])
|
||||
if (d > 0) {
|
||||
const m = Math.min(d, temp)
|
||||
X[i] += (dx[i] / d) * m
|
||||
Y[i] += (dy[i] / d) * m
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Centré, étendue 1 (le plus grand côté de la boîte englobante)
|
||||
const { x0, x1, y0, y1 } = boite(Array.from(X, (x, i) => ({ x, y: Y[i] })))
|
||||
const e = Math.max(x1 - x0, y1 - y0) || 1
|
||||
noeuds.forEach((x, i) => pos.set(x.id, { x: (X[i] - (x0 + x1) / 2) / e, y: (Y[i] - (y0 + y1) / 2) / e }))
|
||||
return pos
|
||||
}
|
||||
|
||||
/** Cache par signature du graphe : au serveur, une fois par processus, pas une fois par requête. */
|
||||
const CACHE = new Map<string, Map<string, Pt>>()
|
||||
export function disposerEnCache(noeuds: NoeudGraphe[], liens: LienGraphe[], principaux: Set<string>): Map<string, Pt> {
|
||||
const sig = JSON.stringify([noeuds.map((x) => [x.id, x.kind]), liens.map((l) => [l.de, l.vers]), [...principaux]])
|
||||
let p = CACHE.get(sig)
|
||||
if (!p) {
|
||||
p = disposer(noeuds, liens, principaux)
|
||||
if (CACHE.size > 24) CACHE.delete(CACHE.keys().next().value as string)
|
||||
CACHE.set(sig, p)
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
/** Identifiants à `pas` liens au plus de `id` (le nœud compris) ; `tout` = tous. */
|
||||
export function voisinage(liens: LienGraphe[], id: string, pas: Pas): Set<string> | null {
|
||||
if (pas === 'tout') return null
|
||||
const adj = new Map<string, string[]>()
|
||||
for (const l of liens) {
|
||||
if (!adj.has(l.de)) adj.set(l.de, [])
|
||||
if (!adj.has(l.vers)) adj.set(l.vers, [])
|
||||
adj.get(l.de)!.push(l.vers)
|
||||
adj.get(l.vers)!.push(l.de)
|
||||
}
|
||||
const vus = new Set([id])
|
||||
let front = [id]
|
||||
for (let p = 0; p < pas; p++) {
|
||||
const suite: string[] = []
|
||||
for (const x of front) for (const y of adj.get(x) ?? []) if (!vus.has(y)) { vus.add(y); suite.push(y) }
|
||||
front = suite
|
||||
}
|
||||
return vus
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* lire — B19b M4. Ce que la fiche d'un objet lit dans le jeu : ses sources, ses porteurs, ses
|
||||
* relations typées (dans les deux sens), ses dettes et ses vacances. Sorti de
|
||||
* `pages/connaissances.vue` et testé par `scripts/test-connaissances.mjs` ; B9 réécrit et
|
||||
* l'option B (fiches Markdown) le reprendront tel quel : il ne connaît que le jeu.
|
||||
*
|
||||
* `lecture(jeu)` indexe le jeu une fois (objets par identifiant, objets rendus) ; chaque
|
||||
* fonction prend cette lecture et un identifiant. Fonctions pures : le jeu n'est pas modifié.
|
||||
*/
|
||||
import type { JeuConnaissances, ObjetConnaissance, VacanceConnaissance } from './valider'
|
||||
import { ETAT_RENDU } from './vocabulaire'
|
||||
|
||||
/**
|
||||
* Libellé d'un type de relation, [de → vers, vers → de]. `renvoie_a` n'y est pas : il vise le
|
||||
* registre des œuvres, une autre base (rendu à part, par `registre_id`).
|
||||
*/
|
||||
export const LIBELLES_RELATION: Record<string, [string, string]> = {
|
||||
extrait_de: ['extrait de', 'source de'],
|
||||
porte_par: ['porté par', 'porte'],
|
||||
republication_de: ['republication de', 'republié par'],
|
||||
meme_objet_que: ['même objet que', 'même objet que'],
|
||||
recoupe: ['recoupe', 'recoupe'],
|
||||
precise: ['précise', 'précisé par'],
|
||||
contredit: ['contredit', 'contredit par'],
|
||||
condition_de: ['condition de', 'a pour condition'],
|
||||
homonyme_de: ['homonyme de, fusion refusée :', 'homonyme de, fusion refusée :'],
|
||||
}
|
||||
|
||||
/**
|
||||
* Ce que la page rend : les objets publiés. Un objet écarté reste en base et n'est jamais
|
||||
* rendu ; `en_file`, `a_trier` et `a_creuser` non plus, tant qu'un humain n'a pas tranché
|
||||
* (interdit n° 2 de la CONCEPTION §5).
|
||||
*/
|
||||
export const estRendu = (o: { etat: string }) => o.etat === ETAT_RENDU
|
||||
|
||||
export interface Lecture {
|
||||
jeu: JeuConnaissances
|
||||
parId: Map<string, ObjetConnaissance>
|
||||
rendus: Map<string, ObjetConnaissance>
|
||||
}
|
||||
|
||||
const LECTURES = new WeakMap<JeuConnaissances, Lecture>()
|
||||
|
||||
/** L'index d'un jeu, construit une fois par jeu (mémorisé) : la page et l'adaptateur le partagent. */
|
||||
export function lecture(jeu: JeuConnaissances): Lecture {
|
||||
let l = LECTURES.get(jeu)
|
||||
if (!l) {
|
||||
l = {
|
||||
jeu,
|
||||
parId: new Map(jeu.objets.map((o) => [o.id, o])),
|
||||
rendus: new Map(jeu.objets.filter(estRendu).map((o) => [o.id, o])),
|
||||
}
|
||||
LECTURES.set(jeu, l)
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
/** Sources d'un objet (`extrait_de`), publiées ou non : une source à creuser se dit, elle ne disparaît pas. Les écartées, non. */
|
||||
export function sourcesDe(l: Lecture, id: string): ObjetConnaissance[] {
|
||||
return l.jeu.relations
|
||||
.filter((r) => r.type === 'extrait_de' && r.de === id && r.etat !== 'ecarte')
|
||||
.map((r) => l.parId.get(r.vers))
|
||||
.filter((o): o is ObjetConnaissance => !!o && o.etat !== 'ecarte')
|
||||
}
|
||||
|
||||
/** Porteurs d'un objet : ses `porteur_ids` qui sont des organisations rendues ; une organisation se porte elle-même. */
|
||||
export function porteursDe(l: Lecture, o: ObjetConnaissance): ObjetConnaissance[] {
|
||||
if (o.nature === 'organisation') return [o]
|
||||
return (o.porteur_ids ?? []).map((id) => l.rendus.get(id)).filter((p): p is ObjetConnaissance => !!p && p.nature === 'organisation')
|
||||
}
|
||||
|
||||
export interface RelationLue {
|
||||
/** Clé stable (rang de la relation dans le jeu). */
|
||||
cle: string
|
||||
type: string
|
||||
/** 0 = l'objet est à l'origine (`de`), 1 = à l'arrivée (`vers`). */
|
||||
sens: 0 | 1
|
||||
libelle: string
|
||||
cible: ObjetConnaissance
|
||||
provenance: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Relations de l'objet, dans les deux sens, sauf ses sources (`sourcesDe`), `renvoie_a` (le
|
||||
* registre, une autre base), les relations écartées et celles vers un objet écarté.
|
||||
*/
|
||||
export function relationsDe(l: Lecture, id: string): RelationLue[] {
|
||||
const out: RelationLue[] = []
|
||||
l.jeu.relations.forEach((r, k) => {
|
||||
if (r.etat === 'ecarte' || r.type === 'renvoie_a' || !LIBELLES_RELATION[r.type]) return
|
||||
if (r.de === id && r.type === 'extrait_de') return
|
||||
if (r.de !== id && r.vers !== id) return
|
||||
const sens: 0 | 1 = r.de === id ? 0 : 1
|
||||
const cible = l.parId.get(sens === 0 ? r.vers : r.de)
|
||||
if (!cible || cible.etat === 'ecarte') return
|
||||
out.push({ cle: `${k}`, type: r.type, sens, libelle: LIBELLES_RELATION[r.type][sens], cible, provenance: r.provenance })
|
||||
})
|
||||
return out
|
||||
}
|
||||
|
||||
/** Les relations regroupées par libellé (un type dans un sens), dans l'ordre de première apparition : une ligne de l'en-tête chacune. */
|
||||
export function relationsParLibelle(l: Lecture, id: string): { libelle: string; relations: RelationLue[] }[] {
|
||||
const groupes = new Map<string, RelationLue[]>()
|
||||
for (const r of relationsDe(l, id)) {
|
||||
const g = groupes.get(r.libelle)
|
||||
if (g) g.push(r)
|
||||
else groupes.set(r.libelle, [r])
|
||||
}
|
||||
return [...groupes].map(([libelle, relations]) => ({ libelle, relations }))
|
||||
}
|
||||
|
||||
export const dettesDe = (o: ObjetConnaissance | undefined): string[] => o?.dettes_non_creditees ?? []
|
||||
export const vacancesDe = (o: ObjetConnaissance | undefined): VacanceConnaissance[] => o?.vacances ?? []
|
||||
@@ -8,16 +8,28 @@
|
||||
* `valider(jeu) → { ok, erreurs[] }`. Chaque erreur nomme l'identifiant en cause et la
|
||||
* règle (`R7`, `R10`, `extrait_de`, `homonyme_de`, `rendu`, `prefixe`, `orpheline`…).
|
||||
* Testé par scripts/test-connaissances.mjs. B20 l'appellera avant toute écriture.
|
||||
*
|
||||
* B19b : natures, échelles, couches, préfixes, états et seuil de copie viennent de
|
||||
* `vocabulaire.ts` (écrits une fois, comparés au schéma par le test) ; les types
|
||||
* `ObjetConnaissance` / `JeuConnaissances` sont les seuls de la couche (l'adaptateur et la
|
||||
* page les importent).
|
||||
*/
|
||||
import schema from '../../data/connaissances/schema.json'
|
||||
import {
|
||||
NATURES, ETATS, ECHELLES, COUCHES, PREFIXES, MOTS_COPIE_MAX,
|
||||
type Nature, type Echelle, type Couche,
|
||||
} from './vocabulaire'
|
||||
|
||||
// ── Vocabulaire, lu dans le schéma ─────────────────────────────────────────
|
||||
export { NATURES, ETATS, PREFIXES, MOTS_COPIE_MAX }
|
||||
|
||||
// ── Vocabulaire propre au validateur, lu dans le schéma ────────────────────
|
||||
|
||||
const DEFS = (schema as any).$defs
|
||||
const enumDe = (p: any): string[] => p?.enum ?? DEFS[(p?.$ref ?? '').replace('#/$defs/', '')]?.enum ?? []
|
||||
/** Une valeur reçue (non sûre) est-elle dans une liste du vocabulaire ? */
|
||||
const dans = (liste: readonly string[], v: unknown) => typeof v === 'string' && liste.includes(v)
|
||||
const PREFIXE_DE = PREFIXES as Record<string, string>
|
||||
|
||||
export const NATURES: string[] = DEFS.objet.properties.nature.enum
|
||||
export const ETATS: string[] = DEFS.etat.enum
|
||||
export const TYPES_RELATION: string[] = DEFS.relation.properties.type.enum
|
||||
export const PROVENANCES: string[] = DEFS.relation.properties.provenance.enum
|
||||
export const CHAMPS_OBJET = new Set(Object.keys(DEFS.objet.properties))
|
||||
@@ -26,15 +38,10 @@ const CHAMPS_FUSION = new Set(Object.keys(DEFS.fusion.properties))
|
||||
const CHAMPS_JEU = new Set(Object.keys((schema as any).properties))
|
||||
const CHAMPS_VACANCE = new Set(Object.keys(DEFS.vacance.properties))
|
||||
const METHODES = enumDe(DEFS.vacance.properties.methode)
|
||||
const ECHELLES: string[] = DEFS.objet.properties.echelles.items.enum
|
||||
const COUCHES: string[] = DEFS.objet.properties.couche.enum
|
||||
const RE_ID = new RegExp(DEFS.id.pattern)
|
||||
const RE_DATE = new RegExp(DEFS.date.pattern)
|
||||
const RE_REGISTRE = new RegExp(DEFS.refRegistre.pattern)
|
||||
|
||||
/** Préfixe d'identifiant de chaque nature. */
|
||||
export const PREFIXES: Record<string, string> = { texte: 'txt', organisation: 'org', outil: 'out', concept: 'cpt' }
|
||||
|
||||
/**
|
||||
* Champs de rendu : la structure ne se fonde pas sur le rendu (U, O §D3). Le layout est une
|
||||
* projection calculée ; une position, une couleur ou un regroupement en base est refusé.
|
||||
@@ -49,16 +56,34 @@ const RENDU = new Set(CHAMPS_RENDU)
|
||||
/** Relations entre concepts (vocabulaire « Croisement »). */
|
||||
export const CROISEMENTS = ['recoupe', 'precise', 'contredit', 'condition_de']
|
||||
|
||||
/** Longueur au-delà de laquelle une suite de mots commune à la définition et à la source est une copie. */
|
||||
export const MOTS_COPIE_MAX = 12
|
||||
// ── Types (les seuls de la couche : adaptateur, lecture et page les importent) ──
|
||||
|
||||
// ── Types ──────────────────────────────────────────────────────────────────
|
||||
export interface VacanceConnaissance { enonce: string; date: string; methode: string; perimetre?: string }
|
||||
|
||||
/**
|
||||
* Un objet de la couche. Les champs que le rendu lit sont typés ; les autres restent
|
||||
* ouverts (le validateur reçoit des données non sûres, c'est lui qui les contrôle).
|
||||
*/
|
||||
export interface ObjetConnaissance {
|
||||
id: string
|
||||
nature: 'texte' | 'organisation' | 'outil' | 'concept'
|
||||
nature: Nature
|
||||
nom_canonique: string
|
||||
etat: string
|
||||
definition_courte?: string
|
||||
libelle_source?: string
|
||||
variantes?: string[]
|
||||
porteur_ids?: string[]
|
||||
echelles?: Echelle[]
|
||||
couche?: Couche
|
||||
url_canonique?: string | null
|
||||
statut?: string
|
||||
date_original?: string | null
|
||||
date_original_nature?: 'affichee' | 'vue'
|
||||
licence?: string | null
|
||||
credit?: string | null
|
||||
dettes_non_creditees?: string[]
|
||||
vacances?: VacanceConnaissance[]
|
||||
registre_id?: string | null
|
||||
[champ: string]: any
|
||||
}
|
||||
|
||||
@@ -167,14 +192,14 @@ export function valider(jeu: JeuConnaissances): { ok: boolean; erreurs: ErreurVa
|
||||
// Identifiant : préfixe de nature, et le bon
|
||||
if (!RE_ID.test(id)) {
|
||||
err(id, 'prefixe', 'identifiant sans préfixe de nature (txt:, org:, out:, cpt:) ou mal formé')
|
||||
} else if (PREFIXES[o.nature] && !id.startsWith(`${PREFIXES[o.nature]}:`)) {
|
||||
err(id, 'prefixe', `nature « ${o.nature} » : l’identifiant doit commencer par ${PREFIXES[o.nature]}:`)
|
||||
} else if (PREFIXE_DE[o.nature] && !id.startsWith(`${PREFIXE_DE[o.nature]}:`)) {
|
||||
err(id, 'prefixe', `nature « ${o.nature} » : l’identifiant doit commencer par ${PREFIXE_DE[o.nature]}:`)
|
||||
}
|
||||
if (!NATURES.includes(o.nature)) err(id, 'schema', `nature inconnue « ${o.nature} »`)
|
||||
if (!dans(NATURES, o.nature)) err(id, 'schema', `nature inconnue « ${o.nature} »`)
|
||||
if (!o.nom_canonique) err(id, 'schema', 'nom_canonique manquant')
|
||||
if (!ETATS.includes(o.etat)) err(id, 'schema', `etat inconnu « ${o.etat} »`)
|
||||
for (const e of o.echelles ?? []) if (!ECHELLES.includes(e)) err(id, 'schema', `échelle inconnue « ${e} »`)
|
||||
if (o.couche != null && !COUCHES.includes(o.couche)) err(id, 'schema', `couche inconnue « ${o.couche} »`)
|
||||
if (!dans(ETATS, o.etat)) err(id, 'schema', `etat inconnu « ${o.etat} »`)
|
||||
for (const e of o.echelles ?? []) if (!dans(ECHELLES, e)) err(id, 'schema', `échelle inconnue « ${e} »`)
|
||||
if (o.couche != null && !dans(COUCHES, o.couche)) err(id, 'schema', `couche inconnue « ${o.couche} »`)
|
||||
for (const champ of ['date_original', 'date_republication', 'derniere_publication', 'peremption_connue', 'verdict_le', 'revu_le']) {
|
||||
if (o[champ] != null && !RE_DATE.test(String(o[champ]))) err(id, 'schema', `${champ} n’est pas une date ISO`)
|
||||
}
|
||||
@@ -214,7 +239,7 @@ export function valider(jeu: JeuConnaissances): { ok: boolean; erreurs: ErreurVa
|
||||
}
|
||||
if (!TYPES_RELATION.includes(r.type)) { err(id, 'schema', `type de relation inconnu « ${r.type} »`); continue }
|
||||
if (!PROVENANCES.includes(r.provenance)) err(id, r.type, `provenance « ${r.provenance} » : source ou curation`)
|
||||
if (!ETATS.includes(r.etat)) err(id, r.type, `etat inconnu « ${r.etat} »`)
|
||||
if (!dans(ETATS, r.etat)) err(id, r.type, `etat inconnu « ${r.etat} »`)
|
||||
|
||||
const de = parId.get(r.de)
|
||||
if (!de) { err(id, 'orpheline', `${r.type} : « ${r.de} » n’est pas dans le jeu`); continue }
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* vocabulaire — B19b M4. Le vocabulaire du schéma de la couche (natures, échelles, couches,
|
||||
* préfixes, états, seuil de copie), écrit UNE fois. Le schéma (`data/connaissances/schema.json`)
|
||||
* reste le contrat : `scripts/test-connaissances.mjs` compare chaque liste à son énumération,
|
||||
* et les préfixes aux motifs `^txt:`… du schéma. Écrit ici plutôt que lu dans le JSON pour
|
||||
* deux raisons : des types littéraux (`Nature`, `Echelle`) sans recopie, et un adaptateur
|
||||
* (`useFicheAdapter`, servi sur `/`, `/agences`, `/outils`) qui n'embarque pas le schéma.
|
||||
* Importé par `valider.ts`, `lire.ts`, `useFicheAdapter.ts`, la page et le test.
|
||||
*/
|
||||
|
||||
/** Les quatre natures, dans l'ordre du schéma (`$defs.objet.properties.nature.enum`). */
|
||||
export const NATURES = ['texte', 'organisation', 'outil', 'concept'] as const
|
||||
export type Nature = (typeof NATURES)[number]
|
||||
|
||||
/** Préfixe d'identifiant de chaque nature (`$defs.id.pattern` et les `allOf` du schéma). */
|
||||
export const PREFIXES: Record<Nature, string> = { texte: 'txt', organisation: 'org', outil: 'out', concept: 'cpt' }
|
||||
|
||||
/** Échelles S / M / XL, dans l'ordre d'affichage (`$defs.objet.properties.echelles.items.enum`). */
|
||||
export const ECHELLES = ['S', 'M', 'XL'] as const
|
||||
export type Echelle = (typeof ECHELLES)[number]
|
||||
|
||||
/** Couches (`$defs.objet.properties.couche.enum`). */
|
||||
export const COUCHES = ['socle', 'actualite'] as const
|
||||
export type Couche = (typeof COUCHES)[number]
|
||||
|
||||
/** États d'un objet ou d'une relation (`$defs.etat.enum`). */
|
||||
export const ETATS = ['en_file', 'a_trier', 'publie', 'a_creuser', 'ecarte'] as const
|
||||
export type Etat = (typeof ETATS)[number]
|
||||
|
||||
/** Le seul état rendu en public : tout autre attend un humain (CONCEPTION §5, interdit n° 2). */
|
||||
export const ETAT_RENDU: Etat = 'publie'
|
||||
|
||||
/**
|
||||
* Longueur au-delà de laquelle une suite de mots commune à la définition et au libellé de la
|
||||
* source est une copie (règle `copie` du validateur). Le schéma ne la porte pas : elle vit ici.
|
||||
*/
|
||||
export const MOTS_COPIE_MAX = 12
|
||||
|
||||
export const LIBELLES_NATURE: Record<Nature, string> = {
|
||||
concept: 'Concept',
|
||||
texte: 'Texte',
|
||||
organisation: 'Organisation',
|
||||
outil: 'Outil',
|
||||
}
|
||||
|
||||
export const LIBELLES_COUCHE: Record<Couche, string> = { socle: 'Socle', actualite: 'Actualité' }
|
||||
|
||||
/** Motif d'un préfixe de nature en tête d'identifiant (`cpt:`, `org:`…), tiré de `PREFIXES`. */
|
||||
export const RE_PREFIXE = new RegExp(`^(${Object.values(PREFIXES).join('|')}):`)
|
||||
Reference in New Issue
Block a user