feat: avant-premiere - article visible en liste mais verrouille avant sa date de publication
This commit is contained in:
+27
-10
@@ -17,33 +17,50 @@ ob_start();
|
||||
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">
|
||||
<?php foreach ($posts as $i => $post): ?>
|
||||
<?php
|
||||
$html = $Parsedown->text($post['content']);
|
||||
$preview = mb_strimwidth(strip_tags($html), 0, 120, '…');
|
||||
$gradient = $coverGradients[$i % count($coverGradients)];
|
||||
$postUrl = '/post/' . rawurlencode($post['slug']);
|
||||
$html = $Parsedown->text($post['content']);
|
||||
$preview = mb_strimwidth(strip_tags($html), 0, 120, '…');
|
||||
$gradient = $coverGradients[$i % count($coverGradients)];
|
||||
$postUrl = '/post/' . rawurlencode($post['slug']);
|
||||
$isDraft = !$post['published'];
|
||||
$isAvantPremiere = $post['published'] && strtotime((string)($post['published_at'] ?? '')) > time();
|
||||
$isLocked = $isAvantPremiere;
|
||||
?>
|
||||
<div class="col">
|
||||
<article class="card h-100">
|
||||
<?php if (!$post['published']): ?>
|
||||
<?php if ($isDraft): ?>
|
||||
<div class="draft-ribbon">Brouillon</div>
|
||||
<?php elseif ($isAvantPremiere): ?>
|
||||
<div class="premiere-ribbon">Avant-première</div>
|
||||
<?php endif; ?>
|
||||
<div class="card-cover" style="background: <?= $gradient ?>"></div>
|
||||
<div class="card-body d-flex flex-column">
|
||||
<h2 class="card-title">
|
||||
<a href="<?= htmlspecialchars($postUrl) ?>">
|
||||
<?php if ($isLocked): ?>
|
||||
<?= htmlspecialchars($post['title']) ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<a href="<?= htmlspecialchars($postUrl) ?>">
|
||||
<?= htmlspecialchars($post['title']) ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</h2>
|
||||
<p class="card-text flex-grow-1"><?= htmlspecialchars($preview) ?></p>
|
||||
<div class="post-entry-meta mt-auto">
|
||||
<span><?= htmlspecialchars(date('d/m/Y', strtotime((string)($post['created_at'] ?? '')))) ?></span>
|
||||
<?php if ($isAvantPremiere): ?>
|
||||
<span class="text-muted">Disponible le <?= htmlspecialchars(date('d/m/Y \à H\hi', strtotime((string)($post['published_at'] ?? '')))) ?></span>
|
||||
<?php else: ?>
|
||||
<span><?= htmlspecialchars(date('d/m/Y', strtotime((string)($post['created_at'] ?? '')))) ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if (function_exists('isAdmin') && isAdmin()): ?>
|
||||
<a href="/?action=edit&uuid=<?= htmlspecialchars($post['uuid']) ?>" class="post-entry-edit">modifier</a>
|
||||
<?php endif; ?>
|
||||
<a href="<?= htmlspecialchars($postUrl) ?>" class="post-entry-read">→ lire</a>
|
||||
<?php if (!$isLocked): ?>
|
||||
<a href="<?= htmlspecialchars($postUrl) ?>" class="post-entry-read">→ lire</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<a href="<?= htmlspecialchars($postUrl) ?>" class="stretched-link"></a>
|
||||
<?php if (!$isLocked): ?>
|
||||
<a href="<?= htmlspecialchars($postUrl) ?>" class="stretched-link"></a>
|
||||
<?php endif; ?>
|
||||
</article>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
Reference in New Issue
Block a user