Changeset 520e477 in Klonkt
- Timestamp:
- 07/20/2026 07:35:55 AM (7 weeks ago)
- Branches:
- main
- Children:
- 22d2f5a8
- Parents:
- 1485933
- git-author:
- Robin <roboburr@…> (07/20/2026 07:26:51 AM)
- git-committer:
- Robin <roboburr@…> (07/20/2026 07:35:55 AM)
- Location:
- src
- Files:
-
- 1 added
- 5 edited
-
routes/circle.js (modified) (2 diffs)
-
routes/posts.js (modified) (4 diffs)
-
services/ActivityPubService.js (modified) (2 diffs)
-
views/pages/circle-feed.ejs (modified) (3 diffs)
-
views/pages/home.ejs (modified) (3 diffs)
-
views/partials/home-append.ejs (added)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/circle.js
r1485933 r520e477 42 42 } 43 43 44 const CIRKEL_PAGE = 72; // matches FEED_PAGE in posts.js: divisible by 2/3/4 45 44 46 router.get('/cirkel', (req, res, next) => { 45 47 const site = res.locals.site; 46 48 if (!site || !apEnabled() || (ActivityPubService.autoBoostCount(site.slug) === 0 && ActivityPubService.boostedCount(site.slug) === 0)) return next(); 47 49 48 const posts = ActivityPubService.getCirkelPosts(site.slug, 80).map((r) => { 50 const append = req.query.append === '1'; 51 const offset = Math.max(0, parseInt(req.query.offset, 10) || 0); 52 const rows = ActivityPubService.getCirkelPosts(site.slug, CIRKEL_PAGE + 1, offset); 53 const hasMore = rows.length > CIRKEL_PAGE; 54 const posts = rows.slice(0, CIRKEL_PAGE).map((r) => { 49 55 const text = tidySnippet(htmlToText(r.content)); 50 56 // Show ONLY the title (the bold first line a Klonkt note carries), not the whole … … 77 83 }); 78 84 85 const moreBase = res.locals.siteUrlBase || ''; 86 if (append) { 87 return renderPage(req, res, 'partials/home-append', { posts, hasMore, nextOffset: offset + CIRKEL_PAGE, moreBase, morePath: '/cirkel' }); 88 } 89 79 90 const sites = ActivityPubService.getCirkelMembers(site.slug) 80 91 .map((s) => ({ name: s.name || 'Onbekend', url: safeUrl(s.url), avatar: safeUrl(s.icon) })); 81 92 82 renderPage(req, res, 'pages/circle-feed', { pageTitle: 'Cirkel', bodyClass: 'on-cirkel', posts, sites }); 93 renderPage(req, res, 'pages/circle-feed', { 94 pageTitle: 'Cirkel', bodyClass: 'on-cirkel', posts, sites, 95 hasMore, nextOffset: offset + CIRKEL_PAGE, moreBase, 96 }); 83 97 }); 84 98 -
src/routes/posts.js
r1485933 r520e477 95 95 const router = express.Router(); 96 96 97 // Feed page size for "Load more" (Solo, News, Messages, Cirkel). 72 is divisible 98 // by 2/3/4 so every grid column count ends on a full row. 99 const FEED_PAGE = 72; 100 97 101 // ==================== UPLOAD IMAGE (cover or content) ==================== 98 102 // Returns JSON {url} so the editor can stick it into the cover field or … … 210 214 `).all(site.id); 211 215 212 // Regular posts: anything with pinned = 0 213 const posts = db.prepare(` 216 // Regular posts: anything with pinned = 0. Paged in blocks of 72 (Load more). 217 const append = req.query.append === '1'; 218 const offset = Math.max(0, parseInt(req.query.offset, 10) || 0); 219 const rows = db.prepare(` 214 220 SELECT p.*, u.username as author_username 215 221 FROM posts p JOIN users u ON p.author_id = u.id 216 222 WHERE p.site_id = ? AND p.status = 'published' AND p.pinned = 0 217 223 ORDER BY p.published_at DESC 218 LIMIT 30 219 `).all(site.id); 224 LIMIT ? OFFSET ? 225 `).all(site.id, FEED_PAGE + 1, offset); 226 const hasMore = rows.length > FEED_PAGE; 227 const posts = rows.slice(0, FEED_PAGE); 228 const moreBase = res.locals.siteUrlBase || ''; 229 230 if (append) { 231 return renderPage(req, res, 'partials/home-append', { posts, hasMore, nextOffset: offset + FEED_PAGE, moreBase }); 232 } 220 233 221 234 recordPageview(site.id, req); … … 224 237 pinnedPosts, 225 238 posts, 239 hasMore, nextOffset: offset + FEED_PAGE, moreBase, 226 240 pageTitle: site.title, 227 241 socialDescr: site.description || site.tagline || '', … … 893 907 } 894 908 895 const FEED_PAGE = 72; // divisible by 2/3/4 → every grid column count keeps full rows896 909 router.get('/news', requireSiteManager, (req, res) => { 897 910 const site = res.locals.site; -
src/services/ActivityPubService.js
r1485933 r520e477 2245 2245 try { if (!_abCount) _abCount = db.prepare('SELECT COUNT(*) AS n FROM ap_following WHERE slug = ? AND auto_boost = 1'); return _abCount.get(slug).n; } catch { return 0; } 2246 2246 } 2247 export function getCirkelPosts(slug, limit ) {2247 export function getCirkelPosts(slug, limit, offset) { 2248 2248 try { 2249 2249 // Cirkel = posts from featured (auto_boost) accounts + posts you boosted … … 2256 2256 WHERE t.slug = ? AND (f.auto_boost = 1 OR t.boosted = 1) 2257 2257 ORDER BY COALESCE(t.published, t.created_at) DESC, t.rowid DESC 2258 LIMIT ? `);2259 return _cirkelPosts.all(slug, limit || 60 );2258 LIMIT ? OFFSET ?`); 2259 return _cirkelPosts.all(slug, limit || 60, offset || 0); 2260 2260 } catch { return []; } 2261 2261 } -
src/views/pages/circle-feed.ejs
r1485933 r520e477 67 67 <!-- ===== TIMELINE (standaard) ===== --> 68 68 <div class="container feed-timeline"> 69 <ul class="post-list feed-timeline-list" >69 <ul class="post-list feed-timeline-list" id="post-list"> 70 70 <% posts.forEach(function(post){ %> 71 71 <%- include('../partials/post-card', { post: post }) %> … … 76 76 <!-- ===== GRID (body[data-feed-view="grid"]) ===== --> 77 77 <section class="feed-grid container" aria-label="<%= t('cfeed.grid_view') %>"> 78 <div class="grid-tiles" >78 <div class="grid-tiles" id="grid-tiles"> 79 79 <% posts.forEach(function(post){ %> 80 80 <%- include('../partials/post-tile', { post: post }) %> … … 82 82 </div> 83 83 </section> 84 85 <% if (typeof hasMore !== 'undefined') { %> 86 <div class="container feed-more-wrap"> 87 <%- include('../partials/load-more', { hasMore: hasMore, nextOffset: nextOffset, moreBase: moreBase, moreTarget: '#post-list', morePath: '/cirkel' }) %> 88 </div> 89 <% } %> 84 90 85 91 <% } %> -
src/views/pages/home.ejs
r1485933 r520e477 36 36 </div> 37 37 <% } else { %> 38 <ul class="post-list feed-timeline-list" >38 <ul class="post-list feed-timeline-list" id="post-list"> 39 39 <% allPosts.forEach(function(post) { %> 40 40 <%- include('../partials/post-card', { post: post }) %> … … 48 48 <% if (allPosts.length > 0) { %> 49 49 <section class="feed-grid container" aria-label="<%= t('phome.grid_view') %>"> 50 <div class="grid-tiles" >50 <div class="grid-tiles" id="grid-tiles"> 51 51 <% allPosts.forEach(function(post) { %> 52 52 <%- include('../partials/post-tile', { post: post }) %> … … 55 55 </section> 56 56 <% } %> 57 <% if (typeof hasMore !== 'undefined' && allPosts.length > 0) { %> 58 <div class="container feed-more-wrap"> 59 <%- include('../partials/load-more', { hasMore: hasMore, nextOffset: nextOffset, moreBase: moreBase, moreTarget: '#post-list', morePath: '/' }) %> 60 </div> 61 <% } %>
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)