commit
7af5d3d9f1
|
|
@ -34,6 +34,16 @@ pageClass: routes
|
|||
|
||||
<RouteEn author="maple3142" example="/facebook/page/SonetPCR" path="/facebook/page/:id" :paramsDesc="['page id']" anticrawler="1"/>
|
||||
|
||||
## Gab
|
||||
|
||||
### User's Posts
|
||||
|
||||
<RouteEn author="zphw" example="/gab/user/realdonaldtrump" path="/gab/user/:username" :paramsDesc="['Username']" />
|
||||
|
||||
### Popular Posts
|
||||
|
||||
<RouteEn author="zphw" example="/gab/popular/hot" path="/gab/popular/:sort?" :paramsDesc="['Sort by, `hot` to be Hot Posts and `top` to be Top Posts. Default: hot']" />
|
||||
|
||||
## Instagram
|
||||
|
||||
::: warning
|
||||
|
|
|
|||
|
|
@ -320,6 +320,16 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性
|
|||
|
||||
<Route author="maple3142" example="/facebook/page/SonetPCR" path="/facebook/page/:id" :paramsDesc="['專頁 id']" anticrawler="1"/>
|
||||
|
||||
## Gab
|
||||
|
||||
### 用戶時間線
|
||||
|
||||
<Route author="zphw" example="/gab/user/realdonaldtrump" path="/gab/user/:username" :paramsDesc="['用戶名']" />
|
||||
|
||||
### 熱門
|
||||
|
||||
<Route author="zphw" example="/gab/popular/hot" path="/gab/popular/:sort?" :paramsDesc="['排序方式, `hot` 為 Hot Posts, `top` 為 Top Posts。默認為 hot']" />
|
||||
|
||||
## iCity
|
||||
|
||||
### 用户动态
|
||||
|
|
|
|||
|
|
@ -3800,6 +3800,7 @@ router.get('/semiconductors/latest-news', require('./routes/semiconductors/lates
|
|||
|
||||
// VOA News
|
||||
router.get('/voa/day-photos', require('./routes/voa/day-photos'));
|
||||
|
||||
// Voice of America
|
||||
router.get('/voa/:language/:channel?', require('./routes/voa/index'));
|
||||
|
||||
|
|
@ -3861,4 +3862,8 @@ router.get('/booth.pm/shop/:subdomain', require('./routes/booth-pm/shop'));
|
|||
// Minecraft feed the beast
|
||||
router.get('/feed-the-beast/modpack/:modpackEntry', require('./routes/feed-the-beast/modpack'));
|
||||
|
||||
// Gab
|
||||
router.get('/gab/user/:username', require('./routes/gab/user'));
|
||||
router.get('/gab/popular/:sort?', require('./routes/gab/explore'));
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const sort = ctx.params.sort || 'hot';
|
||||
|
||||
let baseURL = 'https://gab.com/api/v1/timelines/explore?page=1&sort_by=';
|
||||
baseURL += sort === 'hot' ? 'hot' : 'top_today';
|
||||
|
||||
const response = await got.get(baseURL);
|
||||
|
||||
const result = await Promise.all(
|
||||
response.data.map((item) => {
|
||||
const media = item.media_attachments.map((item) => `<img src='${item.url}'>`).join('<br>');
|
||||
const $ = cheerio.load(item.content);
|
||||
|
||||
return {
|
||||
title: $.text() || 'Untitled',
|
||||
description: item.content + (media && '<br>' + media),
|
||||
link: item.url || baseURL,
|
||||
pubDate: new Date(item.created_at).toISOString(),
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Gab - Popular posts`,
|
||||
link: baseURL,
|
||||
item: result,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const username = ctx.params.username;
|
||||
|
||||
const response = await got.get('https://gab.com/api/v1/account_by_username/' + username);
|
||||
const id = response.data.id;
|
||||
const gabs = await got.get(`https://gab.com/api/v1/accounts/${id}/statuses?exclude_replies=true`);
|
||||
|
||||
const result = await Promise.all(
|
||||
gabs.data
|
||||
.filter((item) => !item.reblog)
|
||||
.map((item) => {
|
||||
const media = item.media_attachments.map((item) => `<img src='${item.url}'>`).join('<br>');
|
||||
const $ = cheerio.load(item.content);
|
||||
|
||||
return {
|
||||
title: $.text() || 'Untitled',
|
||||
description: item.content + (media && '<br>' + media),
|
||||
link: item.url || `https://gab.com/${username}`,
|
||||
pubDate: new Date(item.created_at).toISOString(),
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Gab - ${username}`,
|
||||
link: `https://gab.com/${username}`,
|
||||
item: result,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue