initiation librodrome

This commit is contained in:
Yvv
2026-02-20 12:55:10 +01:00
commit 35e2897a73
208 changed files with 18951 additions and 0 deletions

View File

@@ -0,0 +1,94 @@
<template>
<div>
<div class="flex items-center justify-between mb-6">
<div>
<NuxtLink to="/admin/book" class="text-sm text-white/40 hover:text-white/60 transition-colors">
Chapitres
</NuxtLink>
<h1 class="font-display text-2xl font-bold text-white mt-1">
{{ chapter?.slug }}
</h1>
</div>
<AdminSaveButton :saving="saving" :saved="saved" @save="save" />
</div>
<template v-if="chapter">
<AdminFormSection title="Frontmatter" open>
<textarea
v-model="frontmatter"
class="fm-textarea"
rows="6"
spellcheck="false"
/>
</AdminFormSection>
<AdminFormSection title="Contenu Markdown" open>
<AdminMarkdownEditor v-model="body" :rows="30" />
</AdminFormSection>
</template>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: 'admin',
middleware: 'admin',
})
const route = useRoute()
const slug = computed(() => route.params.slug as string)
const { data: chapter } = await useFetch(() => `/api/admin/chapters/${slug.value}`)
const frontmatter = ref('')
const body = ref('')
watch(chapter, (val) => {
if (val) {
frontmatter.value = val.frontmatter ?? ''
body.value = val.body ?? ''
}
}, { immediate: true })
const saving = ref(false)
const saved = ref(false)
async function save() {
saving.value = true
saved.value = false
try {
await $fetch(`/api/admin/chapters/${slug.value}`, {
method: 'PUT',
body: {
frontmatter: frontmatter.value,
body: body.value,
},
})
saved.value = true
setTimeout(() => { saved.value = false }, 2000)
}
finally {
saving.value = false
}
}
</script>
<style scoped>
.fm-textarea {
width: 100%;
padding: 0.75rem;
border: 1px solid hsl(20 8% 18%);
border-radius: 0.5rem;
background: hsl(20 8% 4%);
color: hsl(36 80% 76%);
font-family: var(--font-mono, monospace);
font-size: 0.85rem;
line-height: 1.7;
resize: vertical;
}
.fm-textarea:focus {
outline: none;
border-color: hsl(12 76% 48% / 0.5);
}
</style>

View File

@@ -0,0 +1,59 @@
<template>
<div>
<h1 class="font-display text-2xl font-bold text-white mb-6">Chapitres</h1>
<div class="flex flex-col gap-2">
<NuxtLink
v-for="chapter in chapters"
:key="chapter.slug"
:to="`/admin/book/${chapter.slug}`"
class="chapter-item"
>
<span class="chapter-order">{{ String(chapter.order ?? 0).padStart(2, '0') }}</span>
<span class="chapter-title">{{ chapter.title }}</span>
<div class="i-lucide-chevron-right h-4 w-4 text-white/20" />
</NuxtLink>
</div>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: 'admin',
middleware: 'admin',
})
const { data: chapters } = await useFetch('/api/admin/chapters')
</script>
<style scoped>
.chapter-item {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.75rem 1rem;
border: 1px solid hsl(20 8% 14%);
border-radius: 0.5rem;
text-decoration: none;
transition: all 0.2s;
}
.chapter-item:hover {
border-color: hsl(12 76% 48% / 0.3);
background: hsl(20 8% 6%);
}
.chapter-order {
font-family: var(--font-mono, monospace);
font-size: 0.85rem;
color: hsl(12 76% 48% / 0.5);
font-weight: 600;
width: 1.75rem;
}
.chapter-title {
flex: 1;
color: white;
font-weight: 500;
}
</style>

60
app/pages/admin/index.vue Normal file
View File

