mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-11 15:47:48 +08:00
feat(route): add misskey featured notes (#11842)
* feat(route): add misskey featured notes * fix note.art Co-authored-by: TonyRL <TonyRL@users.noreply.github.com> --------- Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
This commit is contained in:
@@ -179,6 +179,12 @@ These feed do not include boosts (a.k.a. reblogs). RSSHub provides a feed for us
|
||||
|
||||
<RouteEn author="notofoe" example="/mastodon/account_id/mastodon.social/23634/statuses/only_media" path="/mastodon/account/:site/:account_id/statuses/:only_media?" :paramsDesc="['instance address, only domain, no `http://` or `https://` protocol header', 'account id. login your instance, then search for the user profile; the account id is in the url', 'whether only display media content, default to false, any value to true']"/>
|
||||
|
||||
## Misskey
|
||||
|
||||
### Featured Notes
|
||||
|
||||
<RouteEn author="Misaka13514" example="/misskey/notes/featured/misskey.io" path="/misskey/notes/featured/:site" :paramsDesc="['instance address, domain only, without `http://` or `https://` protocol header']" radar="1" rssbud="1"/>
|
||||
|
||||
## piapro
|
||||
|
||||
### User latest works
|
||||
|
||||
@@ -527,6 +527,12 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性
|
||||
|
||||
<Route author="notofoe" example="/mastodon/account_id/mastodon.social/23634/statuses/only_media" path="/mastodon/account/:site/:account_id/statuses/:only_media?" :paramsDesc="['实例地址, 仅域名, 不包括`http://`或`https://`协议头', '用户 ID. 登录实例后, 搜索用户并进入用户页, 在地址中可以找到这串数字', '是否只显示包含媒体(图片或视频)的推文, 默认置空为否, 任意值为是']"/>
|
||||
|
||||
## Misskey
|
||||
|
||||
### 精选笔记
|
||||
|
||||
<Route author="Misaka13514" example="/misskey/notes/featured/misskey.io" path="/misskey/notes/featured/:site" :paramsDesc="['实例地址, 仅域名, 不包括`http://`或`https://`协议头']" radar="1" rssbud="1"/>
|
||||
|
||||
## piapro
|
||||
|
||||
### 用户最新作品
|
||||
|
||||
29
lib/v2/misskey/featured-notes.js
Normal file
29
lib/v2/misskey/featured-notes.js
Normal file
@@ -0,0 +1,29 @@
|
||||
const got = require('@/utils/got');
|
||||
const utils = require('./utils');
|
||||
const config = require('@/config').value;
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const site = ctx.params.site;
|
||||
if (!config.feature.allow_user_supply_unsafe_domain && !utils.allowSiteList.includes(site)) {
|
||||
ctx.throw(403, `This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`);
|
||||
}
|
||||
|
||||
// docs on: https://misskey-hub.net/docs/api/endpoints/notes/featured.html
|
||||
const url = `https://${site}/api/notes/featured`;
|
||||
const response = await got({
|
||||
method: 'post',
|
||||
url,
|
||||
json: {
|
||||
limit: 10,
|
||||
offset: 0,
|
||||
},
|
||||
});
|
||||
|
||||
const list = response.data;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Featured Notes on ${site}`,
|
||||
link: `https://${site}/explore`,
|
||||
item: utils.parseNotes(list, site),
|
||||
};
|
||||
};
|
||||
3
lib/v2/misskey/maintainer.js
Normal file
3
lib/v2/misskey/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/notes/featured/:site': ['Misaka13514'],
|
||||
};
|
||||
35
lib/v2/misskey/radar.js
Normal file
35
lib/v2/misskey/radar.js
Normal file
@@ -0,0 +1,35 @@
|
||||
module.exports = {
|
||||
'misskey.io': {
|
||||
_name: 'Misskey',
|
||||
'.': [
|
||||
{
|
||||
title: 'Featured Notes',
|
||||
docs: 'https://docs.rsshub.app/social-media.html#misskey',
|
||||
source: ['/explore'],
|
||||
target: '/misskey/notes/featured/misskey.io',
|
||||
},
|
||||
],
|
||||
},
|
||||
'madost.one': {
|
||||
_name: 'Misskey',
|
||||
'.': [
|
||||
{
|
||||
title: 'Featured Notes',
|
||||
docs: 'https://docs.rsshub.app/social-media.html#misskey',
|
||||
source: ['/explore'],
|
||||
target: '/misskey/notes/featured/madost.one',
|
||||
},
|
||||
],
|
||||
},
|
||||
'mk.nixnet.social': {
|
||||
_name: 'Misskey',
|
||||
'.': [
|
||||
{
|
||||
title: 'Featured Notes',
|
||||
docs: 'https://docs.rsshub.app/social-media.html#misskey',
|
||||
source: ['/explore'],
|
||||
target: '/misskey/notes/featured/mk.nixnet.social',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
3
lib/v2/misskey/router.js
Normal file
3
lib/v2/misskey/router.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/notes/featured/:site', require('./featured-notes'));
|
||||
};
|
||||
21
lib/v2/misskey/templates/note.art
Normal file
21
lib/v2/misskey/templates/note.art
Normal file
@@ -0,0 +1,21 @@
|
||||
{{ text.replace(/\n/g, '<br>') }}
|
||||
|
||||
{{ each files file }}
|
||||
<br>
|
||||
{{ if file.type.includes('image') }}
|
||||
<img src="{{ file.url }}" />
|
||||
{{ else if file.type.includes('video') }}
|
||||
<video controls poster="{{ file.thumbnailUrl }}">
|
||||
<source src="{{ file.url }}" type="{{ file.type }}">
|
||||
</video>
|
||||
{{ else if file.type.includes('audio') }}
|
||||
<audio controls>
|
||||
<source src="{{ file.url }}" type="{{ file.type }}">
|
||||
</audio>
|
||||
{{ else }}
|
||||
<a href="{{ file.url }}" target="_blank">{{ file.name }}</a>
|
||||
{{ /if }}
|
||||
{{ if file.comment }}
|
||||
<p>{{ file.comment }}</p>
|
||||
{{ /if }}
|
||||
{{ /each }}
|
||||
31
lib/v2/misskey/utils.js
Normal file
31
lib/v2/misskey/utils.js
Normal file
@@ -0,0 +1,31 @@
|
||||
const { art } = require('@/utils/render');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const path = require('path');
|
||||
|
||||
const allowSiteList = ['misskey.io', 'madost.one', 'mk.nixnet.social'];
|
||||
|
||||
// docs on: https://misskey-hub.net/docs/api/entity/note.html
|
||||
const parseNotes = (data, site) =>
|
||||
data.map((item) => {
|
||||
const host = item.user.host === null ? site : item.user.host;
|
||||
const author = `${item.user.name} (@${item.user.username}@${host})`;
|
||||
const description = art(path.join(__dirname, 'templates/note.art'), {
|
||||
text: item.text,
|
||||
files: item.files,
|
||||
});
|
||||
const title = `${author}: "${description}"`;
|
||||
const link = `https://${host}/notes/${item.id}`;
|
||||
const pubDate = parseDate(item.createdAt);
|
||||
return {
|
||||
title,
|
||||
description,
|
||||
pubDate,
|
||||
link,
|
||||
author,
|
||||
};
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
parseNotes,
|
||||
allowSiteList,
|
||||
};
|
||||
Reference in New Issue
Block a user