feat: add grand-challenge (#6082)

This commit is contained in:
Who's Sure
2020-11-02 11:11:55 +00:00
committed by GitHub
parent 14cef9f738
commit 45b6be29bc
4 changed files with 83 additions and 0 deletions
+10
View File
@@ -97,6 +97,16 @@ pageClass: routes
<Route author="ntzyz" example="/dhl/12345678" path="/dhl/:shipment_id" :paramsDesc="['运单号']"/>
## Grand-Challenge
### Challenge 列表
<Route author="WhoIsSure" example="/grandchallenge/challenges" path="/grandchallenge/challenges"/>
### 用户参加的 Challenge
<Route author="WhoIsSure" example="/grandchallenge/user/Isensee" path="/grandchallenge/user/:id" :paramsDesc="['用户ID,必选-用户页面网址里面的用户ID']"/>
## HackerOne
### HackerOne Hacker Activity
+6
View File
@@ -3453,4 +3453,10 @@ router.get('/wsj/:lang/:category', require('./routes/wsj/index'));
// China File
router.get('/chinafile/:category?', require('./routes/chinafile/index'));
// Grand-Challenge-user
router.get('/grandchallenge/user/:id', require('./routes/grandchallenge/user'));
// Grand-Challenge-Challenges
router.get('/grandchallenge/challenges', require('./routes/grandchallenge/challenges'));
module.exports = router;
+33
View File
@@ -0,0 +1,33 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://grand-challenge.org/challenges',
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('.card');
ctx.state.data = {
title: 'Grand-Challenge-challenges',
link: 'https://grand-challenge.org/challenges',
item:
list &&
list
.map((index, item) => {
item = $(item);
const itemPicUrl = item.find('img').attr('src');
const description = item.find('a[data-description]').attr('data-description') || 'No description';
return {
title: item.find('h5').text(),
description: `${description}<br><img src="${itemPicUrl}">`,
link: item.find('.stretched-link').attr('href'),
};
})
.get(),
};
};
+34
View File
@@ -0,0 +1,34 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const id = ctx.params.id;
const response = await got({
method: 'get',
url: `https://grand-challenge.org/users/${id}`,
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('.card');
ctx.state.data = {
title: `${id}'s participations`,
link: `https://grand-challenge.org/users/${id}`,
item:
list &&
list
.map((index, item) => {
item = $(item);
const itemPicUrl = item.find('img').attr('src');
const description = item.find('.card-text').text() || 'No description';
return {
title: item.find('h5').text(),
description: `${description}<br><img src="${itemPicUrl}">`,
link: item.find('.stretched-link').attr('href'),
};
})
.get(),
};
};