@@ -0,0 +1,60 @@
<template>
<div>
<h1 class="font-display text-2xl font-bold text-white mb-6">Dashboard</h1>
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
<NuxtLink to="/admin/site" class="dash-card">
<div class="i-lucide-globe h-8 w-8 text-primary mb-2" />
<h2 class="text-lg font-semibold text-white">Site</h2>
<p class="text-sm text-white/50">Identité, navigation, footer</p>
</NuxtLink>
<NuxtLink to="/admin/pages/home" class="dash-card">
<div class="i-lucide-home h-8 w-8 text-primary mb-2" />
<h2 class="text-lg font-semibold text-white">Pages</h2>
<p class="text-sm text-white/50">Contenus des pages publiques</p>
</NuxtLink>
<NuxtLink to="/admin/book" class="dash-card">
<div class="i-lucide-book-open h-8 w-8 text-primary mb-2" />
<h2 class="text-lg font-semibold text-white">Chapitres</h2>
<p class="text-sm text-white/50">Éditer le contenu du livre</p>
</NuxtLink>
<NuxtLink to="/admin/songs" class="dash-card">
<div class="i-lucide-music h-8 w-8 text-accent mb-2" />
<h2 class="text-lg font-semibold text-white">Chansons</h2>
<p class="text-sm text-white/50">Métadonnées des pistes</p>
</NuxtLink>
<NuxtLink to="/admin/media" class="dash-card">
<div class="i-lucide-image h-8 w-8 text-accent mb-2" />
<h2 class="text-lg font-semibold text-white">Médias</h2>
<p class="text-sm text-white/50">Images, audio, PDF</p>
</NuxtLink>
</div>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: 'admin',
middleware: 'admin',
})
</script>
<style scoped>
.dash-card {
padding: 1.5rem;
border-radius: 0.75rem;
border: 1px solid hsl(20 8% 14%);
background: hsl(20 8% 6%);
text-decoration: none;
transition: all 0.2s;
}
.dash-card:hover {
border-color: hsl(12 76% 48% / 0.3);
background: hsl(20 8% 8%);
}
</style>

134
app/pages/admin/login.vue Normal file
View File

@@ -0,0 +1,134 @@
<template>
<div class="login-page">
<form class="login-form" @submit.prevent="login">
<div class="i-lucide-lock h-10 w-10 text-primary mb-4 mx-auto" />
<h1 class="font-display text-2xl font-bold text-white text-center mb-6">Administration</h1>
<div v-if="error" class="login-error">
{{ error }}
</div>
<label class="login-label" for="password">Mot de passe</label>
<input
id="password"
v-model="password"
type="password"
class="login-input"
placeholder="Entrez le mot de passe"
autofocus
/>
<button type="submit" class="login-btn" :disabled="loading">
<div v-if="loading" class="i-lucide-loader-2 h-4 w-4 animate-spin" />
Se connecter
</button>
</form>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: false,
})
const password = ref('')
const error = ref('')
const loading = ref(false)
async function login() {
error.value = ''
loading.value = true
try {
await $fetch('/api/admin/auth/login', {
method: 'POST',
body: { password: password.value },
})
navigateTo('/admin')
}
catch {
error.value = 'Mot de passe incorrect'
}
finally {
loading.value = false
}
}
</script>
<style scoped>
.login-page {
min-height: 100dvh;
display: flex;
align-items: center;
justify-content: center;
background: hsl(20 8% 3.5%);
}
.login-form {
width: 100%;
max-width: 24rem;
padding: 2.5rem;
border: 1px solid hsl(20 8% 14%);
border-radius: 1rem;
background: hsl(20 8% 6%);
}
.login-error {
padding: 0.5rem 0.75rem;
border-radius: 0.5rem;
background: hsl(0 60% 45% / 0.15);
color: hsl(0 60% 70%);
font-size: 0.85rem;
margin-bottom: 1rem;
}
.login-label {
display: block;
font-size: 0.8rem;
font-weight: 500;
color: hsl(20 8% 60%);
margin-bottom: 0.375rem;
}
.login-input {
width: 100%;
padding: 0.625rem 0.75rem;
border-radius: 0.5rem;
border: 1px solid hsl(20 8% 18%);
background: hsl(20 8% 4%);
color: white;
font-size: 0.9rem;
margin-bottom: 1.25rem;
}
.login-input:focus {
outline: none;
border-color: hsl(12 76% 48% / 0.5);
}
.login-btn {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
padding: 0.625rem;
border-radius: 0.5rem;
border: none;
background: hsl(12 76% 48%);
color: white;
font-weight: 600;
font-size: 0.9rem;
cursor: pointer;
transition: background 0.2s;
}
.login-btn:hover:not(:disabled) {
background: hsl(12 76% 42%);
}
.login-btn:disabled {
opacity: 0.7;
cursor: wait;
}
</style>

32
app/pages/admin/media.vue Normal file
View File

