diff --git a/docs/en/programming.md b/docs/en/programming.md index 4b49d215e8..8d3843fe5a 100644 --- a/docs/en/programming.md +++ b/docs/en/programming.md @@ -122,10 +122,11 @@ Category GitHub provides some official RSS feeds: -- Repo releases: https://github.com/:owner/:repo/releases.atom -- Repo commits: https://github.com/:owner/:repo/commits.atom -- User activities: https://github.com/:user.atom -- Private feed: https://github.com/:user.private.atom?token=:secret (You can find **Subscribe to your news feed** in [dashboard](https://github.com) page after login) +- Repo releases: `https://github.com/:owner/:repo/releases.atom` +- Repo commits: `https://github.com/:owner/:repo/commits.atom` +- User activities: `https://github.com/:user.atom` +- Private feed: `https://github.com/:user.private.atom?token=:secret` (You can find **Subscribe to your news feed** in [dashboard](https://github.com) page after login) +- Wiki history: `https://github.com/:owner/:repo/wiki.atom` ::: @@ -211,7 +212,11 @@ For instance, the `/github/topics/framework/l=php&o=desc&s=stars` route will gen ### Issue / Pull Request comments - + + +### Wiki History + + ## GitLab diff --git a/docs/programming.md b/docs/programming.md index 4df15ad753..3c402c816d 100644 --- a/docs/programming.md +++ b/docs/programming.md @@ -222,6 +222,7 @@ GitHub 官方也提供了一些 RSS: - 仓库 commits: `https://github.com/:owner/:repo/commits.atom` - 用户动态: `https://github.com/:user.atom` - 专属动态: `https://github.com/:user.private.atom?token=:secret` (登录后在[仪表盘页面](https://github.com)找到 **Subscribe to your news feed** 字样即可) +- Wiki 历史: `https://github.com/:owner/:repo/wiki.atom` ::: @@ -307,7 +308,11 @@ GitHub 官方也提供了一些 RSS: ### Issue / Pull Request 评论 - + + +### Wiki 历史 + + ## GitLab diff --git a/lib/v2/github/maintainer.js b/lib/v2/github/maintainer.js index 5a7e0d6132..0a0806672f 100644 --- a/lib/v2/github/maintainer.js +++ b/lib/v2/github/maintainer.js @@ -12,4 +12,5 @@ module.exports = { '/topics/:name/:qs?': ['queensferryme'], '/trending/:since/:language?/:spoken_language?': ['DIYgod', 'jameschensmith'], '/user/followers/:user': ['HenryQW'], + '/wiki/:user/:repo/:page?': ['TonyRL'], }; diff --git a/lib/v2/github/radar.js b/lib/v2/github/radar.js index 21f8d6a2c3..7c52391b5a 100644 --- a/lib/v2/github/radar.js +++ b/lib/v2/github/radar.js @@ -2,6 +2,12 @@ module.exports = { 'github.com': { _name: 'GitHub', '.': [ + { + title: '仓库 Branches', + docs: 'https://docs.rsshub.app/programming.html#github', + source: ['/:user/:repo/branches', '/:user/:repo'], + target: '/github/branches/:user/:repo', + }, { title: 'Issues / Pull Requests 评论', docs: 'https://docs.rsshub.app/programming.html#github', @@ -9,28 +15,16 @@ module.exports = { target: '/github/comments/:user/:repo/:number', }, { - title: '用户仓库', + title: '仓库 Contributors', docs: 'https://docs.rsshub.app/programming.html#github', - source: '/:user', - target: '/github/repos/:user', + source: ['/:user/:repo/graphs/contributors', '/:user/:repo'], + target: '/github/contributors/:user/:repo', }, { - title: '用户 Followers', + title: '文件 Commits', 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?', + source: '/:user/:repo/blob/:branch/*filepath', + target: '/github/file/:user/:repo/:branch/:filepath', }, { title: '仓库 Issue', @@ -44,24 +38,18 @@ module.exports = { source: ['/:user/:repo/pulls', '/:user/:repo/pulls/:id', '/:user/:repo'], target: '/github/pull/:user/:repo', }, + { + title: '用户仓库', + docs: 'https://docs.rsshub.app/programming.html#github', + source: '/:user', + target: '/github/repos/:user', + }, { 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', @@ -69,10 +57,28 @@ module.exports = { target: '/github/starred_repos/:user', }, { - title: '仓库 Contributors', + title: 'Topics', docs: 'https://docs.rsshub.app/programming.html#github', - source: ['/:user/:repo/graphs/contributors', '/:user/:repo'], - target: '/github/contributors/:user/:repo', + source: '/topics', + target: '/github/topics/:name/:qs?', + }, + { + title: 'Trending', + docs: 'https://docs.rsshub.app/programming.html#github', + source: '/trending', + target: '/github/trending/:since', + }, + { + title: '用户 Followers', + docs: 'https://docs.rsshub.app/programming.html#github', + source: '/:user', + target: '/github/user/followers/:user', + }, + { + title: 'Wiki 历史', + docs: 'https://docs.rsshub.app/programming.html#github', + source: ['/:user/:repo/wiki/:page/_history', '/:user/:repo/wiki/:page', '/:user/:repo/wiki/_history', '/:user/:repo/wiki'], + target: '/github/wiki/:user/:repo/:page', }, ], }, diff --git a/lib/v2/github/router.js b/lib/v2/github/router.js index 686fd4fd16..43aade1a48 100644 --- a/lib/v2/github/router.js +++ b/lib/v2/github/router.js @@ -13,4 +13,5 @@ module.exports = function (router) { router.get('/topics/:name/:qs?', require('./topic')); router.get('/trending/:since/:language/:spoken_language?', require('./trending')); router.get('/user/followers/:user', require('./follower')); + router.get('/wiki/:user/:repo/:page?', require('./wiki')); }; diff --git a/lib/v2/github/wiki.js b/lib/v2/github/wiki.js new file mode 100644 index 0000000000..2ad3446623 --- /dev/null +++ b/lib/v2/github/wiki.js @@ -0,0 +1,32 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +const baseUrl = 'https://github.com'; + +module.exports = async (ctx) => { + const { user, repo, page } = ctx.params; + + const url = `${baseUrl}/${user}/${repo}/wiki${page ? `/${page}` : ''}/_history`; + + const { data } = await got(url); + const $ = cheerio.load(data); + + const items = $('.js-wiki-history-revision') + .toArray() + .map((item) => { + item = $(item); + return { + title: item.find('.h5').text(), + author: item.find('.mt-1 a').text(), + pubDate: parseDate(item.find('relative-time').attr('datetime')), + link: `${baseUrl}${item.find('.text-mono a').attr('href')}`, + }; + }); + + ctx.state.data = { + title: `${$('.gh-header-title').text()} - ${user}/${repo}`, + link: url, + item: items, + }; +};