mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-03 02:28:23 +08:00
feat(route): add bitbucket commits and tags (#9316)
* add bitbucket commits and tags * add english doc * fix bitbucket radar.js * fix bitbucket docs * docs: add bitbucket cn docs * fix: use parseDate utils
This commit is contained in:
@@ -508,6 +508,11 @@ See docs of the specified route and `lib/config.js` for detailed information.
|
|||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
- Bitbucket: [Basic auth with App passwords](https://developer.atlassian.com/cloud/bitbucket/rest/intro/#basic-auth)
|
||||||
|
|
||||||
|
- `BITBUCKET_USERNAME`: Your Bitbucket username
|
||||||
|
- `BITBUCKET_PASSWORD`: Your Bitbucket app password
|
||||||
|
|
||||||
- Discuz cookie
|
- Discuz cookie
|
||||||
|
|
||||||
- `DISCUZ_COOKIE_{cid}`: Cookie of a forum powered by Discuz, cid can be anything from 00 to 99. When visiting a Discuz route, use cid to specify this cookie.
|
- `DISCUZ_COOKIE_{cid}`: Cookie of a forum powered by Discuz, cid can be anything from 00 to 99. When visiting a Discuz route, use cid to specify this cookie.
|
||||||
|
|||||||
@@ -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']" />
|
<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']" />
|
||||||
|
|
||||||
|
## Bitbucket
|
||||||
|
|
||||||
|
### Commits
|
||||||
|
|
||||||
|
<RouteEn author="AuroraDysis" example="/bitbucket/commits/blaze-lib/blaze" path="/bitbucket/commits/:workspace/:repo_slug" :paramsDesc="['Workspace', 'Repository']" rssbud="1" rssbud="1"/>
|
||||||
|
|
||||||
|
### Tags
|
||||||
|
|
||||||
|
<RouteEn author="AuroraDysis" example="/bitbucket/tags/blaze-lib/blaze" path="/bitbucket/tags/:workspace/:repo_slug" :paramsDesc="['Workspace', 'Repository']" rssbud="1" rssbud="1"/>
|
||||||
|
|
||||||
## Gitpod
|
## Gitpod
|
||||||
|
|
||||||
### Blog
|
### Blog
|
||||||
|
|||||||
@@ -525,6 +525,11 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行
|
|||||||
3. 点击 dynamic_new 请求,找到 Cookie
|
3. 点击 dynamic_new 请求,找到 Cookie
|
||||||
4. 视频和专栏只要求 `SESSDATA` 字段,动态需复制整段 Cookie
|
4. 视频和专栏只要求 `SESSDATA` 字段,动态需复制整段 Cookie
|
||||||
|
|
||||||
|
- Bitbucket: [Basic auth with App passwords](https://developer.atlassian.com/cloud/bitbucket/rest/intro/#basic-auth)
|
||||||
|
|
||||||
|
- `BITBUCKET_USERNAME`: 你的 Bitbucket 用户名
|
||||||
|
- `BITBUCKET_PASSWORD`: 你的 Bitbucket 密码
|
||||||
|
|
||||||
- BTBYR
|
- BTBYR
|
||||||
|
|
||||||
- `BTBYR_HOST`: 支持 ipv4 访问的 BTBYR 镜像,默认为原站 `https://bt.byr.cn/`。
|
- `BTBYR_HOST`: 支持 ipv4 访问的 BTBYR 镜像,默认为原站 `https://bt.byr.cn/`。
|
||||||
|
|||||||
@@ -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']" />
|
<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']" />
|
||||||
|
|
||||||
|
## Bitbucket
|
||||||
|
|
||||||
|
### Commits
|
||||||
|
|
||||||
|
<Route author="AuroraDysis" example="/bitbucket/commits/blaze-lib/blaze" path="/bitbucket/commits/:workspace/:repo_slug" :paramsDesc="['Workspace', 'Repository']" rssbud="1" rssbud="1"/>
|
||||||
|
|
||||||
|
### Tags
|
||||||
|
|
||||||
|
<Route author="AuroraDysis" example="/bitbucket/tags/blaze-lib/blaze" path="/bitbucket/tags/:workspace/:repo_slug" :paramsDesc="['Workspace', 'Repository']" rssbud="1" rssbud="1"/>
|
||||||
|
|
||||||
## Gitpod
|
## Gitpod
|
||||||
|
|
||||||
### 博客
|
### 博客
|
||||||
|
|||||||
@@ -91,6 +91,10 @@ const calculateValue = () => {
|
|||||||
bilibili: {
|
bilibili: {
|
||||||
cookies: bilibili_cookies,
|
cookies: bilibili_cookies,
|
||||||
},
|
},
|
||||||
|
bitbucket: {
|
||||||
|
username: envs.BITBUCKET_USERNAME,
|
||||||
|
password: envs.BITBUCKET_PASSWORD,
|
||||||
|
},
|
||||||
btbyr: {
|
btbyr: {
|
||||||
host: envs.BTBYR_HOST,
|
host: envs.BTBYR_HOST,
|
||||||
cookies: envs.BTBYR_COOKIE,
|
cookies: envs.BTBYR_COOKIE,
|
||||||
|
|||||||
40
lib/v2/bitbucket/commits.js
Normal file
40
lib/v2/bitbucket/commits.js
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const config = require('@/config').value;
|
||||||
|
const queryString = require('query-string');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const workspace = ctx.params.workspace;
|
||||||
|
const repo_slug = ctx.params.repo_slug;
|
||||||
|
|
||||||
|
const headers = {
|
||||||
|
Accept: 'application/json',
|
||||||
|
};
|
||||||
|
let auth = '';
|
||||||
|
if (config.bitbucket && config.bitbucket.username && config.bitbucket.password) {
|
||||||
|
auth = config.bitbucket.username + ':' + config.bitbucket.password + '@';
|
||||||
|
}
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: `https://${auth}api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/commits/`,
|
||||||
|
searchParams: queryString.stringify({
|
||||||
|
sort: '-target.date',
|
||||||
|
}),
|
||||||
|
headers,
|
||||||
|
});
|
||||||
|
const data = response.data.values;
|
||||||
|
ctx.state.data = {
|
||||||
|
allowEmpty: true,
|
||||||
|
title: `Recent Commits to ${workspace}/${repo_slug}`,
|
||||||
|
link: `https://bitbucket.org/${workspace}/${repo_slug}`,
|
||||||
|
item:
|
||||||
|
data &&
|
||||||
|
data.map((item) => ({
|
||||||
|
title: item.message,
|
||||||
|
author: item.author.raw,
|
||||||
|
description: item.rendered.message.html || 'No description',
|
||||||
|
pubDate: parseDate(item.date),
|
||||||
|
link: item.links.html.href,
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
};
|
||||||
4
lib/v2/bitbucket/maintainer.js
Normal file
4
lib/v2/bitbucket/maintainer.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
module.exports = {
|
||||||
|
'/commits/:workspace/:repo_slug': ['AuroraDysis'],
|
||||||
|
'/tags/:workspace/:repo_slug': ['AuroraDysis'],
|
||||||
|
};
|
||||||
19
lib/v2/bitbucket/radar.js
Normal file
19
lib/v2/bitbucket/radar.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
module.exports = {
|
||||||
|
'bitbucket.com': {
|
||||||
|
_name: 'Bitbucket',
|
||||||
|
'.': [
|
||||||
|
{
|
||||||
|
title: 'Commits',
|
||||||
|
docs: 'https://docs.rsshub.app/programming.html#bitbucket',
|
||||||
|
source: ['/commits/:workspace/:repo_slug'],
|
||||||
|
target: '/bitbucket/commits/:workspace/:repo_slug',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Tags',
|
||||||
|
docs: 'https://docs.rsshub.app/programming.html#bitbucket',
|
||||||
|
source: ['/tags/:workspace/:repo_slug'],
|
||||||
|
target: '/bitbcuket/tags/:workspace/:repo_slug',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
4
lib/v2/bitbucket/router.js
Normal file
4
lib/v2/bitbucket/router.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
module.exports = (router) => {
|
||||||
|
router.get('/commits/:workspace/:repo_slug', require('./commits'));
|
||||||
|
router.get('/tags/:workspace/:repo_slug', require('./tags'));
|
||||||
|
};
|
||||||
40
lib/v2/bitbucket/tags.js
Normal file
40
lib/v2/bitbucket/tags.js
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const config = require('@/config').value;
|
||||||
|
const queryString = require('query-string');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const workspace = ctx.params.workspace;
|
||||||
|
const repo_slug = ctx.params.repo_slug;
|
||||||
|
|
||||||
|
const headers = {
|
||||||
|
Accept: 'application/json',
|
||||||
|
};
|
||||||
|
let auth = '';
|
||||||
|
if (config.bitbucket && config.bitbucket.username && config.bitbucket.password) {
|
||||||
|
auth = config.bitbucket.username + ':' + config.bitbucket.password + '@';
|
||||||
|
}
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: `https://${auth}api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/refs/tags/`,
|
||||||
|
searchParams: queryString.stringify({
|
||||||
|
sort: '-target.date',
|
||||||
|
}),
|
||||||
|
headers,
|
||||||
|
});
|
||||||
|
const data = response.data.values;
|
||||||
|
ctx.state.data = {
|
||||||
|
allowEmpty: true,
|
||||||
|
title: `Recent Tags in ${workspace}/${repo_slug}`,
|
||||||
|
link: `https://bitbucket.org/${workspace}/${repo_slug}`,
|
||||||
|
item:
|
||||||
|
data &&
|
||||||
|
data.map((item) => ({
|
||||||
|
title: item.name,
|
||||||
|
author: item.tagger.raw,
|
||||||
|
description: item.message || 'No description',
|
||||||
|
pubDate: parseDate(item.date),
|
||||||
|
link: item.links.html.href,
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user