@@ -0,0 +1,32 @@
<template>
<div>
<h1 class="font-display text-2xl font-bold text-white mb-6">Médias</h1>
<AdminMediaUpload class="mb-6" @uploaded="refresh" />
<AdminMediaBrowser
v-if="files"
:files="files"
@delete="deleteFile"
/>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: 'admin',
middleware: 'admin',
})
const { data: files, refresh } = await useFetch('/api/admin/media')
async function deleteFile(path: string) {
if (!confirm(`Supprimer ${path} ?`)) return
// Remove leading slash for the API path
const apiPath = path.startsWith('/') ? path.slice(1) : path
await $fetch(`/api/admin/media/${apiPath}`, { method: 'DELETE' })
await refresh()
}
</script>

View File

@@ -0,0 +1,209 @@
<template>
<div>
<div class="flex items-center justify-between mb-6">
<h1 class="font-display text-2xl font-bold text-white">Messages</h1>
<span class="text-sm text-white/40">{{ messages?.length || 0 }} message(s)</span>
</div>
<div v-if="messages?.length" class="space-y-3">
<div
v-for="msg in messages"
:key="msg.id"
class="msg-row"
:class="{ 'msg-row--draft': !msg.published }"
>
<!-- En-tête -->
<div class="flex items-center justify-between gap-4 mb-2">
<div class="flex items-center gap-2 min-w-0">
<span class="font-semibold text-white text-sm truncate">{{ msg.author }}</span>
<span v-if="msg.email" class="text-white/30 text-xs truncate">{{ msg.email }}</span>
</div>
<div class="flex items-center gap-2 shrink-0">
<span class="text-xs text-white/30">{{ formatDate(msg.createdAt) }}</span>
<span
class="status-badge"
:class="msg.published ? 'status-badge--pub' : 'status-badge--draft'"
>
{{ msg.published ? 'Publié' : 'En attente' }}
</span>
</div>
</div>
<!-- Texte éditable -->
<div v-if="editing === msg.id" class="mb-3">
<input
v-model="editForm.author"
class="admin-input mb-2 w-full"
placeholder="Auteur"
/>
<textarea
v-model="editForm.text"
class="admin-input w-full"
rows="3"
/>
</div>
<p v-else class="text-white/70 text-sm leading-relaxed mb-3">{{ msg.text }}</p>
<!-- Actions -->
<div class="flex items-center gap-2">
<button class="action-btn" @click="togglePublished(msg)">
<div :class="msg.published ? 'i-lucide-eye-off' : 'i-lucide-eye'" class="h-3.5 w-3.5" />
{{ msg.published ? 'Dépublier' : 'Publier' }}
</button>
<template v-if="editing === msg.id">
<button class="action-btn action-btn--save" @click="saveEdit(msg)">
<div class="i-lucide-check h-3.5 w-3.5" />
Valider
</button>
<button class="action-btn" @click="editing = null">
Annuler
</button>
</template>
<button v-else class="action-btn" @click="startEdit(msg)">
<div class="i-lucide-pencil h-3.5 w-3.5" />
Modifier
</button>
<button class="action-btn action-btn--danger ml-auto" @click="remove(msg)">
<div class="i-lucide-trash-2 h-3.5 w-3.5" />
Supprimer
</button>
</div>
</div>
</div>
<p v-else class="text-center text-white/40 py-12">Aucun message.</p>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: 'admin',
middleware: 'admin',
})
const { data: messages, refresh } = await useFetch<any[]>('/api/admin/messages')
const editing = ref<number | null>(null)
const editForm = reactive({ author: '', text: '' })
function startEdit(msg: any) {
editing.value = msg.id
editForm.author = msg.author
editForm.text = msg.text
}
async function saveEdit(msg: any) {
await $fetch(`/api/admin/messages/${msg.id}`, {
method: 'PUT',
body: { author: editForm.author, text: editForm.text },
})
editing.value = null
await refresh()
}
async function togglePublished(msg: any) {
await $fetch(`/api/admin/messages/${msg.id}`, {
method: 'PUT',
body: { published: !msg.published },
})
await refresh()
}
async function remove(msg: any) {
if (!confirm(`Supprimer le message de "${msg.author}" ?`)) return
await $fetch(`/api/admin/messages/${msg.id}`, { method: 'DELETE' })
await refresh()
}
function formatDate(iso: string) {
return new Date(iso).toLocaleDateString('fr-FR', {
day: 'numeric',
month: 'short',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
})
}
</script>
<style scoped>
.msg-row {
background: hsl(20 8% 6%);
border: 1px solid hsl(20 8% 14%);
border-radius: 0.75rem;
padding: 1rem 1.25rem;
}
.msg-row--draft {
border-left: 3px solid hsl(36 80% 52%);
}
.status-badge {
font-size: 0.65rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
padding: 0.15rem 0.5rem;
border-radius: 9999px;
}
.status-badge--pub {
background: hsl(142 70% 40% / 0.15);
color: hsl(142 70% 60%);
}
.status-badge--draft {
background: hsl(36 80% 52% / 0.15);
color: hsl(36 80% 66%);
}
.admin-input {
padding: 0.375rem 0.5rem;
border-radius: 0.375rem;
border: 1px solid hsl(20 8% 18%);
background: hsl(20 8% 6%);
color: white;
font-size: 0.8rem;
}
.admin-input:focus {
outline: none;
border-color: hsl(12 76% 48% / 0.5);
}
.action-btn {
display: inline-flex;
align-items: center;
gap: 0.35rem;
padding: 0.3rem 0.6rem;
border-radius: 0.375rem;
font-size: 0.75rem;
color: hsl(20 8% 60%);
background: none;
border: 1px solid hsl(20 8% 16%);
cursor: pointer;
transition: all 0.2s;
}
.action-btn:hover {
background: hsl(20 8% 10%);
color: white;
}
.action-btn--save {
border-color: hsl(142 70% 40% / 0.3);
color: hsl(142 70% 60%);
}
.action-btn--save:hover {
background: hsl(142 70% 40% / 0.1);
}
.action-btn--danger:hover {
background: hsl(0 70% 40% / 0.1);
border-color: hsl(0 70% 40% / 0.3);
color: hsl(0 70% 60%);
}
</style>

