feat(route): add 一亩三分地分区标签 (#12249)

* feat(route): add 一亩三分地分区标签

* fix: blog

* fix: offer

---------
This commit is contained in:
Ethan Shen
2023-04-07 05:22:02 +08:00
committed by GitHub
parent 14da384c66
commit e14eb410f1
18 changed files with 435 additions and 344 deletions
+71 -26
View File
@@ -1073,12 +1073,77 @@ pageClass: routes
### 帖子
<Route author="NavePnow DIYgod" example="/1point3acres/post/hot" path="/1point3acres/post/:category" :paramsDesc="['分类 category, 见下表']"/>
<Route author="NavePnow DIYgod nczitzk" example="/1point3acres/thread/hot" path="/1point3acres/thread/:type?/:order?" :paramsDesc="['帖子分类, 见下表,默认为 hot,即热门帖子', '排序方式,见下表,默认为空,即最新回复']">
分类
| 热门帖子 | 最新帖子 |
| -------- | -------- |
| hot | new |
排序方式
| 最新回复 | 最新发布 |
| -------- | -------- |
| | post |
</Route>
### 分区
<Route author="nczitzk" example="/1point3acres/section/345" path="/1point3acres/section/:id?/:type?/:order?" :paramsDesc="['分区 id,见下表,默认为全部', '帖子分类, 见下表,默认为 hot,即热门帖子', '排序方式,见下表,默认为空,即最新回复']">
分区
| 分区 | id |
| -------- | --- |
| 留学申请 | 257 |
| 世界公民 | 379 |
| 投资理财 | 400 |
| 生活干货 | 31 |
| 职场达人 | 345 |
| 人际关系 | 391 |
| 海外求职 | 38 |
| 签证移民 | 265 |
分类
| 热门帖子 | 最新帖子 |
| -------- | -------- |
| hot | new |
排序方式
| 最新回复 | 最新发布 |
| -------- | -------- |
| | post |
</Route>
### 标签
<Route author="nczitzk" example="/1point3acres/category/h1b" path="/1point3acres/category/:id?/:type?/:order?" :paramsDesc="['标签 id,默认为全部', '帖子分类, 见下表,默认为 hot,即热门帖子', '排序方式,见下表,默认为空,即最新回复']">
::: tip
更多标签可以在 [标签列表](https://instant.1point3acres.com/tags) 中找到。
:::
分类
| 热门帖子 | 最新帖子 |
| -------- | -------- |
| hot | new |
排序方式
| 最新回复 | 最新发布 |
| -------- | -------- |
| | post |
</Route>
### 用户主题帖
<Route author="Maecenas" example="/1point3acres/user/1/threads" path="/1point3acres/user/:id/threads" :paramsDesc="['用户 id,可在 Instant 版网站的个人主页 URL 找到']"/>
@@ -1090,6 +1155,7 @@ pageClass: routes
### 录取结果
<Route author="NavePnow" example="/1point3acres/offer/12/null/CMU" path="/1point3acres/offer/:year?/:major?/:school?" :paramsDesc="['录取年份 id,空为null', '录取专业 id,空为null', '录取学校 id,空为null']">
::: warning 三个 id 获取方式
1. 打开 <https://offer.1point3acres.com>
@@ -1105,32 +1171,11 @@ pageClass: routes
### 博客
<Route author="nczitzk" example="/1point3acres/blog" path="/1point3acres/blog/:category?" :paramsDesc="['分类,见下表,可在对应分类页 URL 中找到']">
<Route author="nczitzk" example="/1point3acres/blog" path="/1point3acres/blog/:category?" :paramsDesc="['分类,见下表,可在对应分类页 URL 中找到']" radar="1">
| 分类 | 分类名 |
| ---------- | --------------------------------------------------------------------- |
| 全部 | |
| 一亩三分地 | 一亩三分地 |
| 论坛精华 | 一亩三分地 - 论坛精华 |
| 咨询服务 | 咨询服务 |
| 学校院系 | 学校院系信息 |
| 找工求职 | 如何找工作 |
| 美国经济 | 如何找工作 - 美国经济与就业 |
| 杂谈其他 | 其他类别 |
| 抄袭 | 其他类别 - 抄袭 |
| 直播 | 其他类别 - 直播 |
| 热门专业 | eecsmis 统计金工等热门专业 |
| EECSMIS | eecsmis 统计金工等热门专业 - eecsmis 专业 |
| 数据科学 | eecsmis 统计金工等热门专业 - 数据科学 |
| 统计金工 | eecsmis 统计金工等热门专业 - 生物统计金融工程公共健康生物技术制药行业 |
| 留学申请 | 留学申请信息 |
| GT 考试 | 留学申请信息 - gt 考试 |
| 定位 | 留学申请信息 - 定位 |
| 文书写作 | 留学申请信息 - 文书写作 |
| 面试 | 留学申请信息 - 面试 |
| 移民绿卡 | 移民办绿卡 |
| 美国学习 | 美国学习 |
| 美国生活 | 美国生活 |
| 留学申请 | 找工求职 | 生活攻略 | 投资理财 | 签证移民 | 时政要闻 |
| ---------- | -------- | --------- | -------- | -------- | -------- |
| studyinusa | career | lifestyle | invest | visa | news |
</Route>
+5 -5
View File
@@ -1506,11 +1506,11 @@ router.get('/bupt/funbox', lazyloadRouteHandler('./routes/universities/bupt/funb
// router.get('/vocus/user/:id', lazyloadRouteHandler('./routes/vocus/user'));
// 一亩三分地 1point3acres
router.get('/1point3acres/blog/:category?', lazyloadRouteHandler('./routes/1point3acres/blog'));
router.get('/1point3acres/user/:id/threads', lazyloadRouteHandler('./routes/1point3acres/threads'));
router.get('/1point3acres/user/:id/posts', lazyloadRouteHandler('./routes/1point3acres/posts'));
router.get('/1point3acres/offer/:year?/:major?/:school?', lazyloadRouteHandler('./routes/1point3acres/offer'));
router.get('/1point3acres/post/:category', lazyloadRouteHandler('./routes/1point3acres/post'));
// router.get('/1point3acres/blog/:category?', lazyloadRouteHandler('./routes/1point3acres/blog'));
// router.get('/1point3acres/user/:id/threads', lazyloadRouteHandler('./routes/1point3acres/threads'));
// router.get('/1point3acres/user/:id/posts', lazyloadRouteHandler('./routes/1point3acres/posts'));
// router.get('/1point3acres/offer/:year?/:major?/:school?', lazyloadRouteHandler('./routes/1point3acres/offer'));
// router.get('/1point3acres/post/:category', lazyloadRouteHandler('./routes/1point3acres/post'));
// 广东海洋大学
router.get('/gdoujwc', lazyloadRouteHandler('./routes/universities/gdou/jwc/jwtz'));
-52
View File
@@ -1,52 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const category = ctx.params.category || '';
const rootUrl = 'https://www.1point3acres.com';
const currentUrl = `${rootUrl}/${category === '' ? 'BlogPosts' : `category/${category.replace(/-/g, '/')}`}`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const list = $('.mybloglist h2 a')
.slice(0, 10)
.map((_, item) => {
item = $(item);
return {
title: item.text(),
link: item.attr('href'),
};
})
.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);
content('h2, .meta_tags, .pagination, .subinfopost, #comments').remove();
item.description = content('.post').html();
item.pubDate = new Date(detailResponse.data.match(/"datePublished":"(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+00:00)","dateModified":/)[1]).toUTCString();
return item;
})
)
);
const title = $('title').text().split(' | ')[0];
ctx.state.data = {
title: `${title === 'BlogPosts' ? '全部' : title} - 一亩三分地论坛博客`,
link: currentUrl,
item: items,
};
};
-211
View File
@@ -1,211 +0,0 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
// let out = '';
// const { id } = ctx.params;
// const { year } = ctx.params.year || 'null';
// year 2017-2022
// 2017:6 2018:11 2019:12 2020:13 2021:14 2022:15
// const { major } = ctx.params.major || 'null';
// CS:1 MIS:2
// const { school } = ctx.params.school || 'null';
const year = ctx.params.year || 'null';
const major = ctx.params.major || 'null';
const school = ctx.params.school || 'null';
// school == 'null' ? outname_w : 'CMU'
const url = 'https://api.1point3acres.com/offer/results?ps=15&pg=1';
// const filter = '{"filters": {"planyr": "12", "planmajor": "1", "outname_w": "CMU"}}';
// const filter = 'filters: {planyr: "12", planmajor: "1", outname_w: "CMU"}';
let responseBasic;
// eslint-disable-next-line eqeqeq
if (year == 'null') {
// eslint-disable-next-line eqeqeq
if (major == 'null') {
// eslint-disable-next-line eqeqeq
if (school == 'null') {
// year空 major空 school空
responseBasic = await got({
method: 'post',
url,
json: {
filters: {},
},
});
} else {
// year空 major空 school不空
responseBasic = await got({
method: 'post',
url,
json: {
filters: {
outname_w: school,
},
},
});
}
} else {
// year空 major不空
// eslint-disable-next-line eqeqeq
if (school == 'null') {
// year空 major不空 school空
responseBasic = await got({
method: 'post',
url,
json: {
filters: {
planmajor: major,
},
},
});
} else {
// year空 major不空 school不空
responseBasic = await got({
method: 'post',
url,
json: {
filters: {
planmajor: major,
outname_w: school,
},
},
});
}
}
} else {
// eslint-disable-next-line eqeqeq
if (major == 'null') {
// eslint-disable-next-line eqeqeq
if (school == 'null') {
// year不空 major空 school空
responseBasic = await got({
method: 'post',
url,
json: {
filters: {
planyr: year,
},
},
});
} else {
// year不空 major空 school不空
responseBasic = await got({
method: 'post',
url,
json: {
filters: {
planyr: year,
outname_w: school,
},
},
});
}
} else {
// eslint-disable-next-line eqeqeq
if (school == 'null') {
// year不空 major不空 school空
responseBasic = await got({
method: 'post',
url,
json: {
filters: {
planyr: year,
planmajor: major,
},
},
});
} else {
// year不空 major不空 school不空
responseBasic = await got({
method: 'post',
url,
json: {
filters: {
planyr: year,
planmajor: major,
outname_w: school,
},
},
});
}
}
}
const data = responseBasic.data.results;
// data.id-> 访问offer具体信息->获取 data.tid
// if (data.id !== 0) {
// out = await Promise.all(
// data.map(async (item) => {
// var gettidresponse = await got({
// method: 'get',
// url: 'https://api.1point3acres.com/offer/results/'+ item.id + '/backgrounds',
// headers: {
// authorization: 'eyJhbGciOiJIUzUxMiIsImlhdCI6MTU3Njk5Njc5OSwiZXhwIjoxNTg0ODU5MTk5fQ.eyJ1aWQiOjQ1NzQyN30.0ei5UE6OgLBzN2_IS7xUIbIfW_S1Wzl42q2UeusbboxuzvctO_4Mz6YRr6f0PBLUVZMETxt8F0_4-yqIJ3_kUQ',
// },
// });
// var tid = gettidresponse.data.background.tid;
// //https: //www.1point3acres.com/bbs/thread-581177-1-1.html
// console.log(tid);
// const threadlink = 'https://www.1point3acres.com/bbs/thread-' + tid + '-1-1.html';
// console.log(threadlink);
// return threadlink;
// })
// );
// }
// let responseBasic_1;
// responseBasic_1 = await got({
// method: 'get',
// url: `https://api.1point3acres.com/offer/results/A7m20e4g/backgrounds`,
// headers: {
// authorization: `eyJhbGciOiJIUzUxMiIsImlhdCI6MTU3Njk5Njc5OSwiZXhwIjoxNTg0ODU5MTk5fQ.eyJ1aWQiOjQ1NzQyN30.0ei5UE6OgLBzN2_IS7xUIbIfW_S1Wzl42q2UeusbboxuzvctO_4Mz6YRr6f0PBLUVZMETxt8F0_4-yqIJ3_kUQ`,
// },
// });
// const tid = responseBasic_1.data.background.tid;
ctx.state.data = {
title: `录取结果 - 一亩三分地`,
link: `https://offer.1point3acres.com`,
description: `录取结果 - 一亩三分地`,
item: data.map((item) => ({
title: item.planyr + `年` + item.planmajor + `@` + item.outname_w + ` ` + item.result + ` - 一亩三分地`, // `${year_result}年${major_result}@${outname_w_result} ${result_result}`,
description:
`<b>国家:</b>` +
item.country +
`<br>` +
`<b>学校:</b>` +
item.outname_w +
` ` +
item.outname +
'<br>' +
`<b>录取学位:</b>` +
item.plandegree +
'<br>' +
`<b>录取项目:</b>` +
item.planmajor +
`-` +
item.planprogram +
'<br>' +
`<b>录取结果:</b>` +
item.result +
'<br>' +
`<b>录取时间:</b>` +
item.outtime +
'<br>' +
`<b>通知方式:</b>` +
item.noticemethod +
'<br>' +
`<b>全奖/自费:</b>` +
item.planfin +
'<br>' +
`<b>申入学学期:</b>` +
item.planterm +
'<br>' +
`<b>申入学年度:</b>` +
item.planyr +
'<br>' +
`<b>提交时间:</b>` +
item.submittime +
'<br>',
// pubDate: new Date(item.submittime + ' GMT+8').toUTCString(),
link: `https://offer.1point3acres.com`,
// link: out,
})),
};
};
-50
View File
@@ -1,50 +0,0 @@
const got = require('@/utils/got');
const bbcode = require('bbcodejs');
module.exports = async (ctx) => {
const category = ctx.params.category;
let url;
let title;
if (category === 'new') {
url = 'https://api.1point3acres.com/api/threads?type=new&pg=1&ps=20&includes=summary';
title = '最新帖子';
} else {
url = 'https://api.1point3acres.com/api/threads?type=hot&pg=1&ps=20&includes=summary';
title = '热门帖子';
}
const responseBasic = await got({
method: 'get',
url,
});
const data = responseBasic.data.threads;
const bbcodeParser = new bbcode.Parser();
const items = await Promise.all(
data.map(async (item) => {
const result = {
title: item.subject,
description: `${item.summary}...<br><br><small>作者 ${item.author} · 回复 ${item.replies} · 查看 ${item.views}</small>`,
link: `https://instant.1point3acres.com/thread/${item.tid}`,
};
try {
await ctx.cache.tryGet(item.link, async () => {
const detail = await got({
method: 'get',
url: `https://api.1point3acres.com/instant/threads/${item.tid}`,
referer: 'https://instant.1point3acres.com/',
});
result.description = `${bbcodeParser.toHTML(detail.data.thread.message_bbcode)}<br><br><small>作者 ${item.author} · 回复 ${item.replies} · 查看 ${item.views}</small>`;
});
} catch (error) {
// nothing
}
return result;
})
);
ctx.state.data = {
title: `一亩三分地 - ${title}`,
link: `https://www.1point3acres.com/bbs/`,
item: items,
};
};
+67
View File
@@ -0,0 +1,67 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const categoryMap = {
studyinusa: {
title: '留学申请',
id: 18,
},
career: {
title: '找工求职',
id: 200,
},
lifestyle: {
title: '生活攻略',
id: 370,
},
invest: {
title: '投资理财',
id: 371,
},
visa: {
title: '签证移民',
id: 194,
},
news: {
title: '时政要闻',
id: 366,
},
};
const { category } = ctx.params;
const rootUrl = 'https://blog.1point3acres.com';
const currentUrl = `${rootUrl}/${category}/`;
const { data } = await got(`${rootUrl}/wp-json/wp/v2/posts`, {
searchParams: {
categories: category ? categoryMap[category].id : undefined,
per_page: ctx.query.limit ? parseInt(ctx.query.limit) : 100,
},
});
const items = data.map((item) => {
const $ = cheerio.load(item.content.rendered, null, false);
$('h2').nextAll().remove();
$('[powered-by="1p3a"], h2').remove();
$('img').each((_, img) => {
if (img.attribs.src.match(/wp-content\/uploads/)) {
img.attribs.src = img.attribs.src.replace(/(-\d+x\d+)/, '');
}
});
return {
title: item.title.rendered,
description: $.html(),
link: item.link,
pubDate: parseDate(item.date_gmt),
};
});
ctx.state.data = {
title: `${category ? `${categoryMap[category].title} | ` : ''}美国留学就业生活攻略`,
link: currentUrl,
item: items,
};
};
+17
View File
@@ -0,0 +1,17 @@
const { rootUrl, apiRootUrl, types, ProcessThreads } = require('./utils');
module.exports = async (ctx) => {
const id = ctx.params.id ?? '';
const type = ctx.params.type ?? 'hot';
const order = ctx.params.order ?? '';
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 10;
const currentUrl = `${rootUrl}${id ? `/category/${id}` : ''}`;
const apiUrl = `${apiRootUrl}/api${id ? `/tags/${id}/` : ''}threads?type=${type}&includes=tags,forum_name,summary&ps=${limit}&pg=1&order=${order === '' ? '' : 'time_desc'}&is_groupid=1`;
ctx.state.data = {
title: `一亩三分地 - ${id}${types[type]}`,
link: currentUrl,
item: await ProcessThreads(ctx.cache.tryGet, apiUrl, order),
};
};
+9
View File
@@ -0,0 +1,9 @@
module.exports = {
'/blog/:category?': ['nczitzk'],
'/category/:id?/:type?/:order?': ['nczitzk'],
'/offer/:year?/:major?/:school?': ['NavePnow'],
'/post/:type?/:order?': ['NavePnow', 'DIYgod', 'nczitzk'],
'/section/:id?/:type?/:order?': ['nczitzk'],
'/user/:id/posts': ['Maecenas'],
'/user/:id/threads': ['Maecenas'],
};
+69
View File
@@ -0,0 +1,69 @@
const got = require('@/utils/got');
const { art } = require('@/utils/render');
const { parseDate } = require('@/utils/parse-date');
const { join } = require('path');
module.exports = async (ctx) => {
// year 2017-2022
// 2017:6 2018:11 2019:12 2020:13 2021:14 2022:15
// CS:1 MIS:2
const { year = 'null', major = 'null', school = 'null' } = ctx.params;
// const filter = 'filters: {planyr: "12", planmajor: "1", outname_w: "CMU"}';
const responseBasic = await got.post('https://api.1point3acres.com/offer/results', {
searchParams: {
ps: 15,
pg: 1,
},
json: {
filters: {
planyr: year !== 'null' ? year : undefined,
planmajor: major !== 'null' ? major : undefined,
outname_w: school !== 'null' ? school : undefined,
},
},
});
const data = responseBasic.data.results;
// data.id-> 访问offer具体信息->获取 data.tid
// if (data.id !== 0) {
// out = await Promise.all(
// data.map(async (item) => {
// var gettidresponse = await got({
// method: 'get',
// url: 'https://api.1point3acres.com/offer/results/'+ item.id + '/backgrounds',
// headers: {
// authorization: 'eyJhbGciOiJIUzUxMiIsImlhdCI6MTU3Njk5Njc5OSwiZXhwIjoxNTg0ODU5MTk5fQ.eyJ1aWQiOjQ1NzQyN30.0ei5UE6OgLBzN2_IS7xUIbIfW_S1Wzl42q2UeusbboxuzvctO_4Mz6YRr6f0PBLUVZMETxt8F0_4-yqIJ3_kUQ',
// },
// });
// var tid = gettidresponse.data.background.tid;
// //https: //www.1point3acres.com/bbs/thread-581177-1-1.html
// console.log(tid);
// const threadlink = 'https://www.1point3acres.com/bbs/thread-' + tid + '-1-1.html';
// console.log(threadlink);
// return threadlink;
// })
// );
// }
// let responseBasic_1;
// responseBasic_1 = await got({
// method: 'get',
// url: `https://api.1point3acres.com/offer/results/A7m20e4g/backgrounds`,
// headers: {
// authorization: `eyJhbGciOiJIUzUxMiIsImlhdCI6MTU3Njk5Njc5OSwiZXhwIjoxNTg0ODU5MTk5fQ.eyJ1aWQiOjQ1NzQyN30.0ei5UE6OgLBzN2_IS7xUIbIfW_S1Wzl42q2UeusbboxuzvctO_4Mz6YRr6f0PBLUVZMETxt8F0_4-yqIJ3_kUQ`,
// },
// });
// const tid = responseBasic_1.data.background.tid;
ctx.state.data = {
title: '录取结果 - 一亩三分地',
link: 'https://offer.1point3acres.com',
item: data.map((item) => ({
title: `${item.planyr}年${item.planmajor}@${item.outname_w}:${item.result} - 一亩三分地`,
description: art(join(__dirname, 'templates/offer.art'), {
item,
}),
pubDate: parseDate(item.dateline, 'X'),
link: 'https://offer.1point3acres.com',
guid: `1point3acres:offer:${year}:${major}:${school}:${item.id}`,
})),
};
};
+53
View File
@@ -0,0 +1,53 @@
module.exports = {
'1point3acres.com': {
_name: '一亩三分地',
blog: [
{
title: '博客',
docs: 'https://docs.rsshub.app/bbs.html#yi-mu-san-fen-di',
source: ['/:category'],
target: '/1point3acres/blog/:category?',
},
],
instant: [
{
title: '帖子',
docs: 'https://docs.rsshub.app/bbs.html#yi-mu-san-fen-di',
source: ['/'],
target: '/1point3acres/thread/:type?/:order?',
},
{
title: '分区',
docs: 'https://docs.rsshub.app/bbs.html#yi-mu-san-fen-di',
source: ['/section/:id', '/'],
target: '/1point3acres/section/:id?/:type?/:order?',
},
{
title: '标签',
docs: 'https://docs.rsshub.app/bbs.html#yi-mu-san-fen-di',
source: ['/section/:id', '/'],
target: '/1point3acres/category/:id?/:type?/:order?',
},
{
title: '用户主题帖',
docs: 'https://docs.rsshub.app/bbs.html#yi-mu-san-fen-di',
source: ['/profile/:id', '/'],
target: '/1point3acres/user/:id/threads',
},
{
title: '用户回帖',
docs: 'https://docs.rsshub.app/bbs.html#yi-mu-san-fen-di',
source: ['/profile/:id', '/'],
target: '/1point3acres/user/:id/posts',
},
],
offer: [
{
title: '录取结果',
docs: 'https://docs.rsshub.app/bbs.html#yi-mu-san-fen-di',
source: ['/'],
target: '/1point3acres/offer',
},
],
},
};
+10
View File
@@ -0,0 +1,10 @@
module.exports = function (router) {
router.get('/blog/:category?', require('./blog'));
router.get('/category/:id?/:type?/:order?', require('./category'));
router.get('/offer/:year?/:major?/:school?', require('./offer'));
router.get('/post/:type?/:order?', require('./thread'));
router.get('/section/:id?/:type?/:order?', require('./section'));
router.get('/thread/:type?/:order?', require('./thread'));
router.get('/user/:id/posts', require('./user/post'));
router.get('/user/:id/threads', require('./user/thread'));
};
+28
View File
@@ -0,0 +1,28 @@
const { rootUrl, apiRootUrl, types, ProcessThreads } = require('./utils');
const sections = {
257: '留学申请',
379: '世界公民',
400: '投资理财',
31: '生活干货',
345: '职场达人',
391: '人际关系',
38: '海外求职',
265: '签证移民',
};
module.exports = async (ctx) => {
const id = ctx.params.id ?? '';
const type = ctx.params.type ?? 'hot';
const order = ctx.params.order ?? '';
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 10;
const currentUrl = `${rootUrl}${id ? (isNaN(id) ? `/category/${id}` : `/section/${id}`) : ''}`;
const apiUrl = `${apiRootUrl}/api${id ? (isNaN(id) ? `/tags/${id}/` : `/forums/${id}/`) : ''}threads?type=${type}&includes=tags,forum_name,summary&ps=${limit}&pg=1&order=${order === '' ? '' : 'time_desc'}&is_groupid=1`;
ctx.state.data = {
title: `一亩三分地 - ${sections.hasOwnProperty(id) ? sections[id] : id}${types[type]}`,
link: currentUrl,
item: await ProcessThreads(ctx.cache.tryGet, apiUrl, order),
};
};
+1
View File
@@ -0,0 +1 @@
<img src="{{ url }}" height="{{ height }}" width="{{ width }}">
+11
View File
@@ -0,0 +1,11 @@
<b>国家:</b>{{ item.country }}<br>
<b>学校:</b>{{ item.outname_w }} {{ item.outname }}<br>
<b>录取学位:</b>{{ item.plandegree }}<br>
<b>录取项目:</b>{{ item.planmajor }} - {{ item.planprogram }}<br>
<b>录取结果:</b>{{ item.result }}<br>
<b>录取时间:</b>{{ item.outtime }}<br>
<b>通知方式:</b>{{ item.noticemethod }}<br>
<b>全奖/自费:</b>{{ item.planfin }}<br>
<b>申入学学期:</b>{{ item.planterm }}<br>
<b>申入学年度:</b>{{ item.planyr }}<br>
<b>提交时间:</b>{{ item.submittime }}
+15
View File
@@ -0,0 +1,15 @@
const { rootUrl, apiRootUrl, types, ProcessThreads } = require('./utils');
module.exports = async (ctx) => {
const type = ctx.params.type ?? 'hot';
const order = ctx.params.order ?? '';
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 10;
const apiUrl = `${apiRootUrl}/api/threads?type=${type}&includes=tags,forum_name,summary&ps=${limit}&pg=1&order=${order === '' ? '' : 'time_desc'}&is_groupid=1`;
ctx.state.data = {
title: `一亩三分地 - ${types[type]}`,
link: rootUrl,
item: await ProcessThreads(ctx.cache.tryGet, apiUrl, order),
};
};
+79
View File
@@ -0,0 +1,79 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');
const bbcode = require('bbcodejs');
const rootUrl = 'https://instant.1point3acres.com';
const apiRootUrl = 'https://api.1point3acres.com';
const types = {
new: '最新帖子',
hot: '热门帖子',
};
module.exports = {
rootUrl,
apiRootUrl,
types,
ProcessThreads: async (tryGet, apiUrl, order) => {
const response = await got({
method: 'get',
url: apiUrl,
headers: {
referer: rootUrl,
},
});
const bbcodeParser = new bbcode.Parser();
const items = await Promise.all(
response.data.threads.map((item) => {
const result = {
guid: item.tid,
title: item.subject,
author: item.author,
link: `${rootUrl}/thread/${item.tid}`,
description: item.summary,
pubDate: parseDate((order === '' ? item.lastpost : item.dateline) * 1000),
category: [item.forum_name, ...item.tags.map((t) => t.displayname)],
};
return tryGet(result.link, async () => {
try {
const detailResponse = await got({
method: 'get',
url: `${apiRootUrl}/api/v3/threads/${result.guid}`,
headers: {
referer: rootUrl,
},
});
const data = detailResponse.data;
result.description = bbcodeParser.toHTML(data.thread.message_bbcode);
for (const a of data.thread.attachment_list) {
if (a.isimage === 1) {
result.description = result.description.replace(
new RegExp(`\\[attach\\]${a.aid}\\[\\/attach\\]`, 'g'),
art(path.join(__dirname, 'templates/image.art'), {
url: a.url,
height: a.height,
width: a.width,
})
);
}
}
} catch (e) {
// no-empty
}
return result;
});
})
);
return items;
},
};