From f2ded06594f01a6cbd69f5fb5346fbd458035919 Mon Sep 17 00:00:00 2001 From: me Date: Sat, 15 Mar 2025 10:05:03 +0200 Subject: [PATCH] feed per page --- backend/src/feed.mjs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/backend/src/feed.mjs b/backend/src/feed.mjs index c7fa371..e4d6e10 100644 --- a/backend/src/feed.mjs +++ b/backend/src/feed.mjs @@ -42,3 +42,33 @@ router.get('/:site', utils.limiter(500), (req, res) => { res.set('Content-Type', 'text/xml'); res.send(xml); }); + +router.get('/:site/*', utils.limiter(500), (req, res) => { + const site = req.params.site; + const path = req.params[0]; + + var feed = new Feed({ + title: 'UCS', + description: 'תגובות עבור הדף ' + site + '/' + path, + id: domain + '/feed/' + site, + link: domain, + language: 'he' + }); + + const comments = db.pageComments(site, path); + + for (const comment of comments) { + feed.addItem({ + title: `New message by '${comment.user}' on ${path}`, + description: comment.message, + id: `${site}/${path}#comment-${comment.id}`, + link: `${site}/${path}#comment-${comment.id}`, + date: new Date(comment.published) + }); + } + + var xml = feed.atom1(); + + res.set('Content-Type', 'text/xml'); + res.send(xml); +});