View File

@@ -0,0 +1,98 @@
<template>
<div>
<div class="flex items-center justify-between mb-6">
<div>
<NuxtLink to="/admin" class="text-sm text-white/40 hover:text-white/60 transition-colors">
Dashboard
</NuxtLink>
<h1 class="font-display text-2xl font-bold text-white mt-1">
Page : {{ pageName }}
</h1>
</div>
<AdminSaveButton :saving="saving" :saved="saved" @save="save" />
</div>
<div v-if="data" class="page-editor">
<AdminFormSection title="Contenu YAML" open>
<div class="yaml-editor-wrapper">
<textarea
v-model="yamlContent"
class="yaml-textarea"
rows="30"
spellcheck="false"
/>
</div>
</AdminFormSection>
</div>
<p v-else-if="error" class="text-red-400">
Erreur de chargement : {{ error.message }}
</p>
</div>
</template>
<script setup lang="ts">
import yaml from 'yaml'
definePageMeta({
layout: 'admin',
middleware: 'admin',
})
const route = useRoute()
const pageName = computed(() => route.params.name as string)
const { data, error } = await useFetch(() => `/api/content/pages/${pageName.value}`)
const yamlContent = ref('')
watch(data, (val) => {
if (val) {
yamlContent.value = yaml.stringify(val, { lineWidth: 120 })
}
}, { immediate: true })
const saving = ref(false)
const saved = ref(false)
async function save() {
saving.value = true
saved.value = false
try {
const parsed = yaml.parse(yamlContent.value)
await $fetch(`/api/admin/content/pages/${pageName.value}`, {
method: 'PUT',
body: parsed,
})
saved.value = true
setTimeout(() => { saved.value = false }, 2000)
}
catch (e: any) {
alert('Erreur YAML : ' + (e?.message ?? 'format invalide'))
}
finally {
saving.value = false
}
}
</script>
<style scoped>
.yaml-textarea {
width: 100%;
padding: 1rem;
border: 1px solid hsl(20 8% 18%);
border-radius: 0.5rem;
background: hsl(20 8% 4%);
color: hsl(36 80% 76%);
font-family: var(--font-mono, monospace);
font-size: 0.85rem;
line-height: 1.7;
resize: vertical;
min-height: 20rem;
}
.yaml-textarea:focus {
outline: none;
border-color: hsl(12 76% 48% / 0.5);
}
</style>

116
app/pages/admin/site.vue Normal file
View File

