From 2aad4684721349f57ceab04ccc6137e089832a67 Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Fri, 4 Dec 2020 23:55:51 +0800 Subject: [PATCH] feat: add total commander what's new (#6325) --- docs/en/program-update.md | 6 +++++ docs/program-update.md | 6 +++++ lib/router.js | 3 +++ lib/routes/totalcommander/whatsnew.js | 32 +++++++++++++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 lib/routes/totalcommander/whatsnew.js diff --git a/docs/en/program-update.md b/docs/en/program-update.md index aed6e51a3..45c18933e 100644 --- a/docs/en/program-update.md +++ b/docs/en/program-update.md @@ -92,6 +92,12 @@ The owner of the official image fills in the library, for example: https://rsshu +## Total Commander + +### What's New + + + ## Greasy Fork ### Script Update diff --git a/docs/program-update.md b/docs/program-update.md index 06e7302a3..6a17b840f 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -266,6 +266,12 @@ pageClass: routes +## Total Commander + +### What's New + + + ## Typora ### Changelog diff --git a/lib/router.js b/lib/router.js index 6eea40593..508862e5e 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3517,6 +3517,9 @@ router.get('/uisdc/news', require('./routes/uisdc/news')); router.get('/uisdc/zt/:title?', require('./routes/uisdc/zt')); router.get('/uisdc/topic/:title?/:sort?', require('./routes/uisdc/topic')); +// Total Commander +router.get('/totalcommander/whatsnew', require('./routes/totalcommander/whatsnew')); + // Blizzard router.get('/blizzard/news/:language?/:category?', require('./routes/blizzard/news')); diff --git a/lib/routes/totalcommander/whatsnew.js b/lib/routes/totalcommander/whatsnew.js new file mode 100644 index 000000000..5eeb0dd3b --- /dev/null +++ b/lib/routes/totalcommander/whatsnew.js @@ -0,0 +1,32 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const date = require('@/utils/date'); + +module.exports = async (ctx) => { + const rootUrl = 'http://ghisler.com'; + const currentUrl = `${rootUrl}/whatsnew.htm`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data.replace(/

/g, '

')); + + const items = $('content') + .map((_, item) => { + item = $(item); + return { + link: currentUrl, + title: item.find('h3').text(), + description: item.find('p').html(), + pubDate: date(item.find('b').text().split(':')[0]), + }; + }) + .get(); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +};