From 87cf4c5c4bb300e7584a773dcd58df920cde060c Mon Sep 17 00:00:00 2001 From: Donie Leigh Date: Fri, 18 Jul 2025 11:33:30 +0800 Subject: [PATCH] feat: add Kitty changelog route (#19632) - Create new route handler for Kitty terminal changelog - Implement parsing of version history and change details - Add namespace definition for Kitty terminal The new route fetches and parses the detailed changelog from Kitty's website, providing structured data including version numbers, release dates, and change items in a format suitable for RSS consumption. --- lib/routes/kovidgoyal/kitty/changelog.ts | 83 ++++++++++++++++++++++++ lib/routes/kovidgoyal/namespace.ts | 7 ++ 2 files changed, 90 insertions(+) create mode 100644 lib/routes/kovidgoyal/kitty/changelog.ts create mode 100644 lib/routes/kovidgoyal/namespace.ts diff --git a/lib/routes/kovidgoyal/kitty/changelog.ts b/lib/routes/kovidgoyal/kitty/changelog.ts new file mode 100644 index 000000000..983acbb11 --- /dev/null +++ b/lib/routes/kovidgoyal/kitty/changelog.ts @@ -0,0 +1,83 @@ +import { Route } from '@/types'; +import ofetch from '@/utils/ofetch'; +import { load } from 'cheerio'; +import { parseDate } from '@/utils/parse-date'; + +export const route: Route = { + path: '/kitty/changelog', + categories: ['program-update'], + example: '/kovidgoyal/kitty/changelog', + parameters: {}, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['sw.kovidgoyal.net/kitty/changelog/'], + target: '/kitty/changelog', + }, + ], + name: 'Changelog', + maintainers: ['xbot'], + handler, + url: 'sw.kovidgoyal.net/kitty/changelog/', +}; + +async function handler() { + const url = 'https://sw.kovidgoyal.net/kitty/changelog/'; + const response = await ofetch(url); + const $ = load(response); + + // Find the "Detailed list of changes" section + const detailedSection = $('#detailed-list-of-changes'); + + const items = detailedSection + .find('section[id^="id"]') + .toArray() + .map((section) => { + const $section = $(section); + + // Extract version and date from h3 title + const titleText = $section.find('h3').first().text().trim(); + const versionMatch = titleText.match(/^([\d.]+)\s*\[([^\]]+)\]/); + + if (!versionMatch) { + return null; + } + + const version = versionMatch[1]; + const dateStr = versionMatch[2]; + + // Extract changelog items from the ul list + const changelogItems = $section + .find('ul.simple li') + .toArray() + .map((li) => $(li).html()) + .filter(Boolean); + + // Create description from changelog items + const description = changelogItems.length > 0 ? '' : 'No changelog items available.'; + + return { + title: `Kitty ${version}`, + description, + link: `${url}#${$section.attr('id')}`, + pubDate: parseDate(dateStr, 'YYYY-MM-DD'), + guid: `kitty-${version}`, + }; + }) + .filter(Boolean); + + return { + title: 'Kitty Changelog', + link: url, + description: 'Changelog for Kitty terminal emulator', + language: 'en', + item: items, + }; +} diff --git a/lib/routes/kovidgoyal/namespace.ts b/lib/routes/kovidgoyal/namespace.ts new file mode 100644 index 000000000..bae84646c --- /dev/null +++ b/lib/routes/kovidgoyal/namespace.ts @@ -0,0 +1,7 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: "Kovid's software projects", + url: 'sw.kovidgoyal.net', + lang: 'en', +};