feat(route): zuvio (#10529)
* feat(route): student5 * docs: add docs * fix: timezone
This commit is contained in:
parent
1c114759a9
commit
78ccdc7848
10
docs/bbs.md
10
docs/bbs.md
|
|
@ -384,6 +384,16 @@ pageClass: routes
|
|||
|
||||
<Route author="liyefox" example="/v2ex/tab/hot" path="/v2ex/tab/:tabid" :paramsDesc="['tab标签ID,在 URL 可以找到']"/>
|
||||
|
||||
## Zuvio
|
||||
|
||||
### 校園話題
|
||||
|
||||
<Route author="TonyRL" example="/zuvio/student5/34" path="/zuvio/student5/:board?" :paramsDesc="['看板 ID,空为全站文章,可在看板 URL 或下方路由找到']" radar="1" rssbud="1"/>
|
||||
|
||||
### 看板列表
|
||||
|
||||
<Route author="TonyRL" example="/zuvio/student5/boards" path="/zuvio/student5/boards" />
|
||||
|
||||
## 巴哈姆特電玩資訊站
|
||||
|
||||
### 熱門推薦
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
const { getBoards, rootUrl } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const items = await getBoards(ctx.cache.tryGet);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Zuvio 校園話題列表 - 大學生論壇',
|
||||
description: 'Zuvio 校園話題,Zuvio 校園話題千種動物頭像交流心得。最萌的匿名論壇,上千種逗趣動物頭像隨你變換,點頭像立即私訊功能,讓你找到共同話題的小夥伴!多人分享配對心得、聊天交友心情在此,快加入17分享!',
|
||||
image: 'https://s3.hicloud.net.tw/zuvio.public/public/system/images/irs_v4/chicken/shared/webshare.png',
|
||||
link: `${rootUrl}/articles`,
|
||||
item: items,
|
||||
language: 'zh-Hant',
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'zuvio.com.tw': {
|
||||
_name: 'Zuvio',
|
||||
irs: [
|
||||
{
|
||||
title: '校園話題',
|
||||
docs: 'https://docs.rsshub.app/bbs.html#zuvio',
|
||||
source: ['/student5/chickenM/articles/:board', '/student5/chickenM/articles'],
|
||||
target: (params) => `/zuvio/student5${params.board ? `/${params.board}` : ''}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/student5/boards', require('./boards'));
|
||||
router.get('/student5/:board?', require('./student5'));
|
||||
};
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { token, apiUrl, rootUrl, renderDesc, getBoards } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { board = '' } = ctx.params;
|
||||
const title = board ? (await getBoards(ctx.cache.tryGet)).find((i) => i.boardId === board).title : '全部';
|
||||
|
||||
const { data } = await got(`${apiUrl}/article`, {
|
||||
searchParams: {
|
||||
api_token: token,
|
||||
user_id: '0',
|
||||
board_id: board,
|
||||
sort: 'time',
|
||||
page: '1',
|
||||
device: 'web',
|
||||
my_school_opinion: '1',
|
||||
},
|
||||
});
|
||||
|
||||
const items = data.articles.map((item) => ({
|
||||
title: item.title,
|
||||
description: item.abstract,
|
||||
pubDate: timezone(parseDate(item.created_at), +8),
|
||||
link: `${rootUrl}/article/${item.id}`,
|
||||
api: `${apiUrl}/article/${item.id}`,
|
||||
author: `${item.university} ${item.user_name}`,
|
||||
category: item.board_name,
|
||||
}));
|
||||
|
||||
await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data } = await got(item.api, {
|
||||
searchParams: {
|
||||
api_token: token,
|
||||
user_id: '0',
|
||||
device: 'web',
|
||||
ref: '',
|
||||
},
|
||||
});
|
||||
item.description = renderDesc(data);
|
||||
delete item.api;
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Zuvio 校園${title}話題 - 大學生論壇`,
|
||||
description: 'Zuvio 校園話題千種動物頭像交流心得。最萌的匿名論壇,上千種逗趣動物頭像隨你變換,點頭像立即私訊功能,讓你找到共同話題的小夥伴!多人分享配對心得、聊天交友心情在此,快加入17分享!',
|
||||
image: 'https://s3.hicloud.net.tw/zuvio.public/public/system/images/irs_v4/chicken/shared/webshare.png',
|
||||
link: `${rootUrl}/articles`,
|
||||
item: items,
|
||||
language: 'zh-Hant',
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
<img src="{{ section.content }}">
|
||||
<br>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<p>
|
||||
<a href="{{ section.content }}">
|
||||
<img src="{{ section.icon }}">
|
||||
<div>{{ section.title}}</div>
|
||||
<div>{{ section.description}}</div>
|
||||
</a>
|
||||
</p>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
引用自:
|
||||
<a href="{{ ref_article.id }}">
|
||||
<img src="{{ ref_article.user_icon }}">
|
||||
<div>{{ ref_article.university }} {{ ref_article.user_name }} {{ ref_article.board_name }}</div>
|
||||
<div>{{ ref_article.title }}</div>
|
||||
<div>{{ ref_article.abstract }}</div>
|
||||
</a>
|
||||
<hr>
|
||||
|
|
@ -0,0 +1 @@
|
|||
<a href="https://rsshub.app/zuvio/student5/{{ id }}">{{ id }}</a>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
<iframe width="672" height="377" src="https://www.youtube-nocookie.com/embed/{{ section.youtube_id }}" frameborder="0" allowfullscreen></iframe>
|
||||
<br>
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const got = require('@/utils/got');
|
||||
|
||||
const token =
|
||||
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE0OTcyMzI1MjMsInN5c3RlbV9uYW1lIjoiZm9ydW0iLCJ6dXZpb19pZCI6LTk5OSwiZW1haWwiOm51bGwsIm5hbWUiOm51bGwsInVuaXZlcnNpdHlfaWQiOm51bGwsInVuaXZlcnNpdHlfbmFtZSI6bnVsbH0.0KoJiSnyazsJxLCNEnqnuNUdKsJFhBdCn3R2BJpoUtk';
|
||||
const apiUrl = 'https://forum.zuvio.com.tw/api';
|
||||
const rootUrl = 'https://irs.zuvio.com.tw/student5/chickenM';
|
||||
|
||||
const renderDesc = (data) => {
|
||||
let output = '';
|
||||
if (data.ref_article) {
|
||||
output += art(path.join(__dirname, 'templates/ref_article.art'), {
|
||||
ref_article: data.ref_article,
|
||||
});
|
||||
}
|
||||
output += renderSections(data.sections);
|
||||
return output;
|
||||
};
|
||||
|
||||
const renderSections = (sections) => {
|
||||
let output = '';
|
||||
for (const section of sections) {
|
||||
if (section.type === 'text') {
|
||||
output += section.content.replace(/\n/g, '<br>');
|
||||
} else if (section.type === 'img') {
|
||||
output += art(path.join(__dirname, 'templates/img.art'), { section });
|
||||
} else if (section.type === 'youtube') {
|
||||
output += art(path.join(__dirname, 'templates/youtube.art'), { section });
|
||||
} else if (section.type === 'link') {
|
||||
output += art(path.join(__dirname, 'templates/link.art'), { section });
|
||||
}
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
const getBoards = (tryGet) =>
|
||||
tryGet('zuvio:boards', async () => {
|
||||
const { data } = await got(`${apiUrl}/board`, {
|
||||
searchParams: {
|
||||
api_token: token,
|
||||
user_id: '0',
|
||||
},
|
||||
});
|
||||
|
||||
return data.map((item) => ({
|
||||
title: item.name,
|
||||
description: art(path.join(__dirname, 'templates/rss.art'), { id: item.id }),
|
||||
boardId: item.id,
|
||||
link: `${rootUrl}/articles/${item.id}`,
|
||||
}));
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
token,
|
||||
apiUrl,
|
||||
rootUrl,
|
||||
renderDesc,
|
||||
renderSections,
|
||||
getBoards,
|
||||
};
|
||||
Loading…
Reference in New Issue