fix(route): fix GitHub route parameter conflict at trending.js and refactor to V2 (#8923)

* Fix(route): fix route parameter conflict at trending.js and change to V2

* Fix(route): modify the judgment condition of language parameter

* Fix(docs): Update docs/programming.md

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Fix(docs): Update docs/en/programming.md

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* fix(docs/route): add author and sort routes

* Fix(route): Update docs/en/programming.md

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Fix(route): sort routes

Co-authored-by: Tony <TonyRL@users.noreply.github.com>
This commit is contained in:
Fatpandac
2022-02-03 00:37:01 +08:00
committed by GitHub
parent 6553bbad45
commit 03481653fa
19 changed files with 95 additions and 90 deletions

View File

@@ -98,7 +98,7 @@ GitHub provides some official RSS feeds:
### Trending
<RouteEn path="/github/trending/:since/:language?" example="/github/trending/daily/javascript" :paramsDesc="['time frame, available in [Trending page](https://github.com/trending/javascript?since=monthly) \'s URL, possible values are: daily, weekly or monthly', 'the feed language, available in [Trending page](https://github.com/trending/javascript?since=monthly) \'s URL']" radar="1" rssbud="1"/>
<RouteEn author="DIYgod" path="/github/trending/:since/:language/:spoken_language?" example="/github/trending/daily/javascript/en" :paramsDesc="['time frame, available in [Trending page](https://github.com/trending/javascript?since=monthly) \'s URL, possible values are: `daily`, `weekly` or `monthly`', 'the feed language, available in [Trending page](https://github.com/trending/javascript?since=monthly) \'s URL, don\'t filter option is `any`', 'natural language, available in [Trending page](https://github.com/trending/javascript?since=monthly) \'s URL']" radar="1" rssbud="1"/>
### Topics

View File

@@ -175,7 +175,7 @@ GitHub 官方也提供了一些 RSS:
### Trending
<Route author="DIYgod" example="/github/trending/daily/javascript/zh" path="/github/trending/:since/:language?/:spoken_language?" :paramsDesc="['时间跨度, 可在 [Trending 页](https://github.com/trending/javascript?since=monthly&spoken_language_code=zh) URL 中找到, 可选 daily weekly monthly', '语言, 可在 [Trending 页](https://github.com/trending/javascript?since=monthly&spoken_language_code=zh) URL 中找到', '自然语言, 可在 [Trending 页](https://github.com/trending/javascript?since=monthly&spoken_language_code=zh) URL 中找到']" radar="1" rssbud="1"/>
<Route author="DIYgod" example="/github/trending/daily/javascript/zh" path="/github/trending/:since/:language/:spoken_language?" :paramsDesc="['时间跨度, 可在 [Trending 页](https://github.com/trending/javascript?since=monthly&spoken_language_code=zh) URL 中找到, 可选 `daily` `weekly` `monthly`', '语言, 可在 [Trending 页](https://github.com/trending/javascript?since=monthly&spoken_language_code=zh) URL 中找到`any`表示不设语言限制', '自然语言, 可在 [Trending 页](https://github.com/trending/javascript?since=monthly&spoken_language_code=zh) URL 中找到']" radar="1" rssbud="1"/>
### Topics

View File

@@ -243,77 +243,6 @@ module.exports = {
},
],
},
'github.com': {
_name: 'GitHub',
'.': [
{
title: '用户仓库',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/:user',
target: '/github/repos/:user',
},
{
title: '用户 Followers',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/:user',
target: '/github/user/followers/:user',
},
{
title: 'Trending',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/trending',
target: '/github/trending/:since',
},
{
title: 'Trending',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/topics',
target: '/github/topics/:name/:qs?',
},
{
title: '仓库 Issue',
docs: 'https://docs.rsshub.app/programming.html#github',
source: ['/:user/:repo/issues', '/:user/:repo/issues/:id', '/:user/:repo'],
target: '/github/issue/:user/:repo',
},
{
title: '仓库 Pull Requests',
docs: 'https://docs.rsshub.app/programming.html#github',
source: ['/:user/:repo/pulls', '/:user/:repo/pulls/:id', '/:user/:repo'],
target: '/github/pull/:user/:repo',
},
{
title: '仓库 Stars',
docs: 'https://docs.rsshub.app/programming.html#github',
source: ['/:user/:repo/stargazers', '/:user/:repo'],
target: '/github/stars/:user/:repo',
},
{
title: '仓库 Branches',
docs: 'https://docs.rsshub.app/programming.html#github',
source: ['/:user/:repo/branches', '/:user/:repo'],
target: '/github/branches/:user/:repo',
},
{
title: '文件 Commits',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/:user/:repo/blob/:branch/*filepath',
target: '/github/file/:user/:repo/:branch/:filepath',
},
{
title: '用户 Starred Repositories',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/:user',
target: '/github/starred_repos/:user',
},
{
title: '仓库 Contributors',
docs: 'https://docs.rsshub.app/programming.html#github',
source: ['/:user/:repo/graphs/contributors', '/:user/:repo'],
target: '/github/contributors/:user/:repo',
},
],
},
'zhihu.com': {
_name: '知乎',
www: [

View File

@@ -245,20 +245,6 @@ router.get('/v2ex/tab/:tabid', lazyloadRouteHandler('./routes/v2ex/tab'));
// readhub
router.get('/readhub/category/:category', lazyloadRouteHandler('./routes/readhub/category'));
// GitHub
router.get('/github/repos/:user', lazyloadRouteHandler('./routes/github/repos'));
router.get('/github/trending/:since/:language?/:spoken_language?', lazyloadRouteHandler('./routes/github/trending'));
router.get('/github/issue/:user/:repo/:state?/:labels?', lazyloadRouteHandler('./routes/github/issue'));
router.get('/github/pull/:user/:repo', lazyloadRouteHandler('./routes/github/pulls'));
router.get('/github/user/followers/:user', lazyloadRouteHandler('./routes/github/follower'));
router.get('/github/stars/:user/:repo', lazyloadRouteHandler('./routes/github/star'));
router.get('/github/search/:query/:sort?/:order?', lazyloadRouteHandler('./routes/github/search'));
router.get('/github/branches/:user/:repo', lazyloadRouteHandler('./routes/github/branches'));
router.get('/github/file/:user/:repo/:branch/:filepath+', lazyloadRouteHandler('./routes/github/file'));
router.get('/github/starred_repos/:user', lazyloadRouteHandler('./routes/github/starred_repos'));
router.get('/github/contributors/:user/:repo/:order?/:anon?', lazyloadRouteHandler('./routes/github/contributors'));
router.get('/github/topics/:name/:qs?', lazyloadRouteHandler('./routes/github/topic'));
// f-droid
router.get('/fdroid/apprelease/:app', lazyloadRouteHandler('./routes/fdroid/apprelease'));

View File

@@ -1,3 +1,15 @@
module.exports = {
'/branches/:user/:repo': ['max-arnold'],
'/comments/:user/:repo/:type/:number': ['TonyRL'],
'/contributors/:user/:repo/:order?/:anon?': ['zoenglinghou'],
'/file/:user/:repo/:branch/:filepath+': ['zengxs'],
'/issue/:user/:repo/:state?/:labels?': ['HenryQW', 'AndreyMZ'],
'/pull/:user/:repo': ['hashman'],
'/repos/:user': ['DIYgod'],
'/search/:query/:sort?/:order?': ['LogicJake'],
'/starred_repos/:user': ['LanceZhu'],
'/stars/:user/:repo': ['HenryQW'],
'/topics/:name/:qs?': ['queensferryme'],
'/trending/:since/:language?/:spoken_language?': ['DIYgod'],
'/user/followers/:user': ['HenryQW'],
};

View File

@@ -8,6 +8,72 @@ module.exports = {
source: ['/:user/:repo/:type/:number'],
target: '/github/comments/:user/:repo/:type/:number',
},
{
title: '用户仓库',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/:user',
target: '/github/repos/:user',
},
{
title: '用户 Followers',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/:user',
target: '/github/user/followers/:user',
},
{
title: 'Trending',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/trending',
target: '/github/trending/:since',
},
{
title: 'Trending',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/topics',
target: '/github/topics/:name/:qs?',
},
{
title: '仓库 Issue',
docs: 'https://docs.rsshub.app/programming.html#github',
source: ['/:user/:repo/issues', '/:user/:repo/issues/:id', '/:user/:repo'],
target: '/github/issue/:user/:repo',
},
{
title: '仓库 Pull Requests',
docs: 'https://docs.rsshub.app/programming.html#github',
source: ['/:user/:repo/pulls', '/:user/:repo/pulls/:id', '/:user/:repo'],
target: '/github/pull/:user/:repo',
},
{
title: '仓库 Stars',
docs: 'https://docs.rsshub.app/programming.html#github',
source: ['/:user/:repo/stargazers', '/:user/:repo'],
target: '/github/stars/:user/:repo',
},
{
title: '仓库 Branches',
docs: 'https://docs.rsshub.app/programming.html#github',
source: ['/:user/:repo/branches', '/:user/:repo'],
target: '/github/branches/:user/:repo',
},
{
title: '文件 Commits',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/:user/:repo/blob/:branch/*filepath',
target: '/github/file/:user/:repo/:branch/:filepath',
},
{
title: '用户 Starred Repositories',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/:user',
target: '/github/starred_repos/:user',
},
{
title: '仓库 Contributors',
docs: 'https://docs.rsshub.app/programming.html#github',
source: ['/:user/:repo/graphs/contributors', '/:user/:repo'],
target: '/github/contributors/:user/:repo',
},
],
},
};

View File

@@ -1,3 +1,15 @@
module.exports = function (router) {
router.get('/branches/:user/:repo', require('./branches'));
router.get('/comments/:user/:repo/:type/:number', require('./comments'));
router.get('/contributors/:user/:repo/:order?/:anon?', require('./contributors'));
router.get('/file/:user/:repo/:branch/:filepath+', require('./file'));
router.get('/issue/:user/:repo/:state?/:labels?', require('./issue'));
router.get('/pull/:user/:repo', require('./pulls'));
router.get('/repos/:user', require('./repos'));
router.get('/search/:query/:sort?/:order?', require('./search'));
router.get('/starred_repos/:user', require('./starred_repos'));
router.get('/stars/:user/:repo', require('./star'));
router.get('/topics/:name/:qs?', require('./topic'));
router.get('/trending/:since/:language/:spoken_language?', require('./trending'));
router.get('/user/followers/:user', require('./follower'));
};

View File

@@ -3,8 +3,8 @@ const cheerio = require('cheerio');
module.exports = async (ctx) => {
const since = ctx.params.since;
const language = ctx.params.language || '';
const spoken_language = ctx.params.spoken_language || '';
const language = ctx.params.language === 'any' ? '' : ctx.params.language;
const spoken_language = ctx.params.spoken_language ?? '';
const url = `https://github.com/trending/${encodeURIComponent(language)}?since=${since}&spoken_language_code=${spoken_language}`;
const response = await got({
@@ -32,7 +32,7 @@ module.exports = async (ctx) => {
title: item.find('h1').text(),
author: item.find('h1').text().split('/')[0].trim(),
description: `${item.find('.pr-4').text()}<br>
<br>Language: ${item.find('span[itemprop="programmingLanguage"]').text() || 'unknown'}
<br>Language: ${item.find('span[itemprop="programmingLanguage"]').text() ?? 'unknown'}
<br>Star: ${item.find('.Link--muted').eq(0).text().trim()}
<br>Fork: ${item.find('.Link--muted').eq(1).text().trim()}`,
link: `https://github.com${item.find('h1 a').attr('href')}`,