Skip to content

Commit

Permalink
Exposes feed
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmerfield committed Sep 14, 2022
1 parent 78125d9 commit 5e9966c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/brochure/routes/questions/index.js
Expand Up @@ -40,7 +40,10 @@ function removeXMLInvalidChars(string) {

Questions.get("/feed.rss", async function (req, res, next) {
const { rows } = await pool.query(
`SELECT * FROM items WHERE is_topic = true LIMIT 100`
`SELECT * FROM items
WHERE is_topic = true
ORDER BY created_at DESC
LIMIT ${TOPICS_PER_PAGE}`
);

res.locals.url = config.protocol + "://" + config.host;
Expand All @@ -51,13 +54,12 @@ Questions.get("/feed.rss", async function (req, res, next) {
rows.forEach(function (topic) {
topic.body = removeXMLInvalidChars(marked(topic.body));
topic.url = res.locals.url + "/questions/" + topic.id;
topic.author = 'Anonymous';
topic.author = "Anonymous";
topic.date = moment
.utc(topic.created_at)
.format("ddd, DD MMM YYYY HH:mm:ss ZZ");
});

console.log("here too", rows);
res.locals.layout = "questions/feed";
res.render("questions/feed");
});
Expand Down
2 changes: 2 additions & 0 deletions app/brochure/views/questions/index.html
Expand Up @@ -52,3 +52,5 @@ <h2>
{{/topics_count}}
</div>
{{/paginator}}

<a href="/questions/feed.rss">Feed of latest questions</a>

0 comments on commit 5e9966c

Please sign in to comment.