Changeset 746d98a in Klonkt for src/routes
- Timestamp:
- 09/30/2026 09:08:48 AM (4 hours ago)
- Branches:
- main
- Parents:
- 31680c3
- Location:
- src/routes
- Files:
-
- 2 edited
-
account.js (modified) (4 diffs)
-
admin-sites.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/account.js
r31680c3 r746d98a 14 14 15 15 import express from 'express'; 16 import { listPlatforms, buildProfileLinks, parseProfileLinks } from '../services/PlatformIcons.js'; 16 17 import path from 'path'; 17 18 import fs from 'fs'; … … 69 70 pageTitle: 'Account', 70 71 bodyClass: 'on-special', 72 // De profiellinks staan sinds 30-9 hier, bij je profiel, en niet meer op de 73 // Appearance-pagina (Robins verzoek). 74 pageJs: 'profile-links', 75 platforms: listPlatforms(), 76 profileLinks: editableSite ? parseProfileLinks(editableSite.profile_links) : [], 71 77 account, 72 78 hasPassword, … … 106 112 function ownedSite(user) { 107 113 if (!user) return null; 108 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); 114 // profile_links hoort erbij sinds de links hier staan (30-9). Zonder die kolom 115 // toonde de pagina nul links, en wiste opslaan ze dus. 116 let site = db.prepare('SELECT id, title, tagline, slug, owner_id, profile_photo, profile_links FROM sites WHERE owner_id = ? ORDER BY created_at LIMIT 1').get(user.id); 109 117 if (!site && user.role === 'god') { 110 118 site = getPrimarySite(); // primary/main site as fallback … … 128 136 }); 129 137 138 // ==================== PROFIELLINKS ==================== 139 // Sinds 30-9 hier en niet meer op Appearance: ze horen bij je profiel, naast je 140 // naam, bio en foto. Dezelfde rechten als de site-naam hierboven: de eigenaar 141 // van de site, of god. 142 router.post('/links', requireAuth, (req, res) => { 143 const site = ownedSite(req.session.user); 144 if (!site) return res.redirect('/account?error=' + encodeURIComponent('Geen site om te bewerken.')); 145 if (site.owner_id !== req.session.user.id && req.session.user.role !== 'god') { 146 return res.redirect('/account?error=' + encodeURIComponent('Geen rechten om deze site te bewerken.')); 147 } 148 db.prepare('UPDATE sites SET profile_links = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?') 149 .run(buildProfileLinks(req.body), site.id); 150 res.redirect('/account?success=' + encodeURIComponent('Links bijgewerkt') + '#links'); 151 }); 152 130 153 // ==================== UPDATE BIO ==================== 131 154 const RESERVED_USERNAMES = new Set(['admin', 'account', 'auth', 'login', 'register', 'logout', 'user', 'users', 'api', 'fediverse', 'posts', 'media', 'audio', 'assets', 'cirkel', 'authorize_interaction']); -
src/routes/admin-sites.js
r31680c3 r746d98a 55 55 }); 56 56 57 /** Coerce req.body fields into the JSON profile_links array. */58 function buildProfileLinks(body) {59 const platforms = body.profile_link_platform || [];60 const urls = body.profile_link_url || [];61 const arr = [];62 const platformsArr = Array.isArray(platforms) ? platforms : [platforms];63 const urlsArr = Array.isArray(urls) ? urls : [urls];64 for (let i = 0; i < platformsArr.length; i++) {65 const p = (platformsArr[i] || '').toString().trim();66 const u = (urlsArr[i] || '').toString().trim();67 if (!p || !u) continue;68 if (!PLATFORMS[p]) continue;69 if (!/^https?:\/\//i.test(u) && p !== 'email') continue;70 if (p === 'email' && !/^mailto:|^[^\s@]+@[^\s@]+$/i.test(u)) continue;71 arr.push({ platform: p, url: u });72 }73 return arr.length ? JSON.stringify(arr) : null;74 }75 57 76 58 /** … … 211 193 accents: ThemeService.listAccents(), 212 194 platforms: listPlatforms(), 213 parsedLinks: [],214 195 apAliases: '', 215 196 error: null, … … 275 256 if (!site) return res.redirect('/admin/sites?error=Not+found'); 276 257 277 let parsedLinks = [];278 if (site.profile_links) {279 try { parsedLinks = JSON.parse(site.profile_links) || []; } catch {}280 }281 258 282 259 let apAliases = ''; … … 293 270 accents: ThemeService.listAccents(), 294 271 platforms: listPlatforms(), 295 parsedLinks,296 272 apAliases, 297 273 success: req.query.success || null, … … 333 309 const feedAlt = ['timeline', 'auto'].includes(f.feed_alt_view) ? f.feed_alt_view : 'reader'; 334 310 const feedViewDef = f.feed_view_default === 'grid' ? 'grid' : feedAlt; 335 const profileLinksJson = buildProfileLinks(f); 311 // De profiellinks staan sinds 30-9 bij je profiel (/account). Deze pagina 312 // schrijft ze dus NIET meer: met de velden weg zou elke keer opslaan hier ze 313 // wissen. De kolom blijft van /account/links. 336 314 337 315 // FEP-7628 aliases — validated/resolved before anything is written. … … 366 344 palette = ?, accent = ?, theme_override = ?, profile_photo = ?, 367 345 profile_enabled = ?, 368 profile_links = ?,369 346 ap_aliases = ?, 370 347 is_public = ?, robots_index = ?, require_login_to_comment = ?, … … 386 363 f.profile_photo || null, 387 364 f.profile_enabled ? 1 : 0, 388 profileLinksJson,389 365 apAliasesJson, 390 366 f.is_public ? 1 : 0,
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)