feat(route): add gitpod (#9306)

feat(route): gitpod
This commit is contained in:
Tony
2022-03-12 04:52:04 +08:00
committed by GitHub
parent e50dc7058e
commit bf9be2fa3d
9 changed files with 141 additions and 4 deletions
+11 -2
View File
@@ -205,6 +205,16 @@ For instance, the `/github/topics/framework/l=php&o=desc&s=stars` route will gen
<RouteEn author="zoenglinghou" example="/gitlab/tag/rluna-open-source%2Ffile-management%2Fowncloud/core/gitlab.com" path="/gitlab/tag/:namespace/:project/:host?" :paramsDesc="['owner or namespace. `/` needs to be replaced with `%2F`', 'project name', 'Gitlab instance hostname, default to gitlab.com']" />
## Gitpod
### Blog
<RouteEn author="TonyRL" example="/gitpod/blog" path="/gitpod/blog" />
### Changelog
<RouteEn author="TonyRL" example="/gitpod/changelog" path="/gitpod/changelog" />
## Hacker News
### Section
@@ -237,8 +247,7 @@ Subscribe to the updates (threads and submission) from a paritcular Hacker News
### Hex-Rays News
<RouteEn author="hellodword" example="/hex-rays/news" path="/hex-rays/news">
</RouteEn>
<RouteEn author="hellodword" example="/hex-rays/news" path="/hex-rays/news" />
## Kaggle
+11 -2
View File
@@ -283,6 +283,16 @@ GitHub 官方也提供了一些 RSS:
<Route author="zoenglinghou" example="/gitlab/tag/rluna-open-source%2Ffile-management%2Fowncloud/core/gitlab.com" path="/gitlab/tag/:namespace/:project/:host?" :paramsDesc="['项目所有者或命名空间。斜杠`/`需要替代为`%2F`', '项目名称', '服务器地址,缺省为 gitlab.com']" />
## Gitpod
### 博客
<Route author="TonyRL" example="/gitpod/blog" path="/gitpod/blog" />
### 更新日志
<Route author="TonyRL" example="/gitpod/changelog" path="/gitpod/changelog" />
## Go 语言中文网
### 周刊
@@ -803,8 +813,7 @@ GitHub 官方也提供了一些 RSS:
### 开源项目
<Route author="mlogclub" example="/mlog-club/projects" path="/mlog-club/projects">
</Route>
<Route author="mlogclub" example="/mlog-club/projects" path="/mlog-club/projects" />
## 码农网
+52
View File
@@ -0,0 +1,52 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const { rootUrl } = require('./utils');
const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 10;
const response = await got(rootUrl + '/blog');
const $ = cheerio.load(response.data);
let items = $('div[class^="flex justify-center"]')
.slice(0, limit)
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find('h2').text(),
link: rootUrl + item.find('a').attr('href'),
pubDate: parseDate(item.find('span[class^=date]').text()),
};
});
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = cheerio.load(detailResponse.data);
const headerImg = content('img[class^=max-h]');
item.description = art(path.join(__dirname, 'templates/description.art'), {
img: headerImg.attr('src'),
alt: headerImg.attr('alt'),
content: content('div[class^=content-blog]').html(),
});
item.author = content('span.avatars a')
.toArray()
.map((e) => content(e).text().trim())
.join(', ');
return item;
})
)
);
ctx.state.data = {
title: $('title').text(),
link: rootUrl + '/blog',
description: $('meta[name="description"]').attr('content'),
language: 'en-US',
item: items,
};
};
+35
View File
@@ -0,0 +1,35 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const { rootUrl } = require('./utils');
module.exports = async (ctx) => {
const response = await got(rootUrl + '/changelog');
const $ = cheerio.load(response.data);
const items = $('div[class^=changelog-entry]')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find('h2').text(),
link: rootUrl + item.find('a').attr('href'),
description: item.find('div[class^=content-docs]').html(),
pubDate: parseDate(item.find('a[class*=mb-xx-small]').text()),
author: item
.find('span[class^=flex-shrink-0]')
.eq(0)
.find('img')
.toArray()
.map((e) => $(e).attr('alt').replace('Avatar of ', ''))
.join(', '),
};
});
ctx.state.data = {
title: $('title').text(),
link: rootUrl + '/changelog',
description: $('meta[name="description"]').attr('content'),
language: 'en-US',
item: items,
};
};
+4
View File
@@ -0,0 +1,4 @@
module.exports = {
'/blog': ['TonyRL'],
'/changelog': ['TonyRL'],
};
+19
View File
@@ -0,0 +1,19 @@
module.exports = {
'gitpod.io': {
_name: 'Gitpod',
'.': [
{
title: '博客',
docs: 'https://docs.rsshub.app/programming.html#gitpod',
source: ['/blog', '/'],
target: '/gitpod/blog',
},
{
title: '更新日志',
docs: 'https://docs.rsshub.app/programming.html#gitpod',
source: ['/changelog', '/'],
target: '/gitpod/changelog',
},
],
},
};
+4
View File
@@ -0,0 +1,4 @@
module.exports = (router) => {
router.get('/blog', require('./blog'));
router.get('/changelog', require('./changelog'));
};
+2
View File
@@ -0,0 +1,2 @@
<img src="{{ img }}" alt="{{ alt }}">
{{@ content }}
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
rootUrl: 'https://www.gitpod.io',
};