From ed08cefe307ee4863e18c695abf347cad4b5c56c Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 14 Oct 2022 18:24:07 +0400 Subject: [PATCH] feat(route): thecatcity (#11092) * feat(route): thecatcity * fix: radar * fix: default title --- docs/en/new-media.md | 2 +- docs/new-media.md | 14 +++++++- lib/v2/mckinsey/radar.js | 14 ++++---- lib/v2/tesla/{price => }/maintainer.js | 0 lib/v2/tesla/{price => }/radar.js | 0 lib/v2/thecatcity/index.js | 48 ++++++++++++++++++++++++++ lib/v2/thecatcity/maintainer.js | 3 ++ lib/v2/thecatcity/radar.js | 13 +++++++ lib/v2/thecatcity/router.js | 3 ++ lib/v2/thecatcity/termsMap.js | 30 ++++++++++++++++ 10 files changed, 117 insertions(+), 10 deletions(-) rename lib/v2/tesla/{price => }/maintainer.js (100%) rename lib/v2/tesla/{price => }/radar.js (100%) create mode 100644 lib/v2/thecatcity/index.js create mode 100644 lib/v2/thecatcity/maintainer.js create mode 100644 lib/v2/thecatcity/radar.js create mode 100644 lib/v2/thecatcity/router.js create mode 100644 lib/v2/thecatcity/termsMap.js diff --git a/docs/en/new-media.md b/docs/en/new-media.md index 82b5783831..1075e221f7 100644 --- a/docs/en/new-media.md +++ b/docs/en/new-media.md @@ -764,7 +764,7 @@ Compared to the official one, this feed: ### The Verge - + Provides a better reading experience (full text articles) over the official one. diff --git a/docs/new-media.md b/docs/new-media.md index 365d1097c4..04c0173496 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -1359,7 +1359,7 @@ IPFS 网关有可能失效,那时候换成其他网关。 ### The Verge - + 通过提取文章全文,以提供比官方源更佳的阅读体验. @@ -2950,6 +2950,18 @@ column 为 third 时可选的 category: +## 貓奴日常 + +### 分類 + + + +| 貓物分享 | 貓咪新聞 | 養貓大全 | 貓奴景點 | 新手養貓教學 | +| ---- | ---- | ---- | ---- | ------ | +| 1 | 2 | 3 | 4 | 5 | + + + ## 梅花网 ### 作品 diff --git a/lib/v2/mckinsey/radar.js b/lib/v2/mckinsey/radar.js index 67d420cd74..eaf3492ba3 100644 --- a/lib/v2/mckinsey/radar.js +++ b/lib/v2/mckinsey/radar.js @@ -2,13 +2,11 @@ const { categories } = require('./cn/categoryMap'); module.exports = { 'mckinsey.com.cn': { _name: 'McKinsey Greater China', - '.': [ - { - title: '洞见', - docs: 'https://docs.rsshub.app/finance.html#mai-ken-xi', - source: ['/insights/:category', '/insights'], - target: (params) => `/mckinsey/cn${params.category ? `/${categories.find((c) => c.slug === params.category).key}` : ''}`, - }, - ], + '.': Object.entries(categories).map(([key, value]) => ({ + title: `${value.name} | 洞见`, + docs: 'https://docs.rsshub.app/finance.html#mai-ken-xi', + source: [`/insights/${value.slug}`, '/insights'], + target: `/mckinsey/cn/${key}`, + })), }, }; diff --git a/lib/v2/tesla/price/maintainer.js b/lib/v2/tesla/maintainer.js similarity index 100% rename from lib/v2/tesla/price/maintainer.js rename to lib/v2/tesla/maintainer.js diff --git a/lib/v2/tesla/price/radar.js b/lib/v2/tesla/radar.js similarity index 100% rename from lib/v2/tesla/price/radar.js rename to lib/v2/tesla/radar.js diff --git a/lib/v2/thecatcity/index.js b/lib/v2/thecatcity/index.js new file mode 100644 index 0000000000..555ea5c186 --- /dev/null +++ b/lib/v2/thecatcity/index.js @@ -0,0 +1,48 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const { termsMap } = require('./termsMap'); + +const baseUrl = 'https://thecatcity.com'; + +module.exports = async (ctx) => { + const { term } = ctx.params; + const { data } = await got(`${baseUrl}/node_api/v1/articles/posts`, { + searchParams: { + pageId: 977080509047743, + term, + }, + }); + + const list = data.data.posts.map((post) => ({ + title: post.title, + description: post.description, + link: `${baseUrl}${post.url}`, + pubDate: parseDate(post.post_date), + guid: post.guid, + api: `${baseUrl}/node_api/v1/articles/${post.id}`, + })); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.guid, async () => { + const { data } = await got(item.api, { + searchParams: { + pageId: 977080509047743, + }, + }); + item.description = data.data.post_content; + item.category = [...new Set([...data.data.tags.map((t) => t.name), ...data.data.categories.map((c) => c.name)])]; + item.author = data.data.author.display_name; + return item; + }) + ) + ); + + ctx.state.data = { + title: termsMap[term] ? termsMap[term].title : termsMap[''].title, + description: '提供貓咪日常照顧、新手準備、貓用品、貓咪醫療、貓飲食與行為等相關知識,以及療癒貓影片、貓趣聞、貓小物流行資訊,不論你是貓奴、還是貓控,一切所需都在貓奴日常找到', + link: baseUrl, + image: 'https://assets.presslogic.com/presslogic-hk-tc/static/favicon.ico', + item: items, + }; +}; diff --git a/lib/v2/thecatcity/maintainer.js b/lib/v2/thecatcity/maintainer.js new file mode 100644 index 0000000000..a6c8397fe6 --- /dev/null +++ b/lib/v2/thecatcity/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:term?': ['TonyRL'], +}; diff --git a/lib/v2/thecatcity/radar.js b/lib/v2/thecatcity/radar.js new file mode 100644 index 0000000000..544a9726d0 --- /dev/null +++ b/lib/v2/thecatcity/radar.js @@ -0,0 +1,13 @@ +const { termsMap } = require('./termsMap'); + +module.exports = { + 'thecatcity.com': { + _name: '貓奴日常', + '.': Object.entries(termsMap).map(([key, value]) => ({ + title: value.title, + docs: 'https://docs.rsshub.app/new-media.html#mao-nu-ri-chang', + source: [...new Set([value.slug, '/'])], + target: `/thecatcity${key ? `/${key}` : ''}`, + })), + }, +}; diff --git a/lib/v2/thecatcity/router.js b/lib/v2/thecatcity/router.js new file mode 100644 index 0000000000..0ff3002180 --- /dev/null +++ b/lib/v2/thecatcity/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/:term?', require('./index')); +}; diff --git a/lib/v2/thecatcity/termsMap.js b/lib/v2/thecatcity/termsMap.js new file mode 100644 index 0000000000..850f4800d5 --- /dev/null +++ b/lib/v2/thecatcity/termsMap.js @@ -0,0 +1,30 @@ +const termsMap = { + '': { + title: 'CatCity 貓奴日常 | 貓咪日常照顧、新手準備、貓用品、貓咪醫療', + slug: '/', + }, + 1: { + title: '貓物分享|流行小物、貓咪用品', + slug: '/category/cute-item', + }, + 2: { + title: '貓咪新聞|貓界人氣熱話、貓電影', + slug: '/category/funny-news', + }, + 3: { + title: '養貓大全|貓咪飲食與醫療、行為心理、貓測驗與冷知識', + slug: '/category/knowledge', + }, + 4: { + title: '貓奴景點|貓咪咖啡廳與餐廳、貓奴旅行景點推薦', + slug: '/category/hot-spot', + }, + 5: { + title: '新手養貓教學|養貓準備與花費、日常照顧', + slug: '/category/raise-cats', + }, +}; + +module.exports = { + termsMap, +};