Changeset 82079ad in Klonkt
- Timestamp:
- 06/24/2026 12:31:43 PM (3 months ago)
- Branches:
- main
- Children:
- 3d7312a
- Parents:
- 52ea6df
- Location:
- src
- Files:
-
- 4 edited
-
middleware/render.js (modified) (1 diff)
-
routes/account.js (modified) (3 diffs)
-
routes/posts.js (modified) (1 diff)
-
views/pages/account.ejs (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/middleware/render.js
r52ea6df r82079ad 73 73 const _fresh = db.prepare('SELECT avatar_url, role, lang FROM users WHERE id = ?').get(_u.id); 74 74 if (_fresh) _u = { ..._u, avatar_url: _fresh.avatar_url, role: _fresh.role, lang: _fresh.lang }; 75 // One identity: no own account avatar → fall back to the user's site photo, 76 // so the same picture shows everywhere (nav, account, comments). 77 if (_u && !_u.avatar_url) { 78 const _sp = db.prepare("SELECT profile_photo FROM sites WHERE owner_id = ? AND profile_photo IS NOT NULL ORDER BY is_primary DESC, created_at ASC LIMIT 1").get(_u.id); 79 if (_sp && _sp.profile_photo) _u = { ..._u, avatar_url: _sp.profile_photo }; 80 } 75 81 } 76 82 const userOwnsSite = !!(_u && _u.role !== 'god' && -
src/routes/account.js
r52ea6df r82079ad 68 68 if (account) { delete account.password_hash; delete account.google_sub; } // don't leak to the view 69 69 70 const editableSite = ownedSite(req.session.user); 70 71 renderPage(req, res, 'pages/account', { 71 72 pageTitle: 'Account', … … 75 76 googleLinked, 76 77 googleAvailable: googleConfigured(), 77 editableSite: ownedSite(req.session.user), 78 editableSite, 79 // Display fallback: when you have no own account avatar, show your site's photo. 80 siteAvatar: editableSite ? editableSite.profile_photo : null, 78 81 success: req.query.success || null, 79 82 error: req.query.error || null, … … 98 101 function ownedSite(user) { 99 102 if (!user) return null; 100 let site = db.prepare('SELECT id, title, tagline, slug, owner_id FROM sites WHERE owner_id = ? ORDER BY created_at LIMIT 1').get(user.id);103 let site = db.prepare('SELECT id, title, tagline, slug, owner_id, profile_photo FROM sites WHERE owner_id = ? ORDER BY created_at LIMIT 1').get(user.id); 101 104 if (!site && user.role === 'god') { 102 105 site = getPrimarySite(); // primary/main site as fallback -
src/routes/posts.js
r52ea6df r82079ad 661 661 const commentRows = db.prepare(` 662 662 SELECT c.id, c.parent_comment_id, c.content, c.status, c.created_at, 663 c.author_id, u.username AS author_username, u.avatar_url AS author_avatar 663 c.author_id, u.username AS author_username, 664 COALESCE(u.avatar_url, (SELECT profile_photo FROM sites WHERE owner_id = u.id AND profile_photo IS NOT NULL ORDER BY is_primary DESC, created_at ASC LIMIT 1)) AS author_avatar 664 665 FROM comments c JOIN users u ON u.id = c.author_id 665 666 WHERE c.post_id = ? AND c.status = 'approved' -
src/views/pages/account.ejs
r52ea6df r82079ad 31 31 <label class="ax-avatar-wrap" title="<%= t('acct.avatar_change') %>"> 32 32 <span class="ax-profile-avatar"> 33 <% if (account.avatar_url) { %> 34 <img src="<%= account.avatar_url %>" alt=""> 33 <% var _av = account.avatar_url || (typeof siteAvatar !== 'undefined' ? siteAvatar : null); %> 34 <% if (_av) { %> 35 <img src="<%= _av %>" alt=""> 35 36 <% } else { %> 36 37 <span><%= account.username.charAt(0).toUpperCase() %></span> … … 45 46 <% } else { %> 46 47 <span class="ax-profile-avatar ax-profile-avatar-static"> 47 <% if (account.avatar_url) { %> 48 <img src="<%= account.avatar_url %>" alt=""> 48 <% var _av2 = account.avatar_url || (typeof siteAvatar !== 'undefined' ? siteAvatar : null); %> 49 <% if (_av2) { %> 50 <img src="<%= _av2 %>" alt=""> 49 51 <% } else { %> 50 52 <span><%= account.username.charAt(0).toUpperCase() %></span>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)