Changeset 0688b5f in Klonkt for src/routes/posts.js
- Timestamp:
- 07/01/2026 07:06:45 PM (2 months ago)
- Branches:
- main
- Children:
- 1c2dcba
- Parents:
- d18c60e
- File:
-
- 1 edited
-
src/routes/posts.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/posts.js
rd18c60e r0688b5f 247 247 const cw = (req.body.content_warning || '').trim().slice(0, 200); 248 248 const coverAlt = (req.body.cover_alt || '').trim().slice(0, 1500) || null; // cover alt text (a11y) 249 const language = /^[a-z]{2,3}(-[A-Za-z]{2,4})?$/.test(req.body.language || '') ? req.body.language : (res.locals.lang || null); // BCP-47 content language 249 250 250 251 // Content arrives as user-authored HTML from the WYSIWYG editor — sanitize … … 285 286 INSERT INTO posts ( 286 287 id, site_id, slug, author_id, title, content, excerpt, 287 status, cover_image_url, cover_video_url, cover_alt, pinned, tags, type, noindex, fan_only, nsfw, content_warning, poll_json, publish_at,288 status, cover_image_url, cover_video_url, cover_alt, language, pinned, tags, type, noindex, fan_only, nsfw, content_warning, poll_json, publish_at, 288 289 created_at, updated_at, published_at 289 ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )290 ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 290 291 `).run( 291 292 postId, site.id, finalSlug, req.session.user.id, 292 293 title || finalSlug, cleanContent, excerpt || '', 293 finalStatus, cover_image_url || null, (req.body.cover_video_url || null), coverAlt, parsePinnedRank(pinned),294 finalStatus, cover_image_url || null, (req.body.cover_video_url || null), coverAlt, language, parsePinnedRank(pinned), 294 295 JSON.stringify((tags || '').split(',').map(t => t.trim()).filter(Boolean)), 295 296 finalType, noindex ? 1 : 0, fanOnly, nsfw, cw, pollJson, publishAt, … … 313 314 ActivityPubService.deliverCreate(site, { 314 315 id: postId, slug: finalSlug, title: title || finalSlug, 315 content: cleanContent, cover_image_url: cover_image_url || null, cover_video_url: req.body.cover_video_url || null, cover_alt: coverAlt, 316 content: cleanContent, cover_image_url: cover_image_url || null, cover_video_url: req.body.cover_video_url || null, cover_alt: coverAlt, language, 316 317 published_at: publishedAt, created_at: now, fan_only: fanOnly, nsfw, content_warning: cw, poll_json: pollJson, 317 318 }).catch(() => { /* best-effort */ }); … … 381 382 const cw = (req.body.content_warning || '').trim().slice(0, 200); 382 383 const coverAlt = (req.body.cover_alt || '').trim().slice(0, 1500) || null; // cover alt text (a11y) 384 const language = /^[a-z]{2,3}(-[A-Za-z]{2,4})?$/.test(req.body.language || '') ? req.body.language : (res.locals.lang || null); // BCP-47 content language 383 385 const newSlug = req.body.slug; 384 386 const action = req.body.action || 'save'; … … 424 426 UPDATE posts SET 425 427 title = ?, content = ?, excerpt = ?, status = ?, 426 cover_image_url = ?, cover_video_url = ?, cover_alt = ?, pinned = ?, tags = ?,428 cover_image_url = ?, cover_video_url = ?, cover_alt = ?, language = ?, pinned = ?, tags = ?, 427 429 type = ?, noindex = ?, fan_only = ?, nsfw = ?, content_warning = ?, poll_json = ?, publish_at = ?, 428 430 slug = ?, published_at = ?, updated_at = ? … … 430 432 `).run( 431 433 title, cleanContent, excerpt, finalStatus, 432 cover_image_url || null, (req.body.cover_video_url || null), coverAlt, parsePinnedRank(pinned),434 cover_image_url || null, (req.body.cover_video_url || null), coverAlt, language, parsePinnedRank(pinned), 433 435 JSON.stringify((tags || '').split(',').map(t => t.trim()).filter(Boolean)), 434 436 finalType, noindex ? 1 : 0, fanOnly, nsfw, cw, pollJson, publishAt, … … 456 458 const apPost = { 457 459 id: post.id, slug: finalSlug, title: title || finalSlug, 458 content: cleanContent, cover_image_url: cover_image_url || null, cover_video_url: req.body.cover_video_url || null, cover_alt: coverAlt, 460 content: cleanContent, cover_image_url: cover_image_url || null, cover_video_url: req.body.cover_video_url || null, cover_alt: coverAlt, language, 459 461 published_at: publishedAt, created_at: post.created_at, fan_only: fanOnly, nsfw, content_warning: cw, poll_json: pollJson, 460 462 };
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)