function escapeHtml(inputString) {
return inputString
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(
/class="all-sc"/g,
"style='font-variant-caps: all-small-caps;'"
);
}
function generateAtomFeed() {
let feed = `<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">`;
const articles = $$("article");
const feedTimestamp = new Date().toISOString();
const preamble = `<title>The Satyrs’ Forest 🍇 (changelog)</title>
<subtitle>The irregularly updated changelog feed.</subtitle>
<link href="https://satyrs.eu/new/feed.xml" rel="self"/>
<link href="https://satyrs.eu/new"/>
<updated>${feedTimestamp}</updated>
<id>https://satyrs.eu/new</id>
<author>
<name>Xanthe Tynehorne</name>
</author>`;
feed += preamble;
for (const article of articles) {
const title = article.$("h1 .red").innerText;
const content = escapeHtml(
article.innerHTML.replace(/href="\//g, `href="https://satyrs.eu/`)
);
const articleTimestamp = article.$("header time").dateTime;
const articleID = article.id;
const entry = `<entry>
<title>${title}</title>
<link href="https://satyrs.eu/new#${articleID}"/>
<updated>${articleTimestamp}</updated>
<id>https://satyrs.eu/new#${articleID}</id>
<content type="html">${content}</content>
</entry>`;
feed += entry;
}
feed += "</feed>";
return feed;
}
document.on("DOMContentLoaded", () => {
console.log(generateAtomFeed());
});