feat(route): add Eagle's blog and refactor to V2 (#9546)

* feat(route): add Eagle's blog and refactor to V2

* fix: remove deprecated eagle radar rules

* fix: changelog date and guid

* fix(route): add language option
This commit is contained in:
Fatpandac
2022-04-17 21:24:17 +08:00
committed by GitHub
parent d7d6dc3022
commit cff988ad9f
10 changed files with 178 additions and 35 deletions
-6
View File
@@ -1053,12 +1053,6 @@
},
],
},
'eagle.cool': {
_name: 'Eagle',
cn: [{ title: '更新日志', docs: 'https://docs.rsshub.app/program-update.html#eagle', source: '/changelog', target: '/eagle/changelog/cn' }],
tw: [{ title: '更新日誌', docs: 'https://docs.rsshub.app/program-update.html#eagle', source: '/changelog', target: '/eagle/changelog/tw' }],
en: [{ title: 'Release Notes', docs: 'https://docs.rsshub.app/program-update.html#eagle', source: '/changelog', target: '/eagle/changelog/en' }],
},
'furaffinity.net': {
_name: 'Fur Affinity',
www: [
+12
View File
@@ -58,6 +58,18 @@ Behance 用户主页 URL 获取用户名,如 <https://www.behance.net/mishapet
<Route author="DIYgod" example="/dribbble/keyword/player" path="/dribbble/keyword/:keyword" :paramsDesc="['想要订阅的关键词']"/>
## Eagle
### 博客
<Route author="Fatpandac" example="/eagle/blog" path="/eagle/blog/:cate?/:language?" :paramsDesc="['分类,默认为全部,见下表', '语言,`cn``tw``en` 默认为 `cn`']" radar="1" rsshub="1">
| 全部 | 设计资源 | 设计技巧 | 最新消息 |
| --- | ---------------- | ------------ | ------------ |
| all | design-resources | learn-design | inside-eagle |
</Route>
## Google
### Google Fonts
+6
View File
@@ -58,6 +58,12 @@ Behance user's profile URL, like <https://www.behance.net/mishapetrick> the user
<RouteEn path="/dribbble/keyword/:keyword" example="/dribbble/keyword/player" :paramsDesc="['desired keyword']" />
## Eagle
### Blog
<RouteEn author="Fatpandac" example="/eagle/blog/en" path="/eagle/blog/:cate?/:language?" :paramsDesc="['Category, get by URL, `all` by default', 'Language, `cn`, `tw`, `en`, `en` by default']" radar="1" rsshub="1"/>
## Google
### Google Fonts
-27
View File
@@ -2226,33 +2226,6 @@ module.exports = {
},
],
},
'eagle.cool': {
_name: 'Eagle',
cn: [
{
title: '更新日志',
docs: 'https://docs.rsshub.app/program-update.html#eagle',
source: '/changelog',
target: '/eagle/changelog/cn',
},
],
tw: [
{
title: '更新日誌',
docs: 'https://docs.rsshub.app/program-update.html#eagle',
source: '/changelog',
target: '/eagle/changelog/tw',
},
],
en: [
{
title: 'Release Notes',
docs: 'https://docs.rsshub.app/program-update.html#eagle',
source: '/changelog',
target: '/eagle/changelog/en',
},
],
},
'furaffinity.net': {
_name: 'Fur Affinity',
www: [
+1 -1
View File
@@ -3878,7 +3878,7 @@ router.get('/ccg/:category?', lazyloadRouteHandler('./routes/ccg/index'));
// router.get('/gf-cn/news/:category?', lazyloadRouteHandler('./routes/gf-cn/news'));
// Eagle
router.get('/eagle/changelog/:language?', lazyloadRouteHandler('./routes/eagle/changelog'));
// router.get('/eagle/changelog/:language?', lazyloadRouteHandler('./routes/eagle/changelog'));
// ezone.hk
// router.get('/ezone/:category?', lazyloadRouteHandler('./routes/ezone/index'));
+47
View File
@@ -0,0 +1,47 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const cateList = ['all', 'design-resources', 'learn-design', 'inside-eagle'];
module.exports = async (ctx) => {
let cate = ctx.params.cate ?? 'all';
let language = ctx.params.language ?? 'cn';
if (cateList.indexOf(cate) === -1) {
language = cate;
cate = 'all';
}
const host = `https://${language}.eagle.cool`;
const url = `${host}/blog/${cate === 'all' ? '' : cate}`;
const response = await got(url);
const $ = cheerio.load(response.data);
const title = $('div.categories-list > div > div > div > ul > li.active').text();
const list = $('div.post-item')
.map((_index, item) => ({
title: $(item).find('div.title').text(),
link: new URL($(item).find('a').attr('href'), host).href,
pubDate: parseDate($(item).find('div.metas > a > span').text().replace('・', '')),
}))
.get();
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = cheerio.load(detailResponse.data);
item.description = content('div.post-html').html();
return item;
})
)
);
ctx.state.data = {
title: `eagle - ${title}`,
link: url,
item: items,
};
};
@@ -1,5 +1,6 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
let language = ctx.params.language;
@@ -67,7 +68,8 @@ module.exports = async (ctx) => {
title: item.find('.ver').text(),
description: item.find('.logs').html(),
link: `https://${language}.eagle.cool/changelog`,
pubDate: new Date(getDate()).toUTCString(),
pubDate: parseDate(getDate()),
guid: item.find('.ver').text(),
};
})
.get(),
+4
View File
@@ -0,0 +1,4 @@
module.exports = {
'/blog/:cate?/:language?': ['Fatpandac'],
'/changelog/:language?': ['tigercubden'],
};
+101
View File
@@ -0,0 +1,101 @@
module.exports = {
'eagle.cool': {
_name: 'Eagle',
cn: [
{
title: '更新日志',
docs: 'https://docs.rsshub.app/program-update.html#eagle',
source: '/changelog',
target: '/eagle/changelog/cn',
},
{
title: '全部',
docs: 'https://docs.rsshub.app/design.html#eagle',
source: ['/blog'],
target: '/eagle/blog',
},
{
title: '设计资源',
docs: 'https://docs.rsshub.app/design.html#eagle',
source: ['/blog/design-resources'],
target: '/eagle/blog/design-resources',
},
{
title: '设计技巧',
docs: 'https://docs.rsshub.app/design.html#eagle',
source: ['/blog/learn-design'],
target: '/eagle/blog/learn-design',
},
{
title: '最新消息',
docs: 'https://docs.rsshub.app/design.html#eagle',
source: ['/blog/inside-eagle'],
target: '/eagle/blog/inside-eagle',
},
],
tw: [
{
title: '更新日誌',
docs: 'https://docs.rsshub.app/program-update.html#eagle',
source: '/changelog',
target: '/eagle/changelog/tw',
},
{
title: '全部',
docs: 'https://docs.rsshub.app/design.html#eagle',
source: ['/blog'],
target: '/eagle/blog/tw',
},
{
title: '設計資源',
docs: 'https://docs.rsshub.app/design.html#eagle',
source: ['/blog/design-resources'],
target: '/eagle/blog/design-resources/tw',
},
{
title: '設計技巧',
docs: 'https://docs.rsshub.app/design.html#eagle',
source: ['/blog/learn-design'],
target: '/eagle/blog/learn-design/tw',
},
{
title: '最新消息',
docs: 'https://docs.rsshub.app/design.html#eagle',
source: ['/blog/inside-eagle'],
target: '/eagle/blog/inside-eagle/tw',
},
],
en: [
{
title: 'Release Notes',
docs: 'https://docs.rsshub.app/program-update.html#eagle',
source: '/changelog',
target: '/eagle/changelog/en',
},
{
title: 'All',
docs: 'https://docs.rsshub.app/design.html#eagle',
source: ['/blog'],
target: '/eagle/blog/en',
},
{
title: 'Design Resources',
docs: 'https://docs.rsshub.app/design.html#eagle',
source: ['/blog/design-resources'],
target: '/eagle/blog/design-resources/en',
},
{
title: 'Learn Design',
docs: 'https://docs.rsshub.app/design.html#eagle',
source: ['/blog/learn-design'],
target: '/eagle/blog/learn-design/en',
},
{
title: 'Inside Eagle',
docs: 'https://docs.rsshub.app/design.html#eagle',
source: ['/blog/inside-eagle'],
target: '/eagle/blog/inside-eagle/en',
},
],
},
};
+4
View File
@@ -0,0 +1,4 @@
module.exports = function (router) {
router.get('/blog/:cate?/:language?', require('./blog'));
router.get('/changelog/:language?', require('./changelog'));
};