feat(bibliotheque): étape D, la page /bibliotheque (VueFiches en Mixte, GrapheConnaissances par un second adaptateur, axes thème, époque, auteur ; disposition radiale amorcée au cache du graphe), le module de build et la route de la fiche au clic ; /rag et le commutateur mènent à /bibliotheque, /media intact
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,317 @@
|
||||
<!--
|
||||
/bibliotheque — lot B9. L'arborescence du registre des œuvres (la couche ancienne d'AEP), projetée
|
||||
par un axe (thème, époque, auteur), et la fiche de lecture des œuvres dont le socle est servi.
|
||||
CONCEPTION - bibliothèque navigable (19-10) §4 ; le brief B9 réécrit (18/11).
|
||||
|
||||
Les mêmes composants que /connaissances, sans y toucher : `VueFiches` en Mixte (le graphe, la liste,
|
||||
la fiche en panneau) et `GrapheConnaissances` nourri par un second adaptateur (utils/bibliotheque/
|
||||
arbre.ts). Le chemin dans l'arborescence est le filtre de l'axe, dans l'URL : ?axe=epoque&epoque=…,
|
||||
?fiche=oeu:… ; « Agrandir » est un état de la page (l'adresse ne change pas).
|
||||
|
||||
Données au build : `#build/bibliotheque/arbre.mjs` (l'export, aucune fiche) ; le HTML d'une fiche
|
||||
arrive au clic, par /api/bibliotheque/fiche/<slug>.
|
||||
-->
|
||||
<template>
|
||||
<main class="bib" :class="{ 'bib--agrandi': agrandiVu }">
|
||||
<header class="bib-tete">
|
||||
<h1 class="bib-tete__titre">Bibliothèque</h1>
|
||||
<p class="bib-bandeau">
|
||||
{{ phrase }}
|
||||
Navigation inspirée de
|
||||
<a href="https://holosapiens.earth" target="_blank" rel="noopener noreferrer">l’explorateur Holosapiens<span class="sr-only"> (nouvel onglet)</span></a>.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<div class="bib-vue">
|
||||
<VueFiches
|
||||
:vf="vf"
|
||||
intention="Les livres que lit AEP, rangés par thème, par époque ou par auteur : ouvrez une catégorie, ses œuvres apparaissent."
|
||||
libelle-recherche="Rechercher une œuvre, un auteur…"
|
||||
:libelles-vue="{ carte: 'Graphe' }"
|
||||
:lien-page="lienPage"
|
||||
:navigation-lineaire="false"
|
||||
>
|
||||
<template #carte>
|
||||
<div class="bib-graphe">
|
||||
<GrapheConnaissances
|
||||
:noeuds="graphe.noeuds"
|
||||
:liens="graphe.liens"
|
||||
:selection="selection"
|
||||
:survol="vf.survolId != null ? String(vf.survolId) : null"
|
||||
:retenus="retenus"
|
||||
:kinds-principaux="KINDS_PRINCIPAUX"
|
||||
:libelle-kind="libelleKind"
|
||||
titre="Arborescence de la bibliothèque"
|
||||
@select="choisir"
|
||||
@survol="(id: string | null) => (vf.survolId = id)"
|
||||
/>
|
||||
<ul class="bib-legende" aria-label="Légende de l’arborescence">
|
||||
<li><span class="bib-legende__cat" aria-hidden="true" />{{ LIBELLE_AXE[axe] }}</li>
|
||||
<li><span class="bib-legende__fiche" aria-hidden="true" />Fiche de lecture</li>
|
||||
<li><span class="bib-legende__ref" aria-hidden="true" />Référence seulement</li>
|
||||
</ul>
|
||||
<p v-if="graphe.masquees" class="bib-masquees">
|
||||
{{ graphe.masquees }} {{ graphe.masquees > 1 ? 'autres œuvres' : 'autre œuvre' }} dans la liste seulement
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #detail="{ filtrer }">
|
||||
<article v-if="oeuvre" class="bo">
|
||||
<h2 class="bo__titre">{{ oeuvre.titre }}</h2>
|
||||
<p class="bo__meta">
|
||||
{{ ligneAuteurs(arbre, oeuvre) }} · {{ anneeTexte(oeuvre.annee) }}<template v-if="oeuvre.epoque"> · {{ nomEpoque.get(oeuvre.epoque) }}</template>
|
||||
</p>
|
||||
<ChipGroup v-if="oeuvre.courants.length" :aria-label="`Thèmes de ${oeuvre.titre}`" class="bo__themes">
|
||||
<Chip
|
||||
v-for="c in oeuvre.courants"
|
||||
:key="c"
|
||||
:label="nomCourant.get(c) ?? c"
|
||||
variant="fonction"
|
||||
:active="(vf.etat.filtres.theme ?? []).includes(c)"
|
||||
:aria-label="`Filtrer par thème : ${nomCourant.get(c)}`"
|
||||
@toggle="filtrer('theme', c)"
|
||||
/>
|
||||
</ChipGroup>
|
||||
|
||||
<template v-if="oeuvre.fiche">
|
||||
<p class="bo__statut">Fiche de lecture · {{ oeuvre.regime }}</p>
|
||||
<button
|
||||
v-if="vf.largeur === 'ordinateur' || vf.largeur === 'tablette'"
|
||||
type="button"
|
||||
class="bo__agrandir"
|
||||
:aria-pressed="agrandi ? 'true' : 'false'"
|
||||
@click="agrandi = !agrandi"
|
||||
>{{ agrandi ? 'Réduire' : 'Agrandir, avec le sommaire' }}</button>
|
||||
<p v-if="chargement === 'pending'" class="bo__etat">Chargement de la fiche…</p>
|
||||
<p v-else-if="!ficheLue" class="bo__etat">La fiche n’a pas pu être chargée.</p>
|
||||
<BibliothequeFicheLecture v-else :fiche="ficheLue" :sommaire="agrandiVu" sur-place @oeuvre="(id: string) => vf.ouvrirFiche(id)" />
|
||||
</template>
|
||||
<div v-else class="bo__reference">
|
||||
<p class="bo__statut">Référence seulement</p>
|
||||
<p v-if="oeuvre.regime">Cette œuvre est lue par notre analyse ; sa fiche n’est pas encore ouverte.</p>
|
||||
<p v-else>Cette œuvre est au registre de la bibliothèque, sans fiche de lecture : nous n’en avons rien de plus.</p>
|
||||
</div>
|
||||
</article>
|
||||
</template>
|
||||
</VueFiches>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import arbreBrut from '#build/bibliotheque/arbre.mjs'
|
||||
import type { ConfigVueFiches } from '~/utils/vueFiches'
|
||||
import type { MiniFiche } from '~/composables/useFicheAdapter'
|
||||
import { amorcer } from '~/utils/connaissances/graphe'
|
||||
import {
|
||||
AXES, KINDS_PRINCIPAUX, DIMENSION_AXE, LIBELLES_STATUT, categories, fichesBibliotheque, grapheAxe, disposerArbre,
|
||||
idCategorie, lireIdCategorie, ligneAuteurs, anneeTexte, type Axe, type ExportRegistre,
|
||||
} from '~/utils/bibliotheque/arbre'
|
||||
|
||||
const arbre = arbreBrut as unknown as ExportRegistre
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const parId = new Map(arbre.oeuvres.map((o) => [o.id, o]))
|
||||
const nomEpoque = new Map(arbre.epoques.map((e) => [e.id, e.nom]))
|
||||
const nomCourant = new Map(arbre.courants.map((c) => [c.id, c.contre_point ? `${c.nom} (contre-point)` : c.nom]))
|
||||
const nbFiches = arbre.oeuvres.filter((o) => o.fiche).length
|
||||
const phrase = nbFiches
|
||||
? `${arbre.oeuvres.length} œuvres au registre, dont ${nbFiches} avec une fiche de lecture composée depuis nos notes, pas encore relue.`
|
||||
: `${arbre.oeuvres.length} œuvres au registre. Aucune fiche de lecture n’est encore ouverte : chaque œuvre est une référence.`
|
||||
|
||||
const fiches = fichesBibliotheque(arbre)
|
||||
const valeursDe = (axe: Axe) => categories(arbre, axe).map((c) => ({ valeur: c.valeur, libelle: c.libelle }))
|
||||
const config: ConfigVueFiches = {
|
||||
dimensions: [
|
||||
{ cle: 'statut', libelle: 'Statut', variante: 'posture', valeurs: (['fiche', 'reference'] as const).filter((s) => s === 'reference' || nbFiches).map((s) => ({ valeur: s, libelle: LIBELLES_STATUT[s] })) },
|
||||
{ cle: 'theme', libelle: 'Thème', variante: 'fonction', valeurs: valeursDe('theme') },
|
||||
{ cle: 'epoque', libelle: 'Époque', variante: 'echelle', valeurs: valeursDe('epoque') },
|
||||
{ cle: 'auteur', libelle: 'Auteur (initiale)', variante: 'echelle', valeurs: valeursDe('auteur') },
|
||||
],
|
||||
tris: ['ordre', 'nom', 'pertinence'],
|
||||
triDefaut: 'ordre',
|
||||
libellesTri: { ordre: 'Année' },
|
||||
groupes: [
|
||||
{ cle: 'epoque', libelle: 'Époque', dimension: 'epoque', sans: 'Sans date au registre' },
|
||||
{ cle: 'theme', libelle: 'Thème', dimension: 'theme', sans: 'Sans thème au registre' },
|
||||
],
|
||||
etats: ['carte', 'mixte', 'fiches'],
|
||||
sousVues: { parametre: 'axe', valeurs: AXES, defaut: 'theme' },
|
||||
}
|
||||
const vf = useVueFiches(fiches, config, { etatDefaut: 'carte' })
|
||||
|
||||
// ── L'arborescence : l'axe choisi, le chemin (filtre de l'axe, sinon les catégories de la fiche ouverte) ──
|
||||
const LIBELLE_AXE: Record<Axe, string> = { theme: 'Thème', epoque: 'Époque', auteur: 'Initiale de l’auteur' }
|
||||
const axe = computed<Axe>(() => (AXES.some((a) => a.valeur === vf.etat.sousVue) ? vf.etat.sousVue : 'theme') as Axe)
|
||||
const oeuvre = computed(() => (vf.ficheId ? parId.get(vf.ficheId) : undefined))
|
||||
const filtreAxe = computed(() => vf.etat.filtres[DIMENSION_AXE[axe.value]] ?? [])
|
||||
const focus = computed(() => {
|
||||
if (filtreAxe.value.length) return filtreAxe.value
|
||||
const f = vf.ficheOuverte as MiniFiche | null
|
||||
return f?.etiquettes?.[DIMENSION_AXE[axe.value]] ?? []
|
||||
})
|
||||
const filtresActifs = computed(() => vf.nbActifs > 0 || !!vf.q.trim())
|
||||
const graphe = computed(() => {
|
||||
// Les œuvres filtrées hors du résultat ne sont pas dans le graphe ; le filtre de l'axe, lui, est le chemin
|
||||
const garder = filtresActifs.value ? new Set([...vf.idsResultat].map(String)) : null
|
||||
const g = grapheAxe(arbre, axe.value, focus.value, garder, vf.ficheId)
|
||||
amorcer(g.noeuds, g.liens, new Set(KINDS_PRINCIPAUX), disposerArbre(g.noeuds, g.liens))
|
||||
return g
|
||||
})
|
||||
const selection = computed(() => vf.ficheId ?? (filtreAxe.value.length === 1 ? idCategorie(axe.value, filtreAxe.value[0]) : null))
|
||||
/** Sans sélection, filtres actifs : les catégories qui gardent au moins une œuvre restent allumées. */
|
||||
const retenus = computed<Set<string> | null>(() => {
|
||||
if (!filtresActifs.value) return null
|
||||
const ids = new Set([...vf.idsResultat].map(String))
|
||||
for (const f of fiches) if (ids.has(String(f.id))) for (const v of f.etiquettes?.[DIMENSION_AXE[axe.value]] ?? []) ids.add(idCategorie(axe.value, v))
|
||||
return ids
|
||||
})
|
||||
const libelleKind = (k: string) => (k === 'axe' ? LIBELLE_AXE[axe.value].toLowerCase() : k === 'fiche' ? 'fiche de lecture' : 'référence seulement')
|
||||
|
||||
/** Clic sur une catégorie : elle devient le chemin (re-clic : on remonte) ; sur une œuvre : sa fiche. */
|
||||
function choisir(id: string) {
|
||||
const c = lireIdCategorie(id)
|
||||
if (!c) { vf.ouvrirFiche(id); return }
|
||||
const dim = DIMENSION_AXE[c.axe]
|
||||
const query: Record<string, any> = { ...route.query }
|
||||
if (filtreAxe.value.length === 1 && filtreAxe.value[0] === c.valeur && !vf.ficheId) delete query[dim]
|
||||
else query[dim] = c.valeur
|
||||
delete query.fiche
|
||||
router.replace({ query })
|
||||
}
|
||||
const lienPage = (f: MiniFiche) => {
|
||||
const o = parId.get(String(f.id))
|
||||
return o?.fiche ? `/bibliotheque/fiche/${o.fiche}` : null
|
||||
}
|
||||
|
||||
// ── La fiche : chargée au clic (ou par l'URL partagée), jamais dans le paquet de la page ──
|
||||
const slug = computed(() => oeuvre.value?.fiche ?? null)
|
||||
const { data: ficheLue, status: chargement } = await useAsyncData(
|
||||
() => `bibliotheque-fiche-${slug.value ?? 'aucune'}`,
|
||||
() => (slug.value ? $fetch<any>(`/api/bibliotheque/fiche/${slug.value}`) : Promise.resolve(null)),
|
||||
{ watch: [slug] },
|
||||
)
|
||||
const agrandi = ref(false)
|
||||
watch(() => vf.ficheId, (id) => { if (!id) agrandi.value = false })
|
||||
const agrandiVu = computed(() => agrandi.value && !!oeuvre.value?.fiche && vf.largeur !== 'telephone')
|
||||
|
||||
useSeoMeta({
|
||||
title: () => (oeuvre.value ? `${oeuvre.value.titre} — Bibliothèque — AEP` : 'Bibliothèque — AEP'),
|
||||
description: 'Les livres que lit AEP, rangés par thème, par époque ou par auteur : le registre des œuvres en arborescence, et les fiches de lecture.',
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.bib { height: 100%; min-height: 0; display: flex; flex-direction: column; overflow: hidden; color: var(--text); }
|
||||
.bib-tete {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
gap: var(--space-2xs) var(--space-md);
|
||||
padding: var(--space-xs) var(--space-md);
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: var(--surface);
|
||||
}
|
||||
.bib-tete__titre { margin: 0; font-size: var(--fs-lg); font-weight: var(--fw-bold); line-height: 1.25; }
|
||||
.bib-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); }
|
||||
.bib-bandeau a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
|
||||
.bib-bandeau a:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--radius-sm); }
|
||||
.bib-vue { flex: 1 1 0; min-height: 0; min-width: 0; }
|
||||
|
||||
/* Le graphe et sa légende : la légende du composant (concepts et sources) ne vaut pas ici */
|
||||
.bib-graphe { position: relative; flex: 1; min-height: 0; min-width: 0; display: flex; }
|
||||
.bib-graphe :deep(.gc__legende) { display: none; }
|
||||
/* Une œuvre à fiche : petit rond plein ; une catégorie : rond creux (défaut du composant) */
|
||||
.bib-graphe :deep(.gc__noeud[data-id^='oeu:'] .gc__rond) { background: var(--text); }
|
||||
.bib-graphe :deep(.gc__noeud[data-id^='oeu:'] .gc__libelle) { font-weight: var(--fw-medium); }
|
||||
.bib-graphe :deep(.gc__noeud--sel[data-id^='oeu:'] .gc__rond) { background: var(--accent); }
|
||||
.bib-legende {
|
||||
position: absolute;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
.bib-legende li { display: inline-flex; align-items: center; gap: var(--space-2xs); }
|
||||
.bib-legende__cat { width: 12px; height: 12px; border-radius: var(--radius-full); border: 2px solid var(--text); background: var(--surface); }
|
||||
.bib-legende__fiche { width: 10px; height: 10px; border-radius: var(--radius-full); border: 2px solid var(--text); background: var(--text); }
|
||||
.bib-legende__ref { width: 9px; height: 9px; border-radius: 2px; background: color-mix(in srgb, var(--text) 52%, var(--bg-alt)); }
|
||||
.bib-masquees {
|
||||
position: absolute;
|
||||
right: var(--space-sm);
|
||||
top: var(--space-xs);
|
||||
margin: 0;
|
||||
padding: var(--space-2xs) var(--space-xs);
|
||||
border-radius: var(--radius-sm);
|
||||
background: color-mix(in srgb, var(--bg-alt) 88%, transparent);
|
||||
font-size: var(--fs-xs);
|
||||
color: color-mix(in srgb, var(--text) 78%, transparent);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Le panneau : une fiche de 2 000 mots demande plus que les 380 px de la vue fiches */
|
||||
@media (min-width: 1024px) {
|
||||
.bib :deep(.vf--detail .vf-corps) { grid-template-columns: var(--vf-liste) minmax(0, 1fr) min(34rem, 42vw); }
|
||||
.bib :deep(.vf--detail.vf--fiches .vf-corps) { grid-template-columns: minmax(0, 1fr) 0 min(34rem, 42vw); }
|
||||
.bib :deep(.vf--detail.vf--carte .vf-corps) { grid-template-columns: 0 minmax(0, 1fr) min(34rem, 42vw); }
|
||||
}
|
||||
/* « Agrandir » : le graphe et la liste s'effacent, la fiche prend la largeur ; l'adresse ne change pas */
|
||||
@media (min-width: 768px) {
|
||||
.bib--agrandi :deep(.vf-corps),
|
||||
.bib--agrandi :deep(.vf--detail .vf-corps),
|
||||
.bib--agrandi :deep(.vf--detail.vf--fiches .vf-corps),
|
||||
.bib--agrandi :deep(.vf--detail.vf--carte .vf-corps) { grid-template-columns: 0 0 minmax(0, 1fr); }
|
||||
.bib--agrandi :deep(.vf-liste),
|
||||
.bib--agrandi :deep(.vf-carte) { visibility: hidden; }
|
||||
.bib--agrandi :deep(.vf-detail) { grid-column: 3; border-left: none; }
|
||||
.bib--agrandi :deep(.vf-detail__corps) { padding-inline: max(var(--space-md), calc((100% - 68ch) / 2)); }
|
||||
}
|
||||
@media (min-width: 768px) and (max-width: 1023.98px) {
|
||||
.bib--agrandi :deep(.vf-corps) { grid-template-columns: 0 minmax(0, 1fr); }
|
||||
.bib--agrandi :deep(.vf-detail) { grid-column: 2; }
|
||||
}
|
||||
|
||||
/* La fiche d'une œuvre dans le panneau */
|
||||
.bo { min-width: 0; overflow-wrap: anywhere; }
|
||||
.bo p { margin: 0; }
|
||||
.bo__titre { margin: 0 0 var(--space-2xs); font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: var(--lh-tight); }
|
||||
.bo__meta { font-size: var(--fs-sm); color: color-mix(in srgb, var(--text) 78%, transparent); }
|
||||
.bo__themes { margin-top: var(--space-xs); }
|
||||
.bo__statut { margin-top: var(--space-sm) !important; font-size: var(--fs-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: 0.04em; color: color-mix(in srgb, var(--text) 78%, transparent); }
|
||||
.bo__agrandir {
|
||||
min-height: 44px;
|
||||
margin: var(--space-xs) 0 var(--space-sm);
|
||||
padding: 0 var(--space-sm);
|
||||
border: 1px solid var(--border-strong, var(--border));
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--surface);
|
||||
color: var(--text);
|
||||
font: inherit;
|
||||
font-size: var(--fs-sm);
|
||||
font-weight: var(--fw-medium);
|
||||
cursor: pointer;
|
||||
}
|
||||
.bo__agrandir[aria-pressed='true'] { background: var(--text); color: var(--surface); }
|
||||
.bo__agrandir:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
|
||||
.bo__etat { margin-top: var(--space-sm) !important; font-size: var(--fs-sm); }
|
||||
.bo__reference { margin-top: var(--space-xs); display: flex; flex-direction: column; gap: var(--space-2xs); font-size: var(--fs-sm); line-height: 1.5; }
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.bib-tete { padding: var(--space-2xs) var(--space-sm); }
|
||||
.bib-bandeau { font-size: var(--fs-xs); }
|
||||
}
|
||||
</style>
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
<script setup lang="ts">
|
||||
navigateTo('/media', { redirectCode: 301 })
|
||||
navigateTo('/bibliotheque', { redirectCode: 301 })
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user