feat(route): add VMware Flings (#10315)

This commit is contained in:
Ethan Shen 2022-07-25 21:17:09 +08:00 committed by GitHub
parent 09255c52a4
commit fdc5b09f90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 90 additions and 0 deletions

View File

@ -460,6 +460,12 @@ Refer to [#minecraft](/en/game.html#minecraft)
<RouteEn author="cnzgray" example="/typora/changelog" path="/typora/changelog"/>
## VMware
### Flings
<RouteEn author="nczitzk" example="/vmware/flings" path="/vmware/flings"/>
## Western Digital
### Download

View File

@ -547,6 +547,12 @@ pageClass: routes
<Route author="nczitzk" example="/typora/changelog-dev/macOS" path="/typora/changelog-dev/:os" :paramsDesc="['操作系统类型, 可选 `macOS``Windows``Linux`,默认为 `macOS`']"/>
## VMware
### Flings
<Route author="nczitzk" example="/vmware/flings" path="/vmware/flings"/>
## Western Digital
### Download

59
lib/v2/vmware/flings.js Normal file
View File

@ -0,0 +1,59 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const rootUrl = 'https://flings.vmware.com';
const currentUrl = `${rootUrl}/flings`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
let items = $('.clickable')
.toArray()
.map((item) => {
item = $(item);
const title = item.find('.fling-title');
const version = item.find('.fling-version').text();
return {
title: `${title.text()} (${version})`,
link: `${rootUrl}${title.attr('href')}#${version}`,
pubDate: parseDate(item.find('.date').text(), 'MMM DD, YYYY'),
category: item
.find('.fling-tags a')
.toArray()
.map((a) => $(a).text()),
};
});
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(detailResponse.data);
content('#contributors, #similar-flings').remove();
item.description = content('article').html();
return item;
})
)
);
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/flings': ['nczitzk'],
};

13
lib/v2/vmware/radar.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
'vmware.com': {
_name: 'VMware',
flings: [
{
title: 'Flings',
docs: 'https://docs.rsshub.app/program-update.html#vmware-flings',
source: ['/flings', '/'],
target: '/vmware/flings',
},
],
},
};

3
lib/v2/vmware/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/flings', require('./flings'));
};