blob: 62fd7f36c29f05a20f4ace1ad2537ce3355808c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
<?php // Gallery: public feed of all posts with pagination.?>
<div class="gallery-page">
<h1>Gallery</h1>
<?php if (empty($posts)): ?>
<p class="hint">No posts yet. Be the first!</p>
<?php endif; ?>
<div class="gallery-feed">
<?php foreach ($posts as $post): ?>
<article class="gallery-post">
<div class="post-header">
<strong><?= htmlspecialchars($post['username']) ?></strong>
<time><?= date('M j, Y', strtotime($post['created_at'])) ?></time>
</div>
<img src="/<?= htmlspecialchars($post['image_path']) ?>" alt="Post by <?= htmlspecialchars($post['username']) ?>">
</article>
<?php endforeach; ?>
</div>
<?php if ($totalPages > 1): ?>
<nav class="pagination">
<?php if ($page > 1): ?>
<a href="/gallery?page=<?= $page - 1 ?>">« Previous</a>
<?php endif; ?>
<?php for ($i = 1; $i <= $totalPages; $i++): ?>
<?php if ($i === $page): ?>
<span class="current-page"><?= $i ?></span>
<?php else: ?>
<a href="/gallery?page=<?= $i ?>"><?= $i ?></a>
<?php endif; ?>
<?php endfor; ?>
<?php if ($page < $totalPages): ?>
<a href="/gallery?page=<?= $page + 1 ?>">Next »</a>
<?php endif; ?>
</nav>
<?php endif; ?>
</div>
|