From 22b19f2a4fe8532137d0abb4def8e8aa1057571d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E5=B0=8F=E8=8D=89?= <467195537@qq.com> Date: Fri, 10 Feb 2023 12:14:49 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20=E5=A2=9E=E5=8A=A0Issue=20Hunt?= =?UTF-8?q?=E8=AE=A2=E9=98=85=20(#11818)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(route): 增加Issue Hunt订阅 * feat(route): 增加英文文档和Markdown解析 * Update lib/v2/issuehunt/maintainer.js * Update docs/en/programming.md * Update lib/v2/issuehunt/radar.js * Update docs/programming.md * Update lib/v2/issuehunt/radar.js * Update docs/programming.md --------- --- docs/en/programming.md | 6 ++++++ docs/programming.md | 6 ++++++ lib/v2/issuehunt/funded.js | 28 ++++++++++++++++++++++++++++ lib/v2/issuehunt/maintainer.js | 3 +++ lib/v2/issuehunt/radar.js | 13 +++++++++++++ lib/v2/issuehunt/router.js | 3 +++ 6 files changed, 59 insertions(+) create mode 100644 lib/v2/issuehunt/funded.js create mode 100644 lib/v2/issuehunt/maintainer.js create mode 100644 lib/v2/issuehunt/radar.js create mode 100644 lib/v2/issuehunt/router.js diff --git a/docs/en/programming.md b/docs/en/programming.md index 8d3843fe5..9ebe1e719 100644 --- a/docs/en/programming.md +++ b/docs/en/programming.md @@ -290,6 +290,12 @@ Subscribe to the updates (threads and submission) from a paritcular Hacker News +## Issue Hunt + +### Project Funded + + + ## Kaggle ### Discussion diff --git a/docs/programming.md b/docs/programming.md index 96d3c2449..c95e934ff 100644 --- a/docs/programming.md +++ b/docs/programming.md @@ -461,6 +461,12 @@ GitHub 官方也提供了一些 RSS: +## Issue Hunt + +### 项目悬赏 + + + ## ITSlide ### 最新 diff --git a/lib/v2/issuehunt/funded.js b/lib/v2/issuehunt/funded.js new file mode 100644 index 000000000..fd519cc02 --- /dev/null +++ b/lib/v2/issuehunt/funded.js @@ -0,0 +1,28 @@ +const got = require('@/utils/got'); +const MarkdownIt = require('markdown-it'); + +module.exports = async (ctx) => { + const { username, repo } = ctx.params; + const response = await got(`https://issuehunt.io/apis/pages/repos/show?repositoryOwnerName=${username}&repositoryName=${repo}`); + + const { issues } = response.data; + if (issues === undefined) { + throw new Error('没有获取到数据'); + } + + const md = MarkdownIt({ + html: true, + }); + ctx.state.data = { + title: `Issue Hunt 的悬赏 -- ${username}/${repo}`, + link: `https://issuehunt.io/r/${username}/${repo}`, + description: ``, + item: issues.map((item) => ({ + title: item.title, + description: md.render(item.body), + pubDate: item.fundedAt, + link: `https://issuehunt.io/r/${username}/${repo}/issues/${item.number}`, + author: item.userName, + })), + }; +}; diff --git a/lib/v2/issuehunt/maintainer.js b/lib/v2/issuehunt/maintainer.js new file mode 100644 index 000000000..4e93e6de8 --- /dev/null +++ b/lib/v2/issuehunt/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/funded/:username/:repo': ['running-grass'], +}; diff --git a/lib/v2/issuehunt/radar.js b/lib/v2/issuehunt/radar.js new file mode 100644 index 000000000..14205b61e --- /dev/null +++ b/lib/v2/issuehunt/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'issuehunt.io': { + _name: 'Issue Hunt', + '.': [ + { + title: '项目悬赏', + docs: 'https://docs.rsshub.app/programming.html#issue-hunt-xiang-mu-xuan-shang', + source: '/r/:username/:repo', + target: ({ username, repo }) => `/issuehunt/funded/${username}/${repo}`, + }, + ], + }, +}; diff --git a/lib/v2/issuehunt/router.js b/lib/v2/issuehunt/router.js new file mode 100644 index 000000000..dd0e8c553 --- /dev/null +++ b/lib/v2/issuehunt/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/funded/:username/:repo', require('./funded')); +};