diff --git a/docs/en/program-update.md b/docs/en/program-update.md index 21186bd40..484eb4c5f 100644 --- a/docs/en/program-update.md +++ b/docs/en/program-update.md @@ -460,6 +460,12 @@ Refer to [#minecraft](/en/game.html#minecraft) +## VMware + +### Flings + + + ## Western Digital ### Download diff --git a/docs/program-update.md b/docs/program-update.md index e7b80a996..15ab3cc3b 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -547,6 +547,12 @@ pageClass: routes +## VMware + +### Flings + + + ## Western Digital ### Download diff --git a/lib/v2/vmware/flings.js b/lib/v2/vmware/flings.js new file mode 100644 index 000000000..1bf398673 --- /dev/null +++ b/lib/v2/vmware/flings.js @@ -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, + }; +}; diff --git a/lib/v2/vmware/maintainer.js b/lib/v2/vmware/maintainer.js new file mode 100644 index 000000000..e59c6b90e --- /dev/null +++ b/lib/v2/vmware/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/flings': ['nczitzk'], +}; diff --git a/lib/v2/vmware/radar.js b/lib/v2/vmware/radar.js new file mode 100644 index 000000000..e12b1139d --- /dev/null +++ b/lib/v2/vmware/radar.js @@ -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', + }, + ], + }, +}; diff --git a/lib/v2/vmware/router.js b/lib/v2/vmware/router.js new file mode 100644 index 000000000..ede29bc6e --- /dev/null +++ b/lib/v2/vmware/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/flings', require('./flings')); +};