feat(route): add notefolio 旧版已失效 (#12564)
* ✨ feat: 适配 notefolio 旧版已失效 * 🐞 fix: remove y * 📃 docs: update en docs * 🦄 refactor: remove old notefolio * 📃 docs: update docs * 🦄 refactor: remove old router * ✨ feat: add video * 📃 docs: update en docs * 🦄 refactor: use art-template * 📃 docs: `pick` by default * 📃 docs: update docs
This commit is contained in:
+16
-15
@@ -159,22 +159,23 @@ Behance 用户主页 URL 获取用户名,如 <https://www.behance.net/mishapet
|
||||
|
||||
### Works
|
||||
|
||||
<Route author="nczitzk" example="/notefolio" path="/notefolio/:caty?/:order?/:time?/:query?" :paramsDesc="['分类,见下表,默认为 `all`', '排序,可选 `pick` 指 Notefolio 精选,`newest` 指 最新,`noted` 指 知名,默认为 `pick`', '时间,可选 `all` 指 全部,`day` 指 最近24小时,`week` 指 最近一周,`month` 指 最近一个月,`month3` 指 最近三个月,默认为`all`', '关键词,默认为空']">
|
||||
<Route author="BianTan" example="/notefolio/search/1/pick/all/life" path="/notefolio/search/:category?/:order?/:time?/:query?" :paramsDesc="['分类,见下表,默认为 `all`', '排序,可选 `pick` 指 Notefolio 精选,`published` 指 最新,`like` 指 推荐,默认为 `pick`', '时间,可选 `all` 指 全部,`one-day` 指 最近24小时,`week` 指 最近一周,`month` 指 最近一个月,`three-month` 指 最近三个月,默认为`all`', '关键词,默认为空']">
|
||||
|
||||
| 分类 | 韩文分类名 | 中文分类名 |
|
||||
| ---- | --------------- | --------------- |
|
||||
| all | 전체 | 全部 |
|
||||
| A7 | 공예 | 工艺品 |
|
||||
| J7 | 그래픽 디자인 | 平面设计 |
|
||||
| B7 | 디지털 아트 | 数字艺术 |
|
||||
| C7 | 영상/모션그래픽 | 视频 / 图形动画 |
|
||||
| D7 | 브랜딩/편집 | 品牌创建 / 编辑 |
|
||||
| E7 | 산업 디자인 | 工业设计 |
|
||||
| F7 | UI/UX | UI/UX |
|
||||
| G7 | 일러스트레이션 | 插画 |
|
||||
| K7 | 타이포그래피 | 字体 |
|
||||
| H7 | 파인아트 | 纯艺术 |
|
||||
| I7 | 포토그래피 | 摄影 |
|
||||
| 分类 | 韩文分类名 | 中文分类名 |
|
||||
| ---- | ---------------- | --------------- |
|
||||
| all | 전체 | 全部 |
|
||||
| 1 | 영상/모션그래픽 | 视频 / 动态图像 |
|
||||
| 2 | 그래픽 디자인 | 平面设计 |
|
||||
| 3 | 브랜딩/편집 | 品牌创建 / 编辑 |
|
||||
| 4 | UI/UX | UI/UX |
|
||||
| 5 | 일러스트레이션 | 插画 |
|
||||
| 6 | 디지털 아트 | 数字艺术 |
|
||||
| 7 | 캐릭터 디자인 | 角色设计 |
|
||||
| 8 | 품/패키지 디자인 | 产品 / 包装设计 |
|
||||
| 9 | 포토그래피 | 摄影 |
|
||||
| 10 | 타이포그래피 | 字体设计 |
|
||||
| 11 | 공예 | 工艺品 |
|
||||
| 12 | 파인아트 | 纯艺术 |
|
||||
|
||||
</Route>
|
||||
|
||||
|
||||
+15
-14
@@ -105,22 +105,23 @@ Default is under 'https://www.methodstudios.com/en/features'.
|
||||
|
||||
### Works
|
||||
|
||||
<RouteEn author="nczitzk" example="/notefolio" path="/notefolio/:caty?/:order?/:time?/:query?" :paramsDesc="['Category, see below, `all` by default', 'Order, `pick` as Notefolio Pick, `newest` as Newest, `noted` as Noted, `pick` by default', 'Time, `all` as All the time, `day` as Latest 24 hours, `week` as Latest week, `month` as Latest month, `month3` as Latest 3 months, `all` by default', 'Keyword, empty by default']">
|
||||
<RouteEn author="BianTan" example="/notefolio/search/1/pick/all/life" path="/notefolio/search/:category?/:order?/:time?/:query?" :paramsDesc="['Category, see below, `all` by default', 'Order, `pick` as Notefolio Pick, `published` as Newest, `like` as like, `pick` by default', 'Time, `all` as All the time, `one-day` as Latest 24 hours, `week` as Latest week, `month` as Latest month, `three-month` as Latest 3 months, `all` by default', 'Keyword, empty by default']">
|
||||
|
||||
| Category | Name in Korean | Name in English |
|
||||
| -------- | -------------- | --------------- |
|
||||
| all | 전체 | All |
|
||||
| A7 | 공예 | Crafts |
|
||||
| J7 | 그래픽 디자인 | Graphic Design |
|
||||
| B7 | 디지털 아트 | Digital Art |
|
||||
| C7 | 영상/모션그래픽 | Video / Motion Graphics |
|
||||
| D7 | 브랜딩/편집 | Branding / Editing |
|
||||
| E7 | 산업 디자인 | Industrial Design |
|
||||
| F7 | UI/UX | UI/UX |
|
||||
| G7 | 일러스트레이션 | Illustration |
|
||||
| K7 | 타이포그래피 | Typography |
|
||||
| H7 | 파인아트 | Fine Art |
|
||||
| I7 | 포토그래피 | Photography |
|
||||
| ---- | --------------- | --------------- |
|
||||
| all | 전체 | All |
|
||||
| 1 | 영상/모션그래픽 | Video / Motion Graphics |
|
||||
| 2 | 그래픽 디자인 | Graphic Design |
|
||||
| 3 | 브랜딩/편집 | Branding / Editing |
|
||||
| 4 | UI/UX | UI/UX |
|
||||
| 5 | 일러스트레이션 | Illustration |
|
||||
| 6 | 디지털 아트 | Digital Art |
|
||||
| 7 | 캐릭터 디자인 | Character Design |
|
||||
| 8 | 제품/패키지 디자인 | Product Package Design |
|
||||
| 9 | 포토그래피 | Photography |
|
||||
| 10 | 타이포그래피 | Typography |
|
||||
| 11 | 공예 | Crafts |
|
||||
| 12 | 파인아트 | Fine Art|
|
||||
|
||||
</RouteEn>
|
||||
|
||||
|
||||
+1
-1
@@ -3232,7 +3232,7 @@ router.get('/mamibuy/:caty?/:age?/:sort?', lazyloadRouteHandler('./routes/mamibu
|
||||
router.get('/mercari/:type/:id', lazyloadRouteHandler('./routes/mercari/index'));
|
||||
|
||||
// notefolio
|
||||
router.get('/notefolio/:caty?/:order?/:time?/:query?', lazyloadRouteHandler('./routes/notefolio/index'));
|
||||
// router.get('/notefolio/:caty?/:order?/:time?/:query?', lazyloadRouteHandler('./routes/notefolio/index'));
|
||||
|
||||
// JavDB
|
||||
// router.get('/javdb/home/:category?/:sort?/:filter?', lazyloadRouteHandler('./routes/javdb'));
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const caty = ctx.params.caty || 'all';
|
||||
const order = ctx.params.order || 'pick';
|
||||
const time = ctx.params.time || 'all';
|
||||
const query = ctx.params.query || '';
|
||||
|
||||
const rootUrl = `https://notefolio.net/?work_categories=${caty === 'all' ? '' : caty}&order=${order}&from=${time}&q=${query}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: rootUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
$('div.mobile-category-order').remove();
|
||||
|
||||
const list = $('div.work-list div.work-list-item')
|
||||
.slice(0, 5)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a.go-to-work-info').eq(0);
|
||||
return {
|
||||
title: item.find('div.title').text(),
|
||||
link: `https://notefolio.net${a.attr('href')}`,
|
||||
author: item.find('span.go-profile-area').text(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = '<ul>';
|
||||
|
||||
content('li.block-image a img').each((_, i) => {
|
||||
i = content(i);
|
||||
item.description += `<li><img src="${i.attr('src')}"></li>`;
|
||||
});
|
||||
|
||||
content('li.block-video iframe').each((_, i) => {
|
||||
i = content(i);
|
||||
item.description += `<li><iframe src="${i.attr('src')}"></li>`;
|
||||
});
|
||||
|
||||
item.description += `<li>${content('li.block-text').html()}</li></ul>`;
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: rootUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/search/:category?/:order?/:time?/:query?': ['BianTan'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'notefolio.net': {
|
||||
_name: 'Notefolio',
|
||||
'.': [
|
||||
{
|
||||
title: 'Search',
|
||||
docs: 'https://docs.rsshub.app/design.html#notefolio',
|
||||
source: ['/search'],
|
||||
target: '/notefolio/search/:category?/:order?/:time?/:query?',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/search/:category?/:order?/:time?/:query?', require('./search'));
|
||||
};
|
||||
@@ -0,0 +1,145 @@
|
||||
// 导入所需模组
|
||||
const got = require('@/utils/got'); // 自订的 got
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const dayjs = require('dayjs');
|
||||
const path = require('path');
|
||||
const { art } = require('@/utils/render');
|
||||
|
||||
// 分类
|
||||
const categoryMap = [
|
||||
{
|
||||
keywords: 'video-motiongraphic',
|
||||
category: 'portfolio.category.trevorbenitez',
|
||||
},
|
||||
{
|
||||
keywords: 'graphic-design',
|
||||
category: 'portfolio.category.lynnrogers',
|
||||
},
|
||||
{
|
||||
keywords: 'branding-editorial',
|
||||
category: 'portfolio.category.katiethompson',
|
||||
},
|
||||
{
|
||||
keywords: 'UI-UX',
|
||||
category: 'portfolio.category.brittneyhall',
|
||||
},
|
||||
{
|
||||
keywords: 'illustration',
|
||||
category: 'portfolio.category.margaretbullock',
|
||||
},
|
||||
{
|
||||
keywords: 'digital-art',
|
||||
category: 'portfolio.category.amandahoward',
|
||||
},
|
||||
{
|
||||
keywords: 'character-design',
|
||||
category: 'portfolio.category.rachelsharp',
|
||||
},
|
||||
{
|
||||
keywords: 'product-package-design',
|
||||
category: 'portfolio.category.vanessacohen',
|
||||
},
|
||||
{
|
||||
keywords: 'photography',
|
||||
category: 'portfolio.category.johnmurray',
|
||||
},
|
||||
{
|
||||
keywords: 'typography',
|
||||
category: 'portfolio.category.timothysmith',
|
||||
},
|
||||
{
|
||||
keywords: 'crafts',
|
||||
category: 'portfolio.category.jessicaking',
|
||||
},
|
||||
{
|
||||
keywords: 'fine-art',
|
||||
category: 'portfolio.category.johnmedina',
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* @param category 分类
|
||||
* @param order 排序 [like, pick, published]
|
||||
* @param time 时间范围 ['one-day', 'week', 'month', 'three-month']
|
||||
* @param query 搜索词
|
||||
* @query limit 分页,默认20
|
||||
*/
|
||||
module.exports = async (ctx) => {
|
||||
// 分类、排序、时间范围、搜索词
|
||||
const { category = 'all', order = 'pick', time = 'all', query = '' } = ctx.params;
|
||||
// 分页
|
||||
const { limit } = ctx.query;
|
||||
|
||||
// 请求链接
|
||||
let searchUrl = `https://api.stunning.kr/api/v1/dantats/portfolio?state=Public&limit=${limit ? parseInt(limit, 10) : 20}&search=${query}&orderBy=${order}`;
|
||||
// 分类
|
||||
const index = (Number(category) || 0) - 1;
|
||||
if (index >= 0 && categoryMap[index]) {
|
||||
searchUrl += `&category=${categoryMap[index].category}`;
|
||||
}
|
||||
// 时间范围
|
||||
if (time !== 'all' && ['one-day', 'week', 'month', 'three-month'].includes(time)) {
|
||||
let startTime = '';
|
||||
const endTime = dayjs().endOf('d').format('YYYY-MM-DDTHH:mm:ss.SSS');
|
||||
|
||||
// 过去24小时-day 最近一周-week 最近一个月-month 最近三个月three-month
|
||||
switch (time) {
|
||||
case 'one-day': {
|
||||
startTime = dayjs().subtract(1, 'd').format('YYYY-MM-DDTHH:mm:ss.SSS');
|
||||
break;
|
||||
}
|
||||
case 'week': {
|
||||
startTime = dayjs().subtract(7, 'd').startOf('d').format('YYYY-MM-DDTHH:mm:ss.SSS');
|
||||
break;
|
||||
}
|
||||
case 'month': {
|
||||
startTime = dayjs().subtract(30, 'd').startOf('d').format('YYYY-MM-DDTHH:mm:ss.SSS');
|
||||
break;
|
||||
}
|
||||
case 'three-month': {
|
||||
startTime = dayjs().subtract(90, 'd').startOf('d').format('YYYY-MM-DDTHH:mm:ss.SSS');
|
||||
break;
|
||||
}
|
||||
}
|
||||
searchUrl += `&publishedAt=${startTime}Z&publishedAt=${endTime}Z`;
|
||||
}
|
||||
|
||||
// 发送 HTTP GET 请求到 API 并解构返回的数据对象
|
||||
const { data } = await got(searchUrl, {
|
||||
headers: {
|
||||
Origin: 'https://notefolio.net',
|
||||
},
|
||||
});
|
||||
|
||||
// 从 API 响应中提取相关数据
|
||||
const items =
|
||||
data?.resultData.map((item) => {
|
||||
const { id, title, user, createdAt, categories = [], contents = [] } = item;
|
||||
|
||||
const description = contents.map((item) => art(path.join(__dirname, './templates/search.art'), { item })).join(' ');
|
||||
|
||||
return {
|
||||
// 文章标题
|
||||
title,
|
||||
// 文章链接
|
||||
link: `https://notefolio.net/${user.url}/${id}`,
|
||||
// 文章正文
|
||||
description,
|
||||
// 文章发布日期
|
||||
pubDate: parseDate(createdAt),
|
||||
// 如果有的话,文章作者
|
||||
author: user.nick,
|
||||
// 如果有的话,文章分类
|
||||
category: categories.map((label) => label.replace('portfolio.category.', '')),
|
||||
};
|
||||
}) || [];
|
||||
|
||||
ctx.state.data = {
|
||||
// 源标题
|
||||
title: `${category}/${order}/${time}/${query} search`,
|
||||
// 源链接
|
||||
// link: '',
|
||||
// 源文章
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
{{ if item.type === 'Image' }}
|
||||
{{each item.files}}
|
||||
<img src="{{$value.url}}" alt style="max-width: 100%; height: auto;"><br>
|
||||
{{/each}}
|
||||
{{ else if item.type === 'Text' }}
|
||||
{{@ item.content }}<br>
|
||||
{{ else if type === 'Video' }}
|
||||
<iframe src="{{ item.url }}"></iframe><br>
|
||||
{{ /if }}
|
||||
Reference in New Issue
Block a user