Added user specific RSS and ATOM feeds and updated the EJS templates to

add them by default to the user's header section
This commit is contained in:
2025-07-30 01:28:23 +01:00
parent 72316094e4
commit 0cc319a702
8 changed files with 83 additions and 9 deletions

View File

@@ -29,7 +29,7 @@ export function unix_time_to_rss_date(unix_time) {
export function unix_time_to_atom_date(unix_time) {
const { fromUnixTime, format, getUnixTime } = require("date-fns") // A date utility library
let date = fromUnixTime(unix_time)
let formatted_date = format(date, "yyyy-MM-dd\\THH:mm:ss\\Z")
let formatted_date = format(date, "yyyy-MM-dd'T'HH:mm:ss'Z'")
return `${formatted_date}`
}
// This function accepts a list of strings eg ["string1","string2,"string3"] (any length)

View File

@@ -60,7 +60,7 @@ app.set('view engine', 'ejs');
app.set('views', '../views')
////////////////////// SYNDICATION ////////////////////////
// RSS protocol gets
// global RSS protocol gets
app.get("/rss", (req,res) => {
if (config.rss == false) {
res.render("partials/message", {
@@ -78,7 +78,28 @@ app.get("/rss", (req,res) => {
})
};
});
// ATOM protocol gets
// user RSS protocol gets
app.get("/user/:username/rss", (req,res) => {
const username = req.params.username;
const userID = func.get_userID(username);
if (config.rss == false) {
res.render("partials/message", {
message: config.string.rss_disabled,
config: config,
})
}
else {
res.setHeader('content-type', 'application/rss+xml');
res.render("syndication/user_rss", {
config,
posts,
converter,
func,
userID,
})
};
});
// global ATOM protocol gets
app.get("/atom", (req,res) => {
if (config.rss == false) {
res.render("partials/message", {
@@ -93,6 +114,29 @@ app.get("/atom", (req,res) => {
posts,
converter,
func,
getUnixTime,
})
};
});
// user ATOM protocol gets
app.get("/user/:username/atom", (req,res) => {
const username = req.params.username;
const userID = func.get_userID(username);
if (config.rss == false) {
res.render("partials/message", {
message: config.string.rss_disabled,
config: config,
})
}
else {
res.setHeader('content-type', 'application/rss+xml');
res.render("syndication/user_atom", {
config,
posts,
converter,
func,
userID,
getUnixTime,
})
};
});