From 342d333bc74704632e9670e981b57b5b94ae5f65 Mon Sep 17 00:00:00 2001 From: NathanDai Date: Sat, 13 May 2023 23:36:48 +0800 Subject: [PATCH] feat(route): add Infuse Release Notes (#12500) * feat(route): add Infuse Release Notes * Update lib/v2/firecore/maintainer.js * Update lib/v2/firecore/index.js * Update docs/en/program-update.md * Update lib/v2/firecore/radar.js --------- --- docs/en/program-update.md | 6 ++++++ docs/program-update.md | 6 ++++++ lib/v2/firecore/index.js | 37 +++++++++++++++++++++++++++++++++++ lib/v2/firecore/maintainer.js | 3 +++ lib/v2/firecore/radar.js | 13 ++++++++++++ lib/v2/firecore/router.js | 3 +++ 6 files changed, 68 insertions(+) create mode 100644 lib/v2/firecore/index.js create mode 100644 lib/v2/firecore/maintainer.js create mode 100644 lib/v2/firecore/radar.js create mode 100644 lib/v2/firecore/router.js diff --git a/docs/en/program-update.md b/docs/en/program-update.md index b233b26c81..a1b7930c0c 100644 --- a/docs/en/program-update.md +++ b/docs/en/program-update.md @@ -306,6 +306,12 @@ Language +## Infuse + +### Release Notes + + + ## IPSW.me ### Apple Firmware Update-IPSWs/OTAs version diff --git a/docs/program-update.md b/docs/program-update.md index a34b58de5b..74e109c5a2 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -338,6 +338,12 @@ pageClass: routes +## Infuse + +### Release Notes + + + ## IPSW\.me ### 苹果固件更新 - IPSWs/OTAs 版本 diff --git a/lib/v2/firecore/index.js b/lib/v2/firecore/index.js new file mode 100644 index 0000000000..963a976ab5 --- /dev/null +++ b/lib/v2/firecore/index.js @@ -0,0 +1,37 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const host = 'https://firecore.com/releases'; + const { data } = await got(host); + const $ = cheerio.load(data); + const items = $(`div.tab-pane.fade#${ctx.params.os}`) + .find('.release-date') + .toArray() + .map((item) => { + item = $(item); + const title = item + .parent() + .contents() + .filter((_, el) => el.nodeType === 3) + .text(); + const pubDate = parseDate(item.text().match(/(\d{4}-\d{2}-\d{2})/)[1]); + + const next = item.parent().nextUntil('hr'); + return { + title, + description: next + .toArray() + .map((item) => $(item).html()) + .join(''), + pubDate, + }; + }); + + ctx.state.data = { + title: 'Infuse Release Notes', + link: 'https://firecore.com/releases', + item: items, + }; +}; diff --git a/lib/v2/firecore/maintainer.js b/lib/v2/firecore/maintainer.js new file mode 100644 index 0000000000..ab42b1ff1b --- /dev/null +++ b/lib/v2/firecore/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:os': ['NathanDai'], +}; diff --git a/lib/v2/firecore/radar.js b/lib/v2/firecore/radar.js new file mode 100644 index 0000000000..0487faed09 --- /dev/null +++ b/lib/v2/firecore/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'firecore.com': { + _name: 'Infuse', + '.': [ + { + title: 'Release Notes', + docs: 'https://docs.rsshub.app/program-update.html#infuse', + source: ['/releases', '/'], + target: '/firecore/:os?', + }, + ], + }, +}; diff --git a/lib/v2/firecore/router.js b/lib/v2/firecore/router.js new file mode 100644 index 0000000000..268034c466 --- /dev/null +++ b/lib/v2/firecore/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:os', require('./index')); +};