feat: cpython release (#4856)

This commit is contained in:
Trim21 2020-05-26 11:33:36 +08:00 committed by GitHub
parent e887aadcc0
commit f4fd0e9802
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 0 deletions

View File

@ -68,6 +68,16 @@ pageClass: routes
<Route author="DIYgod" example="/chrome/webstore/extensions/kefjpfngnndepjbopdmoebkipbgkggaa" path="/chrome/webstore/extensions/:id" :paramsDesc="['扩展程序 id, 可在应用页 URL 中找到']" />
## cpython
### 正式版本发布
<Route author="trim21" example="/cpython" path="/cpython" />
### 所有版本发布
<Route author="trim21" example="/cpython/pre" path="/cpython/pre" />
## CurseForge
### 文件更新

View File

@ -386,6 +386,9 @@ router.get('/tuicool/mags/:type', require('./routes/tuicool/mags'));
router.get('/hexo/next/:url', require('./routes/hexo/next'));
router.get('/hexo/yilia/:url', require('./routes/hexo/yilia'));
// cpython
router.get('/cpython/:pre?', require('./routes/cpython'));
// 小米
router.get('/mi/crowdfunding', require('./routes/mi/crowdfunding'));
router.get('/mi/youpin/crowdfunding', require('./routes/mi/youpin/crowdfunding'));

View File

@ -0,0 +1,32 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const dayjs = require('dayjs');
module.exports = async (ctx) => {
const includePreRelease = ctx.params.pre;
const response = await got(`https://www.python.org/downloads`);
const $ = cheerio.load(response.data);
const items = [];
$('.list-row-container.menu li').each(function () {
const $listElement = $(this);
const title = $listElement.find('span.release-number').text();
if (title) {
if (!includePreRelease) {
if (title.includes('rc')) {
return;
}
}
items.push({
title: $listElement.find('span.release-number').text(),
description: title,
link: $listElement.find('.release-enhancements a').attr('href'),
pubDate: dayjs($listElement.find('.release-date').text()),
});
}
});
ctx.state.data = {
title: 'cpython',
link: 'https://www.python.org/',
item: items,
};
};