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.
This commit is contained in:
parent
265498b382
commit
87cf4c5c4b
|
|
@ -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 ? '<ul>' + changelogItems.map((item) => `<li>${item}</li>`).join('') + '</ul>' : '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,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
import type { Namespace } from '@/types';
|
||||
|
||||
export const namespace: Namespace = {
|
||||
name: "Kovid's software projects",
|
||||
url: 'sw.kovidgoyal.net',
|
||||
lang: 'en',
|
||||
};
|
||||
Loading…
Reference in New Issue