-
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
Closed
Closed
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
97f0693
DOC-2608: Initial prototype - no posts yet
867d112
DOC-2608: Add extension to antora-playbook.yml
a26c44c
DOC-2608: Populate RSS with changelog.adoc content
c4a2a78
DOC-2608: Attempt to fix <li> tag rendering issue
68e654b
DOC-2608: Add purl.org's content module for encoded content
629e422
DOC-2608: Move rssfeed.cjs to lib folder and add error handling to pr…
f99263d
DOC-2608: Fix error in item description
3c275a7
DOC-2608: Move input and output file names into Antora playbook config
32e5a8d
DOC-2608: Normalize version if it's missing the minor or patch version
7b1599a
DOC-2608: Add copyright info to RSS
9c88453
Fix code scanning alert no. 35: Incomplete string escaping or encoding
088e542
DOC-2608: Time the RSS feed generation and log it
daadb63
DOC-2608: Rename 'lib' folder to 'extensions'
6d8218b
DOC-2608: Add link to RSS feed in changelog page
b8cb65d
DOC-2608: Make changelog RSS url into an Antora attribute
6653816
DOC-2608: Use {site-url} attribute instead of hard-coded RSS link
c29fe34
DOC-2608: Generate RSS file in tinymce/latest folder
852e77b
DOC-2608: Fix Atom link
fea6fc5
Add note about RSS reader in Tip admonition
d30f274
Merge remote-tracking branch 'origin/tinymce/7' into hotfix/7/DOC-2608
MitchC1999 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| "use strict"; | ||
|
|
||
| const cheerio = require("cheerio"); | ||
|
|
||
| module.exports.register = function ({ config }) { | ||
| this.on("beforePublish", ({ siteCatalog, contentCatalog, playbook }) => { | ||
| 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}`; | ||
|
|
||
| // 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}/rss.xml" rel="self" type="application/rss+xml" /> | ||
| ${rssItems} | ||
| </channel> | ||
| </rss>`; | ||
|
|
||
| // Add RSS feed to site catalog | ||
| siteCatalog.addFile({ | ||
| contents: Buffer.from(rss), | ||
| out: { path: config.outputFile }, | ||
| }); | ||
| console.log(`RSS feed generated at ${config.outputFile}`); | ||
| } catch (error) { | ||
| // Catch any errors to allow the build to continue | ||
| console.error("Error generating RSS feed:", error); | ||
| } | ||
| }); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.