-
Notifications
You must be signed in to change notification settings - Fork 220
DOC-2608: Add an RSS feed for the TinyMCE Changelog #3566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
97f0693
867d112
a26c44c
c4a2a78
68e654b
629e422
f99263d
3c275a7
32e5a8d
7b1599a
9c88453
088e542
daadb63
6d8218b
b8cb65d
6653816
c29fe34
852e77b
fea6fc5
d30f274
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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); | ||
| } | ||
| }); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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]. | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
@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?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||||||
|
|
||||||||||
Uh oh!
There was an error while loading. Please reload this page.