feat: add crossbell

This commit is contained in:
DIYgod
2023-02-14 20:09:36 +00:00
parent 0a06b2cb9b
commit 2e5df2aa53
10 changed files with 163 additions and 0 deletions
+18
View File
@@ -4,6 +4,24 @@ pageClass: routes
# Social Media
## Crossbell
### Notes
<RouteEn author="DIYgod" example="/crossbell/notes" path="/crossbell/notes" radar="1" rssbud="1"/>
### Notes of character
<RouteEn author="DIYgod" example="/crossbell/notes/character/10" path="/crossbell/notes/character/:characterId" radar="1" rssbud="1"/>
### Notes of source
<RouteEn author="DIYgod" example="/crossbell/notes/source/xlog" path="/crossbell/notes/source/:source" radar="1" rssbud="1"/>
### Feeds of following
<RouteEn author="DIYgod" example="/crossbell/feeds/following/10" path="/crossbell/feeds/following/:characterId" radar="1" rssbud="1"/>
## CuriousCat
### User
+18
View File
@@ -344,6 +344,24 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性
</Route>
## Crossbell
### Notes
<Route author="DIYgod" example="/crossbell/notes" path="/crossbell/notes" radar="1" rssbud="1"/>
### Notes of character
<Route author="DIYgod" example="/crossbell/notes/character/10" path="/crossbell/notes/character/:characterId" radar="1" rssbud="1"/>
### Notes of source
<Route author="DIYgod" example="/crossbell/notes/source/xlog" path="/crossbell/notes/source/:source" radar="1" rssbud="1"/>
### Feeds of following
<Route author="DIYgod" example="/crossbell/feeds/following/10" path="/crossbell/feeds/following/:characterId" radar="1" rssbud="1"/>
## Curius
### 用户
+22
View File
@@ -0,0 +1,22 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const characterId = ctx.params.characterId;
const response = await got(`https://indexer.crossbell.io/v1/characters/${characterId}/feed/follow`);
ctx.state.data = {
title: 'Crossbell Feeds of ' + characterId,
link: 'https://crossbell.io/',
item: response.data?.list?.map((item) => ({
title: `${item.type} ${item.character.metadata?.content?.name}@${item.character.handle}`,
description: `${item.type} ${item.note && `<br>Note: ${item.note.metadata?.content?.title || item.note.metadata?.content?.content}`}${
item.character && `<br>Character: ${item.character.metadata?.content?.name}@${item.character.handle}`
}`,
link: item.note ? item.note?.metadata?.content?.external_urls || `https://crossbell.io/notes/${item.note?.characterId}-${item.note?.noteId}` : 'https://xchar.app/' + item.character?.handle,
pubDate: item.createdAt,
updated: item.updatedAt,
author: item.note?.metadata?.content?.authors?.[0] || item.note?.character?.metadata?.content?.name || item.note?.character?.handle || item.owner,
guid: item.transactionHash + item.logIndex + item.type,
category: [...(item.note?.metadata?.content?.sources || []), ...(item.note?.metadata?.content?.tags || [])],
})),
};
};
+6
View File
@@ -0,0 +1,6 @@
module.exports = {
'/notes': ['DIYgod'],
'/notes/character/:characterId': ['DIYgod'],
'/notes/source/:source': ['DIYgod'],
'/feeds/following/:characterId': ['DIYgod'],
};
+22
View File
@@ -0,0 +1,22 @@
const got = require('@/utils/got');
const { getItem } = require('./utils');
module.exports = async (ctx) => {
const characterId = ctx.params.characterId;
const response = await got('https://indexer.crossbell.io/v1/notes', {
searchParams: {
characterId,
includeCharacter: true,
},
});
const name = response.data?.list?.[0]?.character?.metadata?.content?.name || response.data?.list?.[0]?.character?.handle || characterId;
const handle = response.data?.list?.[0]?.character?.handle;
ctx.state.data = {
title: 'Crossbell Notes from ' + name,
link: 'https://xchar.app/' + handle,
item: response.data?.list?.map((item) => getItem(item)),
};
};
+16
View File
@@ -0,0 +1,16 @@
const got = require('@/utils/got');
const { getItem } = require('./utils');
module.exports = async (ctx) => {
const response = await got('https://indexer.crossbell.io/v1/notes', {
searchParams: {
includeCharacter: true,
},
});
ctx.state.data = {
title: 'Crossbell Notes',
link: 'https://crossbell.io/',
item: response.data?.list?.map((item) => getItem(item)),
};
};
+19
View File
@@ -0,0 +1,19 @@
const got = require('@/utils/got');
const { getItem } = require('./utils');
module.exports = async (ctx) => {
const source = ctx.params.source;
const response = await got('https://indexer.crossbell.io/v1/notes', {
searchParams: {
sources: source,
includeCharacter: true,
},
});
ctx.state.data = {
title: 'Crossbell Notes from ' + source,
link: 'https://crossbell.io/',
item: response.data?.list?.map((item) => getItem(item)),
};
};
+12
View File
@@ -0,0 +1,12 @@
module.exports = {
getItem: (note) => ({
title: note.metadata?.content?.title || '',
description: note.metadata?.content?.content,
link: note.metadata?.content?.external_urls || `https://crossbell.io/notes/${note.characterId}-${note.noteId}`,
pubDate: note.metadata?.content?.publishedAt,
updated: note.metadata?.content?.updatedAt,
author: note.metadata?.content?.authors?.[0] || note.character?.metadata?.content?.name || note.character?.handle,
guid: `${note.characterId}-${note.noteId}`,
category: [...(note.metadata?.content?.sources || []), ...(note.metadata?.content?.tags || [])],
}),
};
+24
View File
@@ -0,0 +1,24 @@
module.exports = {
'crossbell.io': {
_name: 'Crossbell',
'.': [
{
title: 'Notes',
docs: 'https://docs.rsshub.app/social-media.html#crossbell',
source: '/*',
target: '/notes',
},
],
},
'xlog.app': {
_name: 'xLog',
'.': [
{
title: 'Notes',
docs: 'https://docs.rsshub.app/social-media.html#crossbell',
source: '/*',
target: '/notes/source/xlog',
},
],
},
};
+6
View File
@@ -0,0 +1,6 @@
module.exports = function (router) {
router.get('/notes/character/:characterId', require('./notes/character'));
router.get('/notes/source/:source', require('./notes/source'));
router.get('/notes', require('./notes/index'));
router.get('/feeds/following/:characterId', require('./feeds/following'));
};