Compare commits
7
Commits
0118dd65f8
...
d83ef12269
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d83ef12269 | ||
|
|
0ff71d9b7f | ||
|
|
c1b26e5987 | ||
|
|
67a8bf5584 | ||
|
|
b799c292c8 | ||
|
|
623584587d | ||
|
|
2d3ead6f70 |
@@ -0,0 +1,607 @@
|
||||
<!--
|
||||
GrapheConnaissances — B19-M2/M4. Un graphe biparti générique : des nœuds principaux
|
||||
(par défaut les concepts) et des nœuds secondaires (les sources : textes, organisations,
|
||||
outils), reliés par des liens typés. Écrit pour /connaissances, et pour être repris tel
|
||||
quel par la bibliothèque du corpus (B9 réécrit) : il ne connaît ni la vue fiches, ni la
|
||||
couche, seulement `noeuds`, `liens`, `selection`, `survol`.
|
||||
|
||||
La manière de GrapheMots (B6) : SVG rendu au serveur, taille mesurée, nœuds secondaires
|
||||
hors tabulation avec <title>, estompage. Rien de sa couronne de sept mots.
|
||||
Les gestes repris de l'explorateur Holosapiens (CONSTAT du 12/10, §4), en mieux :
|
||||
- clic = recadrage en 600 ms au plus, puis immobile ; aucune dérive perpétuelle ;
|
||||
- sœurs estompées, chemin allumé (liens de la sélection), un seul accent safran ;
|
||||
- nœuds principaux = <button>, au clavier ; `prefers-reduced-motion` = état final, sans transition ;
|
||||
- caméra bornée à la zone libre : le panneau de fiche est une colonne à part (VueFiches),
|
||||
la barre de pas et la poignée ont leur marge ; aucun nœud dessous.
|
||||
Graphe local (M4) : une sélection restreint le graphe à son voisinage à un ou deux pas
|
||||
(bascule « 1 pas / 2 pas / tout »), comme le graphe local d'Obsidian ; sans sélection,
|
||||
le graphe entier.
|
||||
|
||||
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.
|
||||
-->
|
||||
<template>
|
||||
<div ref="racine" class="gc" :class="{ 'gc--fige': fige }">
|
||||
<svg class="gc__svg" :viewBox="`0 0 ${taille.w} ${taille.h}`" aria-hidden="true" focusable="false">
|
||||
<g class="gc__liens">
|
||||
<line
|
||||
v-for="l in liensVus"
|
||||
:key="l.cle"
|
||||
:x1="l.x1" :y1="l.y1" :x2="l.x2" :y2="l.y2"
|
||||
class="gc__lien"
|
||||
:class="[`gc__lien--${l.provenance}`, { 'gc__lien--vif': l.vif, 'gc__lien--eteint': l.eteint }]"
|
||||
/>
|
||||
</g>
|
||||
<g
|
||||
v-for="s in secondairesVus"
|
||||
:key="s.id"
|
||||
class="gc__source"
|
||||
:class="{ 'gc__source--sel': s.sel, 'gc__source--survol': s.survol, 'gc__source--eteint': s.eteint === 'fort', 'gc__source--loin': s.eteint === 'leger' }"
|
||||
:transform="`translate(${s.x} ${s.y})`"
|
||||
@click="emit('select', s.id)"
|
||||
@mouseenter="emit('survol', s.id)"
|
||||
@mouseleave="emit('survol', null)"
|
||||
>
|
||||
<title>{{ s.libelle }}</title>
|
||||
<rect x="-6" y="-6" width="12" height="12" rx="2" class="gc__carre" />
|
||||
<text v-if="s.etiquette" x="10" y="4" class="gc__source-texte">{{ s.etiquette }}</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
<div class="gc__noeuds" role="group" :aria-label="titre">
|
||||
<button
|
||||
v-for="p in principauxVus"
|
||||
:key="p.id"
|
||||
type="button"
|
||||
class="gc__noeud"
|
||||
:class="{ 'gc__noeud--sel': p.sel, 'gc__noeud--survol': p.survol, 'gc__noeud--eteint': p.eteint === 'fort', 'gc__noeud--loin': p.eteint === 'leger' }"
|
||||
:style="{ left: `${p.x}px`, top: `${p.y}px`, '--gc-r': `${p.r}px` }"
|
||||
:data-id="p.id"
|
||||
:aria-label="p.aria"
|
||||
:aria-pressed="p.sel ? 'true' : 'false'"
|
||||
@click="emit('select', p.id)"
|
||||
@mouseenter="emit('survol', p.id)"
|
||||
@mouseleave="emit('survol', null)"
|
||||
@focus="emit('survol', p.id)"
|
||||
@blur="emit('survol', null)"
|
||||
>
|
||||
<span class="gc__rond" aria-hidden="true" />
|
||||
<span class="gc__libelle" aria-hidden="true">{{ p.libelle }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="selVue" class="gc__barre" role="group" aria-label="Voisinage affiché">
|
||||
<button
|
||||
v-for="o in OPTIONS_PAS"
|
||||
:key="o.v"
|
||||
type="button"
|
||||
class="gc__pas"
|
||||
:aria-pressed="pas === o.v ? 'true' : 'false'"
|
||||
@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>
|
||||
</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">
|
||||
const props = withDefaults(defineProps<{
|
||||
noeuds: NoeudGraphe[]
|
||||
liens: LienGraphe[]
|
||||
selection: string | null
|
||||
survol: string | null
|
||||
/** Kinds rendus en nœuds principaux (ronds, boutons) ; les autres sont secondaires (carrés). */
|
||||
kindsPrincipaux?: string[]
|
||||
/** Pas du graphe local à l'ouverture d'une sélection. */
|
||||
pasDefaut?: Pas
|
||||
/** Nom accessible du groupe de nœuds. */
|
||||
titre?: string
|
||||
/** Libellé de kind pour les noms accessibles (« concept », « texte »…). */
|
||||
libelleKind?: (kind: string) => string
|
||||
/** Nœuds du résultat courant (filtres de la page) ; les autres s'estompent sans disparaître. null = tous. */
|
||||
retenus?: Set<string> | null
|
||||
}>(), {
|
||||
kindsPrincipaux: () => ['concept'],
|
||||
pasDefaut: 1,
|
||||
titre: 'Graphe',
|
||||
libelleKind: (k: string) => k,
|
||||
retenus: null,
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
select: [id: string]
|
||||
survol: [id: string | null]
|
||||
}>()
|
||||
|
||||
const OPTIONS_PAS: { v: Pas; libelle: string }[] = [
|
||||
{ v: 1, libelle: '1 pas' },
|
||||
{ v: 2, libelle: '2 pas' },
|
||||
{ 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`
|
||||
|
||||
// ── Taille mesurée (le rendu serveur part d'une taille plausible, comme GrapheMots) ──
|
||||
const racine = ref<HTMLElement | null>(null)
|
||||
const taille = reactive({ w: 720, h: 560 })
|
||||
const fige = ref(false) // prefers-reduced-motion : état final, sans transition
|
||||
let redim = false
|
||||
onMounted(() => {
|
||||
const mq = window.matchMedia('(prefers-reduced-motion: reduce)')
|
||||
fige.value = mq.matches
|
||||
const majMq = () => { fige.value = mq.matches }
|
||||
mq.addEventListener('change', majMq)
|
||||
const el = racine.value
|
||||
if (el && typeof ResizeObserver !== 'undefined') {
|
||||
const maj = (w: number, h: number, initiale = false) => {
|
||||
if (w > 40 && h > 40 && (Math.round(w) !== taille.w || Math.round(h) !== taille.h)) {
|
||||
redim = initiale // la première mesure saute ; un redimensionnement (fiche ouverte, fenêtre) se recadre en douceur
|
||||
taille.w = Math.round(w)
|
||||
taille.h = Math.round(h)
|
||||
}
|
||||
}
|
||||
maj(el.clientWidth, el.clientHeight, true)
|
||||
const ro = new ResizeObserver((e) => { const r = e[0]?.contentRect; if (r) maj(r.width, r.height) })
|
||||
ro.observe(el)
|
||||
onBeforeUnmount(() => ro.disconnect())
|
||||
}
|
||||
onBeforeUnmount(() => { mq.removeEventListener('change', majMq); if (raf) cancelAnimationFrame(raf) })
|
||||
})
|
||||
|
||||
// ── Layout (repère abstrait, en cache) ──
|
||||
const principaux = computed(() => new Set(props.kindsPrincipaux))
|
||||
const monde = computed(() => disposerEnCache(props.noeuds, props.liens, principaux.value))
|
||||
const ids = computed(() => new Set(props.noeuds.map((x) => x.id)))
|
||||
|
||||
// ── Sélection et voisinage ──
|
||||
const selVue = computed(() => (props.selection && ids.value.has(props.selection) ? props.selection : null))
|
||||
const pas = ref<Pas>(props.pasDefaut)
|
||||
watch(selVue, (s, avant) => { if (s && !avant) pas.value = props.pasDefaut })
|
||||
const visibles = computed<Set<string> | null>(() => (selVue.value ? voisinage(props.liens, selVue.value, pas.value) : null))
|
||||
const voisinsSel = computed(() => (selVue.value ? voisinage(props.liens, selVue.value, 1)! : null))
|
||||
const voisinsSurvol = computed(() => (props.survol && ids.value.has(props.survol) ? voisinage(props.liens, props.survol, 1)! : null))
|
||||
|
||||
// ── Caméra : boîte des nœuds visibles → zone libre ──
|
||||
interface Camera { cx: number; cy: number; s: number }
|
||||
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
|
||||
})
|
||||
const pt = (id: string): Pt | null => {
|
||||
const p = monde.value.get(id)
|
||||
if (!p) return null
|
||||
return tourne.value ? { x: p.y, y: -p.x } : p
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
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)
|
||||
const s = Math.min(z.w / Math.max(x1 - x0, 1e-3), z.h / Math.max(y1 - y0, 1e-3), plein * 2.4)
|
||||
return { cx: (x0 + x1) / 2, cy: (y0 + y1) / 2, s }
|
||||
})
|
||||
|
||||
const camera = reactive<Camera>({ ...cible.value })
|
||||
let raf = 0
|
||||
watch(cible, (c) => {
|
||||
if (raf) { cancelAnimationFrame(raf); raf = 0 }
|
||||
if (!import.meta.client || fige.value || redim) {
|
||||
redim = false
|
||||
Object.assign(camera, c)
|
||||
return
|
||||
}
|
||||
const de = { ...camera }
|
||||
const t0 = performance.now()
|
||||
const pasAnim = (t: number) => {
|
||||
const u = Math.min(1, (t - t0) / DUREE)
|
||||
const e = 1 - Math.pow(1 - u, 3)
|
||||
camera.cx = de.cx + (c.cx - de.cx) * e
|
||||
camera.cy = de.cy + (c.cy - de.cy) * e
|
||||
camera.s = de.s + (c.s - de.s) * e
|
||||
raf = u < 1 ? requestAnimationFrame(pasAnim) : 0
|
||||
}
|
||||
raf = requestAnimationFrame(pasAnim)
|
||||
})
|
||||
|
||||
/** Bord à garder libre autour du centre d'un nœud : la demi-largeur maximale d'un libellé (9,5 rem) pour un principal. */
|
||||
const BORD_PRINCIPAL = 80 // 64 sous 768 px, où le libellé passe à 8 rem
|
||||
const BORD_SECONDAIRE = 12
|
||||
const kindDe = computed(() => new Map(props.noeuds.map((x) => [x.id, x.kind])))
|
||||
const ecran = (id: string): Pt | null => {
|
||||
const p = pt(id)
|
||||
if (!p) return null
|
||||
const z = zone.value
|
||||
const x = (p.x - camera.cx) * camera.s + z.x + z.w / 2
|
||||
// Garde-fou : aucun libellé ne sort du cadre, même en pleine animation ou sur une colonne étroite.
|
||||
const b = principaux.value.has(kindDe.value.get(id) ?? '') ? (taille.w < 768 ? 64 : BORD_PRINCIPAL) : BORD_SECONDAIRE
|
||||
const xBorne = taille.w > 2 * b ? Math.min(taille.w - b, Math.max(b, x)) : x
|
||||
return {
|
||||
x: Math.round(xBorne * 10) / 10,
|
||||
y: Math.round(((p.y - camera.cy) * camera.s + z.y + z.h / 2) * 10) / 10,
|
||||
}
|
||||
}
|
||||
|
||||
// ── Ce qui se dessine ──
|
||||
const estPrincipal = (kind: string) => principaux.value.has(kind)
|
||||
const vu = (id: string) => !visibles.value || visibles.value.has(id)
|
||||
/**
|
||||
* Estompé : hors du voisinage immédiat de la sélection. En « tout », les sœurs s'éteignent
|
||||
* franchement ; en graphe local à deux pas, le second cercle reste lisible, un ton en dessous.
|
||||
*/
|
||||
const eteint = (id: string): 'fort' | 'leger' | null => {
|
||||
if (!voisinsSel.value) return props.retenus && !props.retenus.has(id) ? 'fort' : null
|
||||
if (voisinsSel.value.has(id) || voisinsSurvol.value?.has(id)) return null
|
||||
return pas.value === 'tout' ? 'fort' : 'leger'
|
||||
}
|
||||
const degre = computed(() => {
|
||||
const d = new Map<string, number>()
|
||||
for (const l of props.liens) for (const id of [l.de, l.vers]) d.set(id, (d.get(id) ?? 0) + 1)
|
||||
return d
|
||||
})
|
||||
const tronquer = (t: string, max = 30) => (t.length > max ? `${t.slice(0, max - 1).trimEnd()}…` : t)
|
||||
|
||||
const principauxVus = computed(() => props.noeuds
|
||||
.filter((x) => estPrincipal(x.kind) && vu(x.id))
|
||||
.map((x) => {
|
||||
const p = ecran(x.id)!
|
||||
const n = degre.value.get(x.id) ?? 0
|
||||
return {
|
||||
id: x.id,
|
||||
libelle: x.libelle,
|
||||
x: p.x,
|
||||
y: p.y,
|
||||
r: 7 + Math.min(x.poids ?? n, 6),
|
||||
sel: x.id === selVue.value,
|
||||
survol: x.id === props.survol,
|
||||
eteint: eteint(x.id),
|
||||
aria: `${x.libelle}, ${props.libelleKind(x.kind)}, ${n} ${n > 1 ? 'liens' : 'lien'}`,
|
||||
}
|
||||
}))
|
||||
|
||||
const secondairesVus = computed(() => props.noeuds
|
||||
.filter((x) => !estPrincipal(x.kind) && vu(x.id))
|
||||
.map((x) => {
|
||||
const p = ecran(x.id)!
|
||||
const enVue = !!visibles.value || !!voisinsSel.value?.has(x.id) || !!voisinsSurvol.value?.has(x.id) || x.id === props.survol
|
||||
return {
|
||||
id: x.id,
|
||||
libelle: x.libelle,
|
||||
etiquette: enVue ? tronquer(x.libelle) : '',
|
||||
x: p.x,
|
||||
y: p.y,
|
||||
sel: x.id === selVue.value,
|
||||
survol: x.id === props.survol,
|
||||
eteint: eteint(x.id),
|
||||
}
|
||||
}))
|
||||
|
||||
const liensVus = computed(() => props.liens
|
||||
.filter((l) => vu(l.de) && vu(l.vers))
|
||||
.map((l, i) => {
|
||||
const a = ecran(l.de)
|
||||
const b = ecran(l.vers)
|
||||
if (!a || !b) return null
|
||||
const sel = selVue.value
|
||||
const sv = props.survol
|
||||
const vif = (!!sel && (l.de === sel || l.vers === sel)) || (!!sv && (l.de === sv || l.vers === sv))
|
||||
return {
|
||||
cle: `${l.de}>${l.vers}>${l.type}>${i}`,
|
||||
x1: a.x, y1: a.y, x2: b.x, y2: b.y,
|
||||
provenance: l.provenance === 'curation' ? 'curation' : 'source',
|
||||
vif,
|
||||
eteint: !!sel && !vif && pas.value === 'tout',
|
||||
}
|
||||
})
|
||||
.filter((l): l is NonNullable<typeof l> => !!l))
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.gc {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
background: var(--bg-alt);
|
||||
color: var(--text);
|
||||
}
|
||||
.gc__svg {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
/* Liens : encre fine ; tirets = posé par la curation */
|
||||
.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;
|
||||
}
|
||||
.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__carre {
|
||||
fill: color-mix(in srgb, var(--text) 52%, var(--bg-alt));
|
||||
stroke: var(--bg-alt);
|
||||
stroke-width: 1.5;
|
||||
}
|
||||
.gc__source--survol .gc__carre { fill: var(--text); }
|
||||
.gc__source--sel .gc__carre { fill: var(--accent); stroke: var(--text); }
|
||||
.gc__source--eteint { opacity: 0.28; }
|
||||
.gc__source--loin { opacity: 0.6; }
|
||||
.gc__source-texte {
|
||||
fill: color-mix(in srgb, var(--text) 80%, transparent);
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
paint-order: stroke;
|
||||
stroke: var(--bg-alt);
|
||||
stroke-width: 3px;
|
||||
stroke-linejoin: round;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Concepts : boutons HTML posés sur le dessin */
|
||||
.gc__noeuds { position: absolute; inset: 0; pointer-events: none; }
|
||||
.gc__noeud {
|
||||
position: absolute;
|
||||
transform: translate(-50%, calc(-1 * var(--gc-r)));
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
max-width: 9.5rem;
|
||||
padding: 0 2px 2px;
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
background: none;
|
||||
color: var(--text);
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
pointer-events: auto;
|
||||
transition: opacity 160ms ease-out;
|
||||
}
|
||||
.gc__rond {
|
||||
width: calc(2 * var(--gc-r));
|
||||
height: calc(2 * var(--gc-r));
|
||||
border-radius: 50%;
|
||||
background: var(--surface);
|
||||
border: 2px solid var(--text);
|
||||
transition: background 160ms ease-out, border-color 160ms ease-out;
|
||||
}
|
||||
.gc__libelle {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
text-align: center;
|
||||
overflow-wrap: anywhere;
|
||||
padding: 0 3px;
|
||||
border-radius: 4px;
|
||||
background: color-mix(in srgb, var(--bg-alt) 82%, transparent);
|
||||
}
|
||||
.gc__noeud--survol .gc__rond { border-width: 3px; }
|
||||
.gc__noeud--sel .gc__rond { background: var(--accent); border-color: var(--text); }
|
||||
.gc__noeud--sel .gc__libelle { background: var(--accent); color: var(--on-accent); }
|
||||
.gc__noeud--eteint { opacity: 0.32; }
|
||||
.gc__noeud--loin { opacity: 0.62; }
|
||||
.gc__noeud:focus { outline: none; }
|
||||
.gc__noeud:focus-visible .gc__rond { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
|
||||
.gc__noeud:focus-visible .gc__libelle { outline: 2px solid var(--focus-ring); }
|
||||
|
||||
/* Barre du graphe local (en haut à gauche, hors de la poignée de la vue fiches) */
|
||||
.gc__barre {
|
||||
position: absolute;
|
||||
top: var(--space-xs);
|
||||
left: 32px;
|
||||
display: inline-flex;
|
||||
padding: 2px;
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--surface);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
.gc__pas {
|
||||
min-height: 36px;
|
||||
min-width: 44px;
|
||||
padding: 0 var(--space-sm);
|
||||
border: none;
|
||||
border-radius: calc(var(--radius-md) - 2px);
|
||||
background: none;
|
||||
color: var(--text);
|
||||
font: inherit;
|
||||
font-size: var(--fs-sm);
|
||||
font-weight: var(--fw-medium);
|
||||
cursor: pointer;
|
||||
}
|
||||
.gc__pas[aria-pressed='true'] { background: var(--text); color: var(--surface); }
|
||||
.gc__pas:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
|
||||
|
||||
.gc__legende {
|
||||
position: absolute;
|
||||
top: var(--space-xs);
|
||||
right: var(--space-sm);
|
||||
margin: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 11px;
|
||||
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-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) */
|
||||
.gc--fige .gc__lien, .gc--fige .gc__source, .gc--fige .gc__noeud, .gc--fige .gc__rond { transition: none; }
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.gc__lien, .gc__source, .gc__noeud, .gc__rond { transition: none; }
|
||||
}
|
||||
</style>
|
||||
@@ -89,8 +89,16 @@ function partir(ev: MouseEvent, to: string) {
|
||||
|
||||
const route = useRoute()
|
||||
const e = computed(() => ECHELLES[props.echelle])
|
||||
/** La rangée de boutons de la porte (geste et onglets réunis, sans doublon). */
|
||||
const boutons = computed(() => PORTES_ECHELLES[props.echelle])
|
||||
/**
|
||||
* La rangée de boutons de la porte (geste et onglets réunis, sans doublon), plus, en M, la
|
||||
* carte « Je cherche des ressources » vers /connaissances (B19-M5, amendement à B16 M2 :
|
||||
* CONCEPTION couche connaissances §6, Q7). Ce n'est pas un onglet de la barre : la page n'y
|
||||
* entre qu'au checkpoint de B19 (utils/echelles.ts, ECHELLES.M.onglets).
|
||||
*/
|
||||
const CARTES_EN_PLUS: Partial<Record<EchelleId, { libelle: string; to: string }[]>> = {
|
||||
M: [{ libelle: 'Je cherche des ressources', to: '/connaissances' }],
|
||||
}
|
||||
const boutons = computed(() => [...PORTES_ECHELLES[props.echelle], ...(CARTES_EN_PLUS[props.echelle] ?? [])])
|
||||
const v = computed(() => voisines(props.echelle))
|
||||
/** id stable par échelle : la page y pose le focus après une ouverture ou un passage latéral. */
|
||||
const titreId = computed(() => `porte-titre-${props.echelle}`)
|
||||
|
||||
@@ -27,7 +27,7 @@ export interface MiniFiche {
|
||||
chipsDimension?: string
|
||||
echelle?: string
|
||||
geoloc: boolean
|
||||
kind: 'org' | 'structure' | 'mot'
|
||||
kind: 'org' | 'structure' | 'mot' | 'concept' | 'texte' | 'organisation' | 'outil'
|
||||
/** Étiquettes complètes par dimension (valeurs telles qu'écrites dans l'URL). */
|
||||
etiquettes?: Record<string, string[]>
|
||||
coords?: [number, number]
|
||||
@@ -193,6 +193,131 @@ 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'
|
||||
|
||||
/** `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')
|
||||
}
|
||||
|
||||
/** É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[] {
|
||||
if (o.echelles?.length) return [...o.echelles]
|
||||
const out = new Set<string>()
|
||||
for (const r of jeu.relations) {
|
||||
if (r.type !== 'extrait_de' || r.vers !== o.id) continue
|
||||
for (const e of rendus.get(r.de)?.echelles ?? []) out.add(e)
|
||||
}
|
||||
return ['S', 'M', 'XL'].filter((e) => out.has(e))
|
||||
}
|
||||
|
||||
/**
|
||||
* Un objet de la couche → `MiniFiche`. `id` = identifiant préfixé (`cpt:holoptisme`),
|
||||
* `kind` = nature, résumé = définition dans nos mots (concept) ou titre et porteur (objet).
|
||||
* 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)
|
||||
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.nom_canonique, nomsPorteurs.join(', ')].filter(Boolean).join(' — ')
|
||||
return {
|
||||
id: objet.id,
|
||||
kind: objet.nature,
|
||||
nom: objet.nom_canonique,
|
||||
resume: truncateOnWord(resume, 140),
|
||||
chips: echelles,
|
||||
chipsDimension: 'echelle',
|
||||
/** Badge non cliquable de la carte-fiche : la nature. */
|
||||
echelle: LIBELLES_NATURE[objet.nature],
|
||||
geoloc: true,
|
||||
etiquettes: {
|
||||
nature: [objet.nature],
|
||||
echelle: echelles,
|
||||
porteur: porteurs.map((p) => valeurPorteur(p.id)),
|
||||
couche: objet.couche ? [objet.couche] : [],
|
||||
},
|
||||
date: objet.date_original ?? undefined,
|
||||
texte: [objet.libelle_source, objet.credit, ...(objet.variantes ?? []), ...nomsPorteurs].filter(Boolean).join(' '),
|
||||
}
|
||||
}
|
||||
|
||||
/** 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))
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
export function grapheConnaissances(jeu: JeuCouche): {
|
||||
noeuds: { id: string; libelle: string; kind: string; poids: number }[]
|
||||
liens: { de: string; vers: string; type: string; provenance: string }[]
|
||||
} {
|
||||
const rendus = new Map(jeu.objets.filter(estRendu).map((o) => [o.id, o]))
|
||||
const liens = jeu.relations
|
||||
.filter((r) => r.etat === 'publie' && 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 }))
|
||||
return { noeuds, liens }
|
||||
}
|
||||
|
||||
export function useFicheAdapter() {
|
||||
return { toMini, toMiniMot }
|
||||
return { toMini, toMiniMot, toMiniConnaissance }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,357 @@
|
||||
<!--
|
||||
/connaissances — B19-M3. La couche de connaissances partagées, premier jeu : des concepts
|
||||
reliés à leurs sources (CONCEPTION - couche connaissances partagees (12-10) §6), rendus par
|
||||
la vue fiches (états Graphe / Mixte / Fiches, libellés de B6), le graphe dans #carte, la
|
||||
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.
|
||||
-->
|
||||
<template>
|
||||
<main class="cn">
|
||||
<header class="cn-tete">
|
||||
<h1 class="cn-tete__titre">Connaissances partagées</h1>
|
||||
<p class="cn-bandeau">
|
||||
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>
|
||||
(CC BY-SA 4.0).
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<div class="cn-vue">
|
||||
<VueFiches
|
||||
:vf="vf"
|
||||
intention="Des idées nommées, chacune reliée aux textes qui la portent : ouvrez un concept, ses sources s’allument."
|
||||
libelle-recherche="Rechercher un concept, une source…"
|
||||
:libelles-vue="{ carte: 'Graphe' }"
|
||||
:lien-page="() => null"
|
||||
>
|
||||
<template #carte>
|
||||
<GrapheConnaissances
|
||||
:noeuds="graphe.noeuds"
|
||||
:liens="graphe.liens"
|
||||
:selection="vf.ficheId"
|
||||
:survol="vf.survolId != null ? String(vf.survolId) : null"
|
||||
:retenus="vf.idsResultat"
|
||||
:libelle-kind="(k: string) => LIBELLES_NATURE[k as Nature]?.toLowerCase() ?? k"
|
||||
titre="Graphe des concepts et de leurs sources"
|
||||
@select="(id: string) => vf.ouvrirFiche(id)"
|
||||
@survol="(id: string | null) => (vf.survolId = id)"
|
||||
/>
|
||||
</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>
|
||||
|
||||
<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>
|
||||
|
||||
<!-- 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>
|
||||
<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>
|
||||
</dd>
|
||||
</template>
|
||||
<template v-if="objetDe(fiche.id)!.statut">
|
||||
<dt>Statut</dt>
|
||||
<dd>{{ objetDe(fiche.id)!.statut }}</dd>
|
||||
</template>
|
||||
<template v-if="objetDe(fiche.id)!.url_canonique">
|
||||
<dt>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>
|
||||
</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>
|
||||
|
||||
<!-- 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>
|
||||
</article>
|
||||
</template>
|
||||
</VueFiches>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<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']
|
||||
|
||||
// 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 fiches = fichesConnaissances(jeu)
|
||||
const graphe = grapheConnaissances(jeu)
|
||||
const nbConcepts = jeu.objets.filter((o) => o.nature === 'concept' && estRendu(o)).length
|
||||
|
||||
// ── Configuration de la vue fiches : nature, échelle, porteur, couche ──
|
||||
const NATURES: Nature[] = ['concept', 'texte', 'organisation', 'outil']
|
||||
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: 'porteur',
|
||||
libelle: 'Porteur',
|
||||
variante: 'posture',
|
||||
valeurs: jeu.objets
|
||||
.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é' })) },
|
||||
],
|
||||
tris: ['nom', 'recent', 'pertinence'],
|
||||
triDefaut: 'nom',
|
||||
groupes: [
|
||||
{ cle: 'nature', libelle: 'Nature', dimension: 'nature', sans: 'Sans nature' },
|
||||
],
|
||||
etats: ['carte', 'mixte', 'fiches'],
|
||||
}
|
||||
|
||||
const vf = useVueFiches(fiches, config)
|
||||
|
||||
// ── 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 :'],
|
||||
}
|
||||
|
||||
/** 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) ?? []
|
||||
|
||||
const MOIS = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre']
|
||||
function dateFr(d: unknown): string {
|
||||
const [a, m, j] = String(d ?? '').split('-')
|
||||
if (!a) return ''
|
||||
if (!m) return a
|
||||
if (!j) return `${MOIS[Number(m) - 1]} ${a}`
|
||||
return `${Number(j)} ${MOIS[Number(m) - 1]} ${a}`
|
||||
}
|
||||
const urlCourte = (u: string) => u.replace(/^https?:\/\//, '').replace(/\/$/, '')
|
||||
const idDom = (id: string | number) => String(id).replace(/[^a-z0-9-]/gi, '-')
|
||||
|
||||
const NOMBRES = ['zéro', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze']
|
||||
const nombreEnLettres = (n: number) => NOMBRES[n] ?? String(n)
|
||||
|
||||
useSeoMeta({
|
||||
title: () => (vf.ficheOuverte ? `${vf.ficheOuverte.nom} — Connaissances partagées — AEP` : 'Connaissances partagées — AEP'),
|
||||
description: 'Des concepts reliés à leurs sources, triés à la main : le premier jeu de la couche de connaissances partagées d’AEP, en graphe et en fiches.',
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* La vue fiches remplit la hauteur du conteneur de défilement (app.vue), comme /outils « Partir de soi ». */
|
||||
.cn {
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
color: var(--text);
|
||||
}
|
||||
.cn-tete {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
gap: var(--space-2xs, 0.25rem) 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-bandeau {
|
||||
flex: 1 1 32rem;
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
font-size: var(--fs-sm);
|
||||
line-height: 1.45;
|
||||
color: color-mix(in srgb, var(--text) 82%, transparent);
|
||||
}
|
||||
.cn-bandeau a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
|
||||
.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 ── */
|
||||
.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);
|
||||
}
|
||||
.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__vers {
|
||||
padding: 0;
|
||||
border: none;
|
||||
background: none;
|
||||
color: var(--text);
|
||||
font: inherit;
|
||||
font-weight: var(--fw-semibold);
|
||||
text-align: left;
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.cf__lien { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
|
||||
.cf__lien--ext { margin-left: 4px; }
|
||||
.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; }
|
||||
.cf__provenance {
|
||||
display: inline-block;
|
||||
margin-left: 6px;
|
||||
padding: 0 6px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid var(--border-strong, var(--border));
|
||||
font-size: var(--fs-xs, 0.75rem);
|
||||
color: color-mix(in srgb, var(--text) 82%, transparent);
|
||||
}
|
||||
.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; }
|
||||
|
||||
@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); }
|
||||
}
|
||||
</style>
|
||||
@@ -172,5 +172,34 @@ ok(V.valider(joint).ok, 'le jeu joint passe toujours le validateur')
|
||||
}
|
||||
ok(J.idRegistre('registre:P2-18') === 'P2-18' && J.idRegistre('cpt:x') === null, 'idRegistre : préfixe registre: seulement')
|
||||
|
||||
// ── B19 M1 : adaptateur toMiniConnaissance et graphe ────────────
|
||||
const A = await jiti.import(join(racine, 'composables', 'useFicheAdapter.ts'))
|
||||
{
|
||||
const fiches = A.fichesConnaissances(fixture)
|
||||
const ids = fiches.map((f) => f.id)
|
||||
ok(fiches.length === fixture.objets.filter((o) => o.etat === 'publie').length, `adaptateur : une fiche par objet publié (${fiches.length})`)
|
||||
ok(!ids.includes('cpt:signaux-faibles-ansoff') && !ids.includes('txt:noubel-economie-du-don'), 'adaptateur : a_trier et a_creuser ne sont pas rendus')
|
||||
{
|
||||
const j = copie(fixture)
|
||||
objet(j, 'cpt:matrice-aep').etat = 'ecarte'
|
||||
ok(!A.fichesConnaissances(j).some((f) => f.id === 'cpt:matrice-aep'), 'adaptateur : un objet écarté n’est pas rendu')
|
||||
}
|
||||
const h = fiches.find((f) => f.id === 'cpt:holoptisme')
|
||||
ok(h.kind === 'concept' && h.nom === 'Holoptisme' && h.resume === objet(fixture, 'cpt:holoptisme').definition_courte, 'adaptateur : id préfixé, kind = nature, nom canonique, résumé = définition')
|
||||
ok(JSON.stringify(h.etiquettes) === JSON.stringify({ nature: ['concept'], echelle: ['S', 'M'], porteur: ['holosapiens'], couche: ['socle'] }), 'adaptateur : étiquettes nature, échelle, porteur, couche', JSON.stringify(h.etiquettes))
|
||||
ok(h.date === '2015-08-08' && h.geoloc === true, 'adaptateur : date = date_original ; pas de géographie')
|
||||
const t = fiches.find((f) => f.id === 'txt:hs-signaux-faibles')
|
||||
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')
|
||||
|
||||
const g = A.grapheConnaissances(fixture)
|
||||
ok(g.noeuds.length === fiches.length, 'graphe : un nœud par fiche')
|
||||
ok(g.liens.every((l) => ids.includes(l.de) && ids.includes(l.vers)), 'graphe : aucun lien vers un objet non rendu')
|
||||
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')
|
||||
ok(g.liens.some((l) => l.type === 'recoupe' && l.de === 'cpt:architectures-invisibles' && l.vers === 'cpt:matrice-aep'), 'graphe : le croisement architectures invisibles ↔ matrice est un lien')
|
||||
}
|
||||
|
||||
console.log(`\n${n - echecs}/${n} OK${echecs ? ` · ${echecs} ÉCHEC(S)` : ''}`)
|
||||
process.exit(echecs ? 1 : 0)
|
||||
|
||||
Reference in New Issue
Block a user