From c9d4f76733efae23ba0fb5f2854729b2c0ba7ed7 Mon Sep 17 00:00:00 2001 From: Ovler Date: Sat, 26 Nov 2022 22:52:38 +0800 Subject: [PATCH 1/2] feat(route): add curius.app (#11182) * feat(route): curius.app * fix typo * fix undefined * use full text * Change style * add tab * upd * edit example * Specify the root domain only * Fix maintainer.js * fix typo * update link * fix: multiple fixes --- docs/en/social-media.md | 6 ++++ docs/social-media.md | 6 ++++ lib/v2/curius/links.js | 43 +++++++++++++++++++++++++ lib/v2/curius/maintainer.js | 3 ++ lib/v2/curius/radar.js | 13 ++++++++ lib/v2/curius/router.js | 3 ++ lib/v2/curius/templates/description.art | 16 +++++++++ 7 files changed, 90 insertions(+) create mode 100644 lib/v2/curius/links.js create mode 100644 lib/v2/curius/maintainer.js create mode 100644 lib/v2/curius/radar.js create mode 100644 lib/v2/curius/router.js create mode 100644 lib/v2/curius/templates/description.art diff --git a/docs/en/social-media.md b/docs/en/social-media.md index 68a82fc366baa0..fd2eb2a901d1cc 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 ea9f9bb98dbf91..80142d50bc3aad 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 00000000000000..71fea2c648fe68 --- /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 00000000000000..00a235e5b6343b --- /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 00000000000000..8fc3e113db1c9d --- /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 00000000000000..c5482d8a527e9e --- /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 00000000000000..95c73adbae6b65 --- /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 }} From 7a9762b12b7d540b6eba1e9efe2499acd88fd083 Mon Sep 17 00:00:00 2001 From: Rongrong Date: Sat, 26 Nov 2022 23:25:23 +0800 Subject: [PATCH 2/2] fix(route/telegram/channel): unsupported message (#11321) Not all unsupported messages are really unsupported (e.g. messages with custom emoji) Signed-off-by: Rongrong Signed-off-by: Rongrong --- lib/v2/telegram/channel.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/v2/telegram/channel.js b/lib/v2/telegram/channel.js index 618049cad743d2..2f6e09dde19a2a 100644 --- a/lib/v2/telegram/channel.js +++ b/lib/v2/telegram/channel.js @@ -25,6 +25,7 @@ const STICKER = 'STICKER'; const ANIMATED_STICKER = 'ANIMATED_STICKER'; // const VIDEO_STICKER = 'VIDEO_STICKER'; // not supported yet by t.me const UNSUPPORTED = 'UNSUPPORTED'; +const PARTIALLY_UNSUPPORTED = 'PARTIALLY_UNSUPPORTED'; /* message media tag dict */ const mediaTagDict = { @@ -45,6 +46,7 @@ const mediaTagDict = { ANIMATED_STICKER: ['[Animated Sticker]', '[Animated Sticker]'], // VIDEO_STICKER: ['[Video Sticker]', '[Video Sticker]'], // not supported yet by t.me UNSUPPORTED: ['[Unsupported]', '🚫'], + PARTIALLY_UNSUPPORTED: ['', ''], }; module.exports = async (ctx) => { @@ -157,10 +159,14 @@ module.exports = async (ctx) => { if (item.find('.tgme_widget_message_tgsticker').length) { msgTypes.push(ANIMATED_STICKER); } - if (msgTypes.length === 0 && item.find('.message_media_not_supported').length) { - msgTypes.unshift(UNSUPPORTED); - if (!includeUnsupportedMsg) { - return null; // drop unsupported message + if (item.find('.message_media_not_supported').length) { + if (item.find('.media_supported_cont').length) { + msgTypes.unshift(PARTIALLY_UNSUPPORTED); + } else { + if (msgTypes.length === 0 && !includeUnsupportedMsg) { + return null; // drop unsupported message + } + msgTypes.unshift(UNSUPPORTED); } } // all other types above cannot be mixed @@ -496,7 +502,7 @@ module.exports = async (ctx) => { const pubDate = parseDate(item.find('.tgme_widget_message_date time').attr('datetime')); /* message text & title */ - const messageTextObj = item.find('.tgme_widget_message_bubble > .tgme_widget_message_text'); + const messageTextObj = item.find(`.${msgTypes.includes(PARTIALLY_UNSUPPORTED) ? 'media_supported_cont' : 'tgme_widget_message_bubble'} > .tgme_widget_message_text`); let messageHtml = '', messageTitle = '';