diff --git a/docs/en/social-media.md b/docs/en/social-media.md index 68a82fc36..fd2eb2a90 100644 --- a/docs/en/social-media.md +++ b/docs/en/social-media.md @@ -10,6 +10,12 @@ pageClass: routes +## Curius + +### User + + + ## Dev.to ### Top Posts diff --git a/docs/social-media.md b/docs/social-media.md index ea9f9bb98..80142d50b 100644 --- a/docs/social-media.md +++ b/docs/social-media.md @@ -344,6 +344,12 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性 +## Curius + +### 用户 + + + ## Dev.to ### 最高职位 diff --git a/lib/v2/curius/links.js b/lib/v2/curius/links.js new file mode 100644 index 000000000..71fea2c64 --- /dev/null +++ b/lib/v2/curius/links.js @@ -0,0 +1,43 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); + +module.exports = async (ctx) => { + const username = ctx.params.name; + + const name_response = await got(`https://curius.app/api/users/${username}`, { + headers: { + Referer: `https://curius.app/${username}`, + }, + }); + + const data = name_response.data; + + const uid = data.user.id; + const name = `${data.user.firstName} ${data.user.lastName}`; + + const response = await got(`https://curius.app/api/users/${uid}/links?page=0`, { + headers: { + Referer: `https://curius.app/${username}`, + }, + }); + + const items = response.data.userSaved.map((item) => ({ + title: item.title, + description: art(path.join(__dirname, 'templates/description.art'), { + item, + }), + link: item.link, + pubDate: parseDate(item.createdDate), + guid: `curius:${username}:${item.id}`, + })); + + ctx.state.data = { + title: `${name} - Curius`, + link: `https://curius.app/${username}`, + description: `${name} - Curius`, + allowEmpty: true, + item: items, + }; +}; diff --git a/lib/v2/curius/maintainer.js b/lib/v2/curius/maintainer.js new file mode 100644 index 000000000..00a235e5b --- /dev/null +++ b/lib/v2/curius/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/links/:name': ['Ovler-Young'], +}; diff --git a/lib/v2/curius/radar.js b/lib/v2/curius/radar.js new file mode 100644 index 000000000..8fc3e113d --- /dev/null +++ b/lib/v2/curius/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'curius.app': { + _name: 'Curius', + '.': [ + { + title: '用户', + docs: 'https://docs.rsshub.app/social-media.html#curius', + source: '/:name', + target: '/curius/links/:name', + }, + ], + }, +}; diff --git a/lib/v2/curius/router.js b/lib/v2/curius/router.js new file mode 100644 index 000000000..c5482d8a5 --- /dev/null +++ b/lib/v2/curius/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/links/:name', require('./links')); +}; diff --git a/lib/v2/curius/templates/description.art b/lib/v2/curius/templates/description.art new file mode 100644 index 000000000..95c73adba --- /dev/null +++ b/lib/v2/curius/templates/description.art @@ -0,0 +1,16 @@ +{{ if item.metadata.full_text }} + 原文:{{@ item.metadata.full_text.replace(/\n/gm, '
') }}

+{{ /if }} +{{ if item.comments.length }} + 评论:{{ item.comments[0].text.substring(0, 100) }}

+{{ /if }} +{{ if item.highlights.length }} + 评论: + {{ each item.highlights highlight }} + {{ if highlight.comment }} + {{ highlight.highlight }}
评论:{{ highlight.comment.text }}
+ {{ else }} +
标注:{{ highlight.highlight }}
+ {{ /if }} + {{ /each }} +{{ /if }}