forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(route): add CNCF * Update docs/en/programming.md Co-authored-by: Tony <[email protected]> * Update docs/programming.md Co-authored-by: Tony <[email protected]> * Update lib/v2/cncf/maintainer.js Co-authored-by: Tony <[email protected]> Co-authored-by: Tony <[email protected]>
- Loading branch information
Fatpandac
and
Tony
authored
May 20, 2022
1 parent
950bfa6
commit e1347b3
Showing
7 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
const rootURL = 'https://www.cncf.io'; | ||
|
||
module.exports = async (ctx) => { | ||
const cate = ctx.params.cate ?? 'blog'; | ||
const url = `${rootURL}/${cate}/`; | ||
|
||
const response = await got(url); | ||
const $ = cheerio.load(response.data); | ||
const title = $('h1.is-style-page-title').text(); | ||
const list = $('div.post-archive__item') | ||
.map((_index, item) => ({ | ||
title: $(item).find('span.post-archive__title').text().trim(), | ||
link: $(item).find('span.post-archive__title > a').attr('href'), | ||
pubDate: parseDate($(item).find('span.post-archive__item_date').text().split('|')[0]), | ||
})) | ||
.get(); | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const detailResponse = await got(item.link); | ||
const content = cheerio.load(detailResponse.data); | ||
|
||
content('div.post-author').remove(); | ||
content('div.social-share').remove(); | ||
|
||
item.description = content('article').html(); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: `CNCF - ${title}`, | ||
link: url, | ||
item: items, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/:cate?': ['Fatpandac'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module.exports = { | ||
'cncf.io': { | ||
_name: 'CNCF', | ||
'.': [ | ||
{ | ||
title: 'Blog', | ||
docs: 'https://docs.rsshub.app/programming.html#cncf', | ||
source: ['/blog'], | ||
target: '/cncf/blog', | ||
}, | ||
{ | ||
title: 'News', | ||
docs: 'https://docs.rsshub.app/programming.html#cncf', | ||
source: ['/news'], | ||
target: '/cncf/news', | ||
}, | ||
{ | ||
title: 'Announcements', | ||
docs: 'https://docs.rsshub.app/programming.html#cncf', | ||
source: ['/announcements'], | ||
target: '/cncf/announcements', | ||
}, | ||
{ | ||
title: 'Reports', | ||
docs: 'https://docs.rsshub.app/programming.html#cncf', | ||
source: ['/reports'], | ||
target: '/cncf/reports', | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
const rootURL = 'https://www.cncf.io'; | ||
|
||
module.exports = async (ctx) => { | ||
const url = `${rootURL}/reports/`; | ||
|
||
const response = await got(url); | ||
const $ = cheerio.load(response.data); | ||
const list = $('div.report-item') | ||
.map((_index, item) => ({ | ||
title: $(item).find('a.report-item__link').attr('title'), | ||
link: $(item).find('a.report-item__link').attr('href'), | ||
})) | ||
.get(); | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const detailResponse = await got(item.link); | ||
const content = cheerio.load(detailResponse.data); | ||
|
||
item.parseDate = parseDate(content('p.is-style-spaced-uppercase').splice(':')[1]); | ||
item.description = content('article > div.has-background').html(); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: `CNCF - Reports`, | ||
link: url, | ||
item: items, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = function (router) { | ||
router.get('/reports', require('./reports')); | ||
router.get('/:cate?', require('./index')); | ||
}; |