From b2f0aaccfe1473bab4ee49d5575ce5ddbc6a3a74 Mon Sep 17 00:00:00 2001 From: TonyRL Date: Wed, 23 Aug 2023 17:37:54 +0000 Subject: [PATCH] refactor(route): move tophub to v2 --- lib/router.js | 4 ++-- lib/{routes => v2}/tophub/index.js | 10 +++++----- lib/v2/tophub/maintainer.js | 3 +++ lib/v2/tophub/radar.js | 13 +++++++++++++ lib/v2/tophub/router.js | 3 +++ .../current/install/README.md | 10 ++++++++-- 6 files changed, 34 insertions(+), 9 deletions(-) rename lib/{routes => v2}/tophub/index.js (80%) create mode 100644 lib/v2/tophub/maintainer.js create mode 100644 lib/v2/tophub/radar.js create mode 100644 lib/v2/tophub/router.js diff --git a/lib/router.js b/lib/router.js index 1c199d092..87bf2f261 100644 --- a/lib/router.js +++ b/lib/router.js @@ -770,8 +770,8 @@ router.get('/blogs/wordpress/:domain/:https?', lazyloadRouteHandler('./routes/bl // 西祠胡同 router.get('/xici/:id?', lazyloadRouteHandler('./routes/xici')); -// 今日热榜 -router.get('/tophub/:id', lazyloadRouteHandler('./routes/tophub')); +// 今日热榜 migrated to v2 +// router.get('/tophub/:id', lazyloadRouteHandler('./routes/tophub')); // 游戏时光 router.get('/vgtime/news', lazyloadRouteHandler('./routes/vgtime/news.js')); diff --git a/lib/routes/tophub/index.js b/lib/v2/tophub/index.js similarity index 80% rename from lib/routes/tophub/index.js rename to lib/v2/tophub/index.js index 68d61d8e7..c00a3e7fc 100644 --- a/lib/routes/tophub/index.js +++ b/lib/v2/tophub/index.js @@ -17,14 +17,14 @@ module.exports = async (ctx) => { const title = $('div.Xc-ec-L.b-L').text().trim(); const out = $('div.Zd-p-Sc > div:nth-child(1) tr') - .map(function () { + .toArray() + .map((e) => { const info = { - title: $(this).find('td.al a').text(), - link: $(this).find('td.al a').attr('href'), + title: $(e).find('td.al a').text(), + link: $(e).find('td.al a').attr('href'), }; return info; - }) - .get(); + }); ctx.state.data = { title, diff --git a/lib/v2/tophub/maintainer.js b/lib/v2/tophub/maintainer.js new file mode 100644 index 000000000..fdeacdedf --- /dev/null +++ b/lib/v2/tophub/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:id': ['LogicJake'], +}; diff --git a/lib/v2/tophub/radar.js b/lib/v2/tophub/radar.js new file mode 100644 index 000000000..0b0304224 --- /dev/null +++ b/lib/v2/tophub/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'tophub.today': { + _name: '今日热榜', + '.': [ + { + title: '榜单', + docs: 'https://docs.rsshub.app/routes/new-media#jin-ri-re-bang-bang-dan', + source: ['/n/:id'], + target: '/tophub/:id', + }, + ], + }, +}; diff --git a/lib/v2/tophub/router.js b/lib/v2/tophub/router.js new file mode 100644 index 000000000..b0440f0cd --- /dev/null +++ b/lib/v2/tophub/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/:id', require('./')); +}; diff --git a/website/i18n/zh/docusaurus-plugin-content-docs/current/install/README.md b/website/i18n/zh/docusaurus-plugin-content-docs/current/install/README.md index be71f2aa5..6244cdb0a 100644 --- a/website/i18n/zh/docusaurus-plugin-content-docs/current/install/README.md +++ b/website/i18n/zh/docusaurus-plugin-content-docs/current/install/README.md @@ -781,11 +781,17 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行 - Civitai - `CIVITAI_COOKIE`: Civitai 登录后的 cookie 值 -- discuz cookies 设定 +- Discourse + + - `DISCOURSE_CONFIG_{id}`: 一个 Discourse 驱动的论坛的配置信息, `id` 可自由设定为任意数字或字符串。值应形如`{"link":link,"key":key}`。其中: + - `link`:论坛的链接。 + - `key`访问论坛API的密钥,可参考[此处代码](https://pastebin.com/YbLCgdWW)以获取。需要确保有足够权限访问对应资源。 + +- Discuz cookies 设定 - `DISCUZ_COOKIE_{cid}`: 某 Discuz 驱动的论坛,用户注册后的 Cookie 值,cid 可自由设定,取值范围 \[00, 99], 使用 discuz 通用路由时,通过指定 cid 来调用该 cookie -- disqus 全部路由:[申请地址](https://disqus.com/api/applications/) +- Disqus 全部路由:[申请地址](https://disqus.com/api/applications/) - `DISQUS_API_KEY`: Disqus API