@@ -0,0 +1,116 @@
<template>
<div>
<div class="flex items-center justify-between mb-6">
<h1 class="font-display text-2xl font-bold text-white">Configuration du site</h1>
<AdminSaveButton :saving="saving" :saved="saved" @save="save" />
</div>
<template v-if="data">
<AdminFormSection title="Identité" open>
<AdminFieldText v-model="data.identity.name" label="Nom du site" />
<AdminFieldTextarea v-model="data.identity.description" label="Description" :rows="3" />
<AdminFieldText v-model="data.identity.url" label="URL" />
</AdminFormSection>
<AdminFormSection title="Navigation" open>
<AdminFieldList
v-model="data.navigation"
label="Liens de navigation"
add-label="Ajouter un lien"
:default-item="() => ({ label: '', to: '/' })"
>
<template #default="{ item, update }">
<div class="flex gap-2 flex-1">
<input
:value="item.label"
class="admin-input flex-1"
placeholder="Label"
@input="update({ ...item, label: ($event.target as HTMLInputElement).value })"
/>
<input
:value="item.to"
class="admin-input w-32"
placeholder="/chemin"
@input="update({ ...item, to: ($event.target as HTMLInputElement).value })"
/>
</div>
</template>
</AdminFieldList>
</AdminFormSection>
<AdminFormSection title="Pied de page">
<AdminFieldText v-model="data.footer.credits" label="Crédits" />
<AdminFieldList
v-model="data.footer.links"
label="Liens"
add-label="Ajouter un lien"
:default-item="() => ({ label: '', to: '/' })"
>
<template #default="{ item, update }">
<div class="flex gap-2 flex-1">
<input
:value="item.label"
class="admin-input flex-1"
placeholder="Label"
@input="update({ ...item, label: ($event.target as HTMLInputElement).value })"
/>
<input
:value="item.to"
class="admin-input w-32"
placeholder="/chemin"
@input="update({ ...item, to: ($event.target as HTMLInputElement).value })"
/>
</div>
</template>
</AdminFieldList>
</AdminFormSection>
<AdminFormSection title="GrateWizard">
<AdminFieldText v-model="data.gratewizard.url" label="URL de l'application" />
</AdminFormSection>
</template>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: 'admin',
middleware: 'admin',
})
const { data } = await useFetch('/api/content/site')
const saving = ref(false)
const saved = ref(false)
async function save() {
saving.value = true
saved.value = false
try {
await $fetch('/api/admin/content/site', {
method: 'PUT',
body: data.value,
})
saved.value = true
setTimeout(() => { saved.value = false }, 2000)
}
finally {
saving.value = false
}
}
</script>
<style scoped>
.admin-input {
padding: 0.375rem 0.5rem;
border-radius: 0.375rem;
border: 1px solid hsl(20 8% 18%);
background: hsl(20 8% 6%);
color: white;
font-size: 0.8rem;
}
.admin-input:focus {
outline: none;
border-color: hsl(12 76% 48% / 0.5);
}
</style>

92
app/pages/admin/songs.vue Normal file
View File

@@ -0,0 +1,92 @@
<template>
<div>
<div class="flex items-center justify-between mb-6">
<h1 class="font-display text-2xl font-bold text-white">Chansons</h1>
<AdminSaveButton :saving="saving" :saved="saved" @save="save" />
</div>
<template v-if="config">
<AdminFormSection title="Métadonnées des chansons" open>
<div
v-for="(song, i) in config.songs"
:key="i"
class="song-row"
>
<span class="song-num">{{ i + 1 }}</span>
<div class="flex-1 grid gap-2 sm:grid-cols-2">
<input
v-model="song.title"
class="admin-input"
placeholder="Titre"
/>
<input
v-model="song.file"
class="admin-input"
placeholder="/audio/fichier.mp3"
/>
</div>
</div>
</AdminFormSection>
</template>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: 'admin',
middleware: 'admin',
})
const { data: config } = await useFetch('/api/content/config')
const saving = ref(false)
const saved = ref(false)
async function save() {
saving.value = true
saved.value = false
try {
await $fetch('/api/admin/content/config', {
method: 'PUT',
body: config.value,
})
saved.value = true
setTimeout(() => { saved.value = false }, 2000)
}
finally {
saving.value = false
}
}
</script>
<style scoped>
.song-row {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.5rem;
border-bottom: 1px solid hsl(20 8% 10%);
}
.song-num {
font-family: var(--font-mono, monospace);
font-size: 0.8rem;
color: hsl(20 8% 40%);
width: 1.25rem;
text-align: right;
}
.admin-input {
padding: 0.375rem 0.5rem;
border-radius: 0.375rem;
border: 1px solid hsl(20 8% 18%);
background: hsl(20 8% 6%);
color: white;
font-size: 0.8rem;
width: 100%;
}
.admin-input:focus {
outline: none;
border-color: hsl(12 76% 48% / 0.5);
}
</style>