dbd76556fb
Ajoute un concept de "livre" (série de pages ordonnées) avec : - BookManager : CRUD JSON dans data/books/<slug>.json - Route /book/<slug> → page de sommaire (table des matières) - Navigation chapitre ← → en bas de chaque article membre du livre - Bandeau "Chapitre X/N — Nom du livre" en haut de l'article - Admin → onglet Livres : créer, éditer, supprimer un livre, ajouter/ordonner les pages via textarea slug Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
63 lines
2.9 KiB
PHP
63 lines
2.9 KiB
PHP
<?php ob_start(); ?>
|
|
|
|
<div class="book-page">
|
|
|
|
<div class="book-header mb-4">
|
|
<p class="book-label">Livre</p>
|
|
<h1 class="h2 mb-2"><?= htmlspecialchars($book['title']) ?></h1>
|
|
<?php if (!empty($book['description'])): ?>
|
|
<p class="lead text-muted"><?= htmlspecialchars($book['description']) ?></p>
|
|
<?php endif; ?>
|
|
<p class="text-muted small"><?= count($bookArticles) ?> page<?= count($bookArticles) > 1 ? 's' : '' ?></p>
|
|
</div>
|
|
|
|
<?php if (empty($bookArticles)): ?>
|
|
<p class="text-muted">Ce livre ne contient pas encore de pages publiées.</p>
|
|
<?php else: ?>
|
|
<ol class="book-chapters">
|
|
<?php foreach ($bookArticles as $i => $a):
|
|
$cat = trim($a['category'] ?? '');
|
|
$gradient = coverGradient($cat !== '' ? $cat : $a['uuid'], $allCats);
|
|
$cover = $a['cover'] ?? '';
|
|
$date = $a['published_at'] ? date('d/m/Y', strtotime((string)$a['published_at'])) : '';
|
|
?>
|
|
<li class="book-chapter">
|
|
<a href="/post/<?= rawurlencode($a['slug'] ?? '') ?>" class="book-chapter-link">
|
|
<span class="book-chapter-num"><?= $i + 1 ?></span>
|
|
<div class="book-chapter-thumb" style="<?= $cover !== ''
|
|
? 'background-image:url(/file?uuid=' . rawurlencode($a['uuid']) . '&name=' . rawurlencode($cover) . ');background-size:cover;background-position:center'
|
|
: 'background:' . htmlspecialchars($gradient) ?>">
|
|
</div>
|
|
<div class="book-chapter-body">
|
|
<div class="book-chapter-title"><?= htmlspecialchars($a['title'] ?? '') ?></div>
|
|
<div class="book-chapter-meta">
|
|
<?php if ($cat !== ''): ?><?= htmlspecialchars($cat) ?><?php endif; ?>
|
|
<?php if ($cat !== '' && $date !== ''): ?> · <?php endif; ?>
|
|
<?php if ($date !== ''): ?><?= $date ?><?php endif; ?>
|
|
</div>
|
|
<?php if (!$a['published']): ?>
|
|
<span class="badge bg-secondary small">Brouillon</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
</a>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ol>
|
|
<?php endif; ?>
|
|
|
|
<?php if (function_exists('isAdmin') && isAdmin()): ?>
|
|
<div class="mt-4 text-end">
|
|
<a href="/admin/books?edit=<?= rawurlencode($book['slug']) ?>" class="btn btn-sm btn-outline-secondary">
|
|
✎ Modifier ce livre
|
|
</a>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
$content = ob_get_clean();
|
|
$title = htmlspecialchars($book['title']) . ' — ' . siteTitle();
|
|
$canonical = rtrim(APP_URL, '/') . '/book/' . rawurlencode($book['slug']);
|
|
include __DIR__ . '/layout.php';
|