From e1ee46b806f07fc4c9bf9d0da44f4ec7152308f7 Mon Sep 17 00:00:00 2001 From: Ethan Shen <42264778+nczitzk@users.noreply.github.com> Date: Sat, 23 Jul 2022 07:22:09 +0800 Subject: [PATCH] feat(route): add WizTree What's New (#10300) --- docs/en/program-update.md | 6 ++++ docs/program-update.md | 6 ++++ lib/v2/diskanalyzer/maintainer.js | 3 ++ lib/v2/diskanalyzer/radar.js | 13 +++++++++ lib/v2/diskanalyzer/router.js | 3 ++ lib/v2/diskanalyzer/whats-new.js | 48 +++++++++++++++++++++++++++++++ 6 files changed, 79 insertions(+) create mode 100644 lib/v2/diskanalyzer/maintainer.js create mode 100644 lib/v2/diskanalyzer/radar.js create mode 100644 lib/v2/diskanalyzer/router.js create mode 100644 lib/v2/diskanalyzer/whats-new.js diff --git a/docs/en/program-update.md b/docs/en/program-update.md index 50f88bfcab..78a4b06a33 100644 --- a/docs/en/program-update.md +++ b/docs/en/program-update.md @@ -448,6 +448,12 @@ Refer to [#minecraft](/en/game.html#minecraft) +## WizTree + +### What's New + + + ## X410 ### News diff --git a/docs/program-update.md b/docs/program-update.md index d4578be777..f527f2aa5c 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -535,6 +535,12 @@ pageClass: routes +## WizTree + +### What's New + + + ## X410 ### News diff --git a/lib/v2/diskanalyzer/maintainer.js b/lib/v2/diskanalyzer/maintainer.js new file mode 100644 index 0000000000..21ba3c7f7a --- /dev/null +++ b/lib/v2/diskanalyzer/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/whats-new': ['nczitzk'], +}; diff --git a/lib/v2/diskanalyzer/radar.js b/lib/v2/diskanalyzer/radar.js new file mode 100644 index 0000000000..318a5ff485 --- /dev/null +++ b/lib/v2/diskanalyzer/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'diskanalyzer.com': { + _name: "What's New", + '.': [ + { + title: 'Change Log', + docs: 'https://docs.rsshub.app/program-update.html#wiztree-whats-new', + source: ['/whats-new', '/'], + target: '/diskanalyzer/whats-new', + }, + ], + }, +}; diff --git a/lib/v2/diskanalyzer/router.js b/lib/v2/diskanalyzer/router.js new file mode 100644 index 0000000000..b56d655e47 --- /dev/null +++ b/lib/v2/diskanalyzer/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/whats-new', require('./whats-new')); +}; diff --git a/lib/v2/diskanalyzer/whats-new.js b/lib/v2/diskanalyzer/whats-new.js new file mode 100644 index 0000000000..e26da81043 --- /dev/null +++ b/lib/v2/diskanalyzer/whats-new.js @@ -0,0 +1,48 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const rootUrl = 'https://diskanalyzer.com'; + const currentUrl = `${rootUrl}/whats-new`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const items = $('.blog-content h4') + .toArray() + .map((item) => { + item = $(item); + + const title = item.text(); + + let description = ''; + item.nextUntil('h4').each(function () { + description += $(this).html(); + }); + if (description === '') { + item.parent() + .nextUntil('h4') + .each(function () { + description += $(this).html(); + }); + } + + return { + title, + link: currentUrl, + description, + pubDate: parseDate(title.match(/\((.*)\)/)[1], ['D MMMM YYYY', 'D MMM YYYY']), + }; + }); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +};