Skip to content

Commit

Permalink
Merge pull request #50 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Sep 7, 2023
2 parents fad9788 + 30cfd44 commit bafc4a0
Show file tree
Hide file tree
Showing 14 changed files with 226 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ RSSHub delivers millions of contents aggregated from all kinds of sources, our v

RSSHub can be used with browser extension [RSSHub Radar](https://github.com/DIYgod/RSSHub-Radar) and mobile auxiliary app [RSSBud](https://github.com/Cay-Zhang/RSSBud) (iOS) and [RSSAid](https://github.com/LeetaoGoooo/RSSAid) (Android)

[English docs](https://docs.rsshub.app/en) | [Telegram Group](https://t.me/rsshub) | [Telegram Channel](https://t.me/awesomeRSSHub)
[English docs](https://docs.rsshub.app) | [Telegram Group](https://t.me/rsshub) | [Telegram Channel](https://t.me/awesomeRSSHub)

[中文文档](https://docs.rsshub.app) | [Telegram 群](https://t.me/rsshub) | [Telegram 频道](https://t.me/awesomeRSSHub)
[中文文档](https://docs.rsshub.app/zh/) | [Telegram 群](https://t.me/rsshub) | [Telegram 频道](https://t.me/awesomeRSSHub)

## Special Thanks

Expand Down
28 changes: 28 additions & 0 deletions lib/v2/luxiangdong/archive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const { data } = await got(`https://www.luxiangdong.com/content.json?t=${Date.now()}`);

const items = data.posts.map((item) => ({
// 文章标题
title: item.title,
// 文章链接
link: item.permalink,
// 文章发布日期
pubDate: parseDate(item.date),
// 如果有的话,文章作者
author: data.meta.author,
// 如果有的话,文章分类
category: item.tags.map((tag) => tag.name),
}));

ctx.state.data = {
// 源标题
title: '土猛的员外',
// 源链接
link: 'https://www.luxiangdong.com/',
// 源文章
item: items,
};
};
3 changes: 3 additions & 0 deletions lib/v2/luxiangdong/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/archive': ['Levix'],
};
13 changes: 13 additions & 0 deletions lib/v2/luxiangdong/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'luxiangdong.com': {
_name: '土猛的员外',
'.': [
{
title: '文章',
docs: 'https://docs.rsshub.app/routes/blog#luxiangdong',
source: ['/'],
target: '/luxiangdong/archive',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/luxiangdong/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/archive', require('./archive'));
};
36 changes: 36 additions & 0 deletions lib/v2/tfc-taiwan/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { baseUrl, parseList, parseItems } = require('./utils');

module.exports = async (ctx) => {
const requestPath = ctx.request.path;
const isTopic = requestPath.startsWith('/topic/');
let link = baseUrl;

if (isTopic) {
link += `/topic/${ctx.params.id}`;
} else if (requestPath === '/') {
link += `/articles/report`;
} else {
link += `/articles${requestPath}`;
}

const { data: response } = await got(link);
const $ = cheerio.load(response);

const list = $(`${isTopic ? '.view-grouping' : '.pane-clone-of-article'} .views-row-inner`)
.toArray()
.map((item) => parseList($(item)));

const items = await parseItems(list, ctx.cache.tryGet);

ctx.state.data = {
title: $('head title').text(),
description: $('head meta[name="description"]').attr('content'),
image: $('head meta[property="og:image"]').attr('content'),
logo: $('head link[rel="shortcut icon"]').attr('href'),
icon: $('head link[rel="shortcut icon"]').attr('href'),
link,
item: items,
};
};
10 changes: 10 additions & 0 deletions lib/v2/tfc-taiwan/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
'': ['TonyRL'],
'/': ['TonyRL'],
'/:type?': ['TonyRL'], // /info and /report
'/:type/:id+': ['TonyRL'], // /category/:id+ and /topic/:id
'/category/:id+': ['TonyRL'],
'/info': ['TonyRL'],
'/report': ['TonyRL'],
'/topic/:id': ['TonyRL'],
};
31 changes: 31 additions & 0 deletions lib/v2/tfc-taiwan/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
'tfc-taiwan.org.tw': {
_name: '台灣事實查核中心',
'.': [
{
title: '專題',
docs: 'https://docs.rsshub.app/routes/other#tai-wan-shi-shi-cha-he-zhong-xin',
source: '/articles/category/:id+',
target: '/tfc-taiwan/category/:id',
},
{
title: '最新相關資訊',
docs: 'https://docs.rsshub.app/routes/other#tai-wan-shi-shi-cha-he-zhong-xin',
source: ['/articles/info', '/'],
target: '/tfc-taiwan/info',
},
{
title: '最新查核報告',
docs: 'https://docs.rsshub.app/routes/other#tai-wan-shi-shi-cha-he-zhong-xin',
source: ['/articles/report', '/'],
target: '/tfc-taiwan/report',
},
{
title: '重點專區',
docs: 'https://docs.rsshub.app/routes/other#tai-wan-shi-shi-cha-he-zhong-xin',
source: '/topic/:id',
target: '/tfc-taiwan/topic/:id',
},
],
},
};
7 changes: 7 additions & 0 deletions lib/v2/tfc-taiwan/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = (router) => {
router.get('/', require('./index'));
router.get('/category/:id+', require('./index'));
router.get('/info', require('./index'));
router.get('/report', require('./index'));
router.get('/topic/:id', require('./index'));
};
7 changes: 7 additions & 0 deletions lib/v2/tfc-taiwan/templates/article.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{ if headerImage }}
<img src="{{ headerImage }}"><br>
{{ /if }}

{{ if content }}
{{@ content }}
{{ /if }}
56 changes: 56 additions & 0 deletions lib/v2/tfc-taiwan/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { join } = require('path');
const { art } = require('@/utils/render');
const asyncPool = require('tiny-async-pool');
const { parseDate } = require('@/utils/parse-date');

const asyncPoolAll = async (...args) => {
const results = [];
for await (const result of asyncPool(...args)) {
results.push(result);
}
return results;
};

const baseUrl = 'https://tfc-taiwan.org.tw';

const parseList = (item) => {
const a = item.find('.entity-list-title a');
return {
title: a.text(),
description: item.find('.entity-list-body').text(),
link: new URL(a.attr('href'), baseUrl).href,
pubDate: item.find('.post-date').length ? parseDate(item.find('.post-date').text(), 'YYYY-MM-DD') : undefined,
image: item.find('.entity-list-img img').attr('src').split('?')[0],
};
};

const parseItems = (list, tryGet) =>
asyncPoolAll(10, list, (item) =>
tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = cheerio.load(response);

$('.field-name-field-addthis, #fb-root, .fb-comments, .likecoin-embed, style[type="text/css"]').remove();

item.description = art(join(__dirname, 'templates/article.art'), {
headerImage: item.image,
content: $('#block-system-main .node-content').html(),
});

item.pubDate = $('meta[property="article:published_time"]').attr('content');
item.updated = $('meta[property="article:modified_time"]').attr('content');
item.category = $('.node-tags .field-item')
.toArray()
.map((item) => $(item).text());

return item;
})
);

module.exports = {
baseUrl,
parseList,
parseItems,
};
2 changes: 1 addition & 1 deletion test/middleware/onerror.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('httperror', () => {
expect(response.text).toMatch(
/Response code 404 \(Not Found\): target website might be blocking our access, you can <a href="https:\/\/docs\.rsshub\.app\/install\/">host your own RSSHub instance<\/a> for a better usability\./
);
}, 10000);
}, 20000);
});

describe('RequestInProgressError', () => {
Expand Down
9 changes: 7 additions & 2 deletions website/docs/routes/blog.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ username 为博主用户名,而非`xxx.hashnode.dev`中`xxx`所代表的 blog

<Route author="ImSingee" example="/medium/list/imsingee/f2d8d48096a9" path="/medium/list/:user/:catalogId" paramsDesc={['Username', 'List ID']}>

The List ID is the last part of the URL after `-`, for example, the username in "https://medium.com/@imsingee/list/collection-7e67004f23f9" is `imsingee`, and the ID is `7e67004f23f9`.
The List ID is the last part of the URL after `-`, for example, the username in <https://medium.com/@imsingee/list/collection-7e67004f23f9> is `imsingee`, and the ID is `7e67004f23f9`.

:::caution

Expand Down Expand Up @@ -475,6 +475,12 @@ Limit the number of entries to be retrieved by adding `?limit=x` to the end of t

<Route author="7Wate a180285" example="/foreverblog/feeds" path="/foreverblog/feeds" radar="1" rssbud="1" />

## 土猛的员外 {#tu-meng-de-yuan-wai}

### 文章 {#tu-meng-de-yuan-wai-wen-zhang}

<Route author="Levix" example="/luxiangdong/archive" path="/luxiangdong/archive"/>

## 王五四文集 {#wang-wu-si-wen-ji}

### 文章 {#wang-wu-si-wen-ji-wen-zhang}
Expand Down Expand Up @@ -532,4 +538,3 @@ Limit the number of entries to be retrieved by adding `?limit=x` to the end of t
### TOP 20 {#zhu-bai-top-20}

<Route author="nczitzk" example="/zhubai/top20" path="/zhubai/top20"/>

22 changes: 22 additions & 0 deletions website/docs/routes/other.md
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,28 @@ Refer to [the list of supported currencies](https://wise.com/tools/exchange-rate

<Route author="xyqfer" example="/sogou/doodles" path="/sogou/doodles"/>

## 台灣事實查核中心 {#tai-wan-shi-shi-cha-he-zhong-xin}

### 最新相關資訊 / 最新查核報告 {#tai-wan-shi-shi-cha-he-zhong-xin-zui-xin-xiang-guan-zi-xun-%2F-zui-xin-cha-he-bao-gao}

<Route author="TonyRL" example="/tfc-taiwan" path="/tfc-taiwan/:type?" paramsDesc={['分類,見下表,預設為 `report`']} radar="1" rssbud="1">

| 最新相關資訊 | 最新查核報告 |
| ---------- | ---------- |
| info | report |

</Route>

### 專題 / 重點專區 {#tai-wan-shi-shi-cha-he-zhong-xin-zhuan-ti-%2F-zhong-dian-zhuan-qu}

<Route author="TonyRL" example="/tfc-taiwan" path="/tfc-taiwan/:type/:id+" paramsDesc={['專題 / 重點專區,見下表', '專題 / 重點專區 ID']} radar="1" rssbud="1">

| 專題 | 重點專區 |
| -------- | ------- |
| category | topic |

</Route>

## 腾讯吐个槽 {#teng-xun-tu-ge-cao}

### 吐槽新帖 {#teng-xun-tu-ge-cao-tu-cao-xin-tie}
Expand Down

0 comments on commit bafc4a0

Please sign in to comment.