Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions antora-playbook-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ ui:
asciidoc:
extensions:
- '@tinymce/antora-extension-livedemos'
antora:
extensions:
- require: './extensions/rssfeed.cjs'
input_file: 'changelog.adoc'
output_file: 'rss.xml'
runtime:
fetch: true
5 changes: 5 additions & 0 deletions antora-playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ ui:
asciidoc:
extensions:
- '@tinymce/antora-extension-livedemos'
antora:
extensions:
- require: './extensions/rssfeed.cjs'
input_file: 'changelog.adoc'
output_file: 'rss.xml'
runtime:
fetch: true
119 changes: 119 additions & 0 deletions extensions/rssfeed.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
"use strict";

const cheerio = require("cheerio");

module.exports.register = function ({ config }) {
this.on("beforePublish", ({ siteCatalog, contentCatalog, playbook }) => {
const startTime = Date.now(); // Start the timer

try {
// Find the changelog page
const page = contentCatalog.findBy({
basename: config.inputFile,
})[0];

if (!page) {
throw new Error(`${config.inputFile} page not found.`);
}

// Destructure page attributes
const {
productname: productName,
productmajorversion: productMajorVersion,
doctitle: pageTitle,
description: pageDescription,
docname: pageName,
"page-component-name": pageComponentName,
"page-component-version": pageComponentVersion,
} = page.asciidoc.attributes;

// Construct site links
const siteLink = playbook.site.url;
const siteLinkWithVersion = `${siteLink}/${pageComponentName}/${pageComponentVersion}`;
const filePath = `${pageComponentName}/${pageComponentVersion}/${config.outputFile}`;

// Load page content with cheerio
const $ = cheerio.load(page.contents.toString());

// Extract releases
const releases = $(".sect1")
.map((_, element) => {
const $element = $(element);
const linkElement = $element.find("a.xref");
let [version, date] = linkElement.text().split(" - ");

// Normalize version if it's missing the minor or patch version
const versionParts = version.split(".");
if (versionParts.length === 1) {
version += ".0.0";
} else if (versionParts.length === 2) {
version += ".0";
}

// Remove <p> tags inside <li> tags to fix rendering issues
const contentElement = $element.find(".sectionbody");
contentElement.find("li > p").each((_, pElem) => {
$(pElem).replaceWith($(pElem).html());
});
const content = contentElement.html();

return {
title: linkElement.text(),
link: `${siteLinkWithVersion}/${linkElement
.attr("href")
.replace(/\.\.\//g, "")}`,
description: `Changelog for TinyMCE ${version}`,
guid: version,
pubDate: new Date(date).toUTCString(),
content,
};
})
.get();

// Generate RSS feed items
const rssItems = releases
.map(
({ title, link, description, guid, pubDate, content }) => `
<item>
<title>${title}</title>
<link>${link}</link>
<description>${description}</description>
<guid isPermaLink="false">${guid}</guid>
<pubDate>${pubDate}</pubDate>
<content:encoded><![CDATA[${content}]]></content:encoded>
</item>`
)
.join("\n");

// Assemble the complete RSS feed
const rss = `<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
>
<channel>
<title>${productName} ${productMajorVersion} ${pageTitle}</title>
<link>${siteLinkWithVersion}/${pageName}</link>
<description>${pageDescription}</description>
<language>en</language>
<copyright>Creative Commons Legal Code - Attribution-NonCommercial-ShareAlike 3.0 Unported</copyright>
<atom:link href="${siteLink}/${filePath}" rel="self" type="application/rss+xml" />
${rssItems}
</channel>
</rss>`;

// Add RSS feed to site catalog
siteCatalog.addFile({
contents: Buffer.from(rss),
out: { path: filePath },
});

const endTime = Date.now(); // End the timer
const duration = endTime - startTime; // Calculate the duration
console.log(`RSS feed generated at ${filePath} in ${duration}ms`);
} catch (error) {
// Catch any errors to allow the build to continue
console.error("Error generating RSS feed:", error);
}
});
};
2 changes: 2 additions & 0 deletions modules/ROOT/pages/changelog.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

NOTE: This is the {productname} Community version changelog. For information about the latest {cloudname} or {enterpriseversion} Release, see: xref:release-notes.adoc[{productname} Release Notes].

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
NOTE: This is the {productname} Community version changelog. For information about the latest {cloudname} or {enterpriseversion} Release, see: xref:release-notes.adoc[{productname} Release Notes].
NOTE: This is the {productname} Community version changelog. For information about the latest {cloudname} or {enterpriseversion} Release, see: xref:release-notes.adoc[{productname} Release Notes].
For an RSS feed of the {productname} changelog, use the following URL in any RSS reader: {site-url}/{page-component-name}/{page-component-version}/rss.xml.

@kemister85 @MitchC1999 Rather than a Tip admonition, could we add it here to the Note admonition, and mention the URL can be used in a RSS reader?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would just add it as an extra line rather than a note box. I think its fine to include in a tip box


TIP: For an RSS feed of the {productname} Changelog, use the following URL in any RSS reader: {site-url}/{page-component-name}/{page-component-version}/rss.xml

== xref:7.7.2-release-notes.adoc[7.7.2 - 2025-03-19]

=== Fixed
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@antora/site-generator-default": "^3.0.1",
"@tinymce/antora-extension-livedemos": "^0.1.0",
"@tinymce/moxiedoc": "^0.3.0",
"cheerio": "^1.0.0",
"dotenv": "^16.0.0",
"ecstatic": "^4.1.4",
"http-server": "^0.12.3",
Expand Down
Loading