source: Klonkt/src/routes/users.js@ b9beb16

main
Last change on this file since b9beb16 was adb6291, checked in by roboburr <roboburr@…>, 2 months ago

feat(video-cover): render iOS video covers across grid, list, related + listing pages

  • post-tile.ejs / post-card.ejs / post.ejs(related): the cover <img> carries data-ios-mp4 when a loop MP4 exists; shell.ejs's iOS swap upgrades it everywhere covers render
  • cover_video_url threaded through the explicit listing SELECTs (tags/types/users/related); the home grid + main list already use SELECT p.*

Co-Authored-By: Claude <noreply@…>

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/**
2 * GET /users/:username
3 *
4 * Author profile page: shows the user + their published posts on the
5 * current site. Read-only. Honours v9-style URL pattern.
6 */
7
8import express from 'express';
9import db from '../config/database.js';
10import { renderPage } from '../middleware/render.js';
11
12const router = express.Router();
13
14router.get('/:username', (req, res) => {
15 const site = res.locals.site;
16 if (!site) return res.status(404).send('No site');
17
18 const username = (req.params.username || '').trim();
19 if (!username) return res.status(404).send('Not found');
20
21 const author = db.prepare(`
22 SELECT id, username, bio, avatar_url, role, palette, theme, created_at
23 FROM users WHERE username = ?
24 `).get(username);
25
26 if (!author) return res.status(404).send('User not found');
27
28 const posts = db.prepare(`
29 SELECT p.id, p.slug, p.title, p.excerpt, p.cover_image_url, p.cover_video_url, p.published_at
30 FROM posts p
31 WHERE p.author_id = ? AND p.site_id = ? AND p.status = 'published'
32 ORDER BY p.published_at DESC
33 LIMIT 100
34 `).all(author.id, site.id);
35
36 // Total across all sites — useful context, doesn't leak content
37 const totalPosts = db.prepare(`
38 SELECT COUNT(*) AS c FROM posts WHERE author_id = ? AND status = 'published'
39 `).get(author.id).c;
40
41 renderPage(req, res, 'pages/user', {
42 pageTitle: `${author.username} — ${site.title}`,
43 bodyClass: 'on-special',
44 author,
45 posts,
46 totalPosts,
47 });
48});
49
50export default router;
Note: See TracBrowser for help on using the repository browser.