Skip to content

Commit

Permalink
feat: new and hot post of 1point3acres (DIYgod#4369)
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan authored Apr 2, 2020
1 parent 10f18de commit d4a9fe2
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/bbs.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,14 @@ pageClass: routes

<Route author="Maecenas" example="/1point3acres/user/1/posts" path="/1point3acres/user/:id/posts" :paramsDesc="['用户 id,可在 Instant 版网站的个人主页 URL 找到']"/>

### 帖子 (手机端的最热与最新 Tab)

<Route author="NavePnow" example="/1point3acres/post/hot" path="/1point3acres/post/:category" :paramsDesc="['分类 category, 见下表']"/>

| 最热帖子 | 最新帖子 |
| -------- | -------- |
| hot | new |

### 录取结果

<Route author="NavePnow" example="/1point3acres/offer/12/null/CMU" path="/1point3acres/offer/:year?/:major?/:school?" :paramsDesc="['录取年份 id,空为null', '录取专业 id,空为null', '录取学校 id,空为null']">
Expand Down
1 change: 1 addition & 0 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,7 @@ router.get('/vocus/user/:id', require('./routes/vocus/user'));
router.get('/1point3acres/user/:id/threads', require('./routes/1point3acres/threads'));
router.get('/1point3acres/user/:id/posts', require('./routes/1point3acres/posts'));
router.get('/1point3acres/offer/:year?/:major?/:school?', require('./routes/1point3acres/offer'));
router.get('/1point3acres/post/:category', require('./routes/1point3acres/post'));

// 广东海洋大学
router.get('/gdoujwc', require('./routes/universities/gdou/jwc/jwtz'));
Expand Down
38 changes: 38 additions & 0 deletions lib/routes/1point3acres/post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const got = require('@/utils/got');

module.exports = async (ctx) => {
const category = ctx.params.category;
let url;
let method;
let description;
let { title } = 'null';
// eslint-disable-next-line eqeqeq
if (title == 'null') {
method = 'get';
}
// eslint-disable-next-line eqeqeq
category == 'new'
? ((url = 'https://api.1point3acres.com/api/threads?type=new&pg=1&ps=20&includes=last_reply'), (title = '最新帖子'))
: ((url = 'https://api.1point3acres.com/api/threads?type=hot&pg=1&ps=20&includes=last_reply'), (title = '最热帖子'));
const responseBasic = await got({
method: method,
url: url,
});
const data = responseBasic.data.threads;
ctx.state.data = {
title: `${title} - 一亩三分地`,
link: `https://www.1point3acres.com/bbs/`,
description: `${title} - 一亩三分地`,
item: data.map((item) => {
// eslint-disable-next-line eqeqeq
item.last_reply.quote == '' ? (description = item.last_reply.message_bbcode) : (description = item.last_reply.quote);
return {
title: `${item.subject}`,
// description: item.last_reply.message_bbcode,// + `<b>楼主:</b>` + item.author,
description: description,
// pubDate: new Date(item.submittime + ' GMT+8').toUTCString(),
link: `https://instant.1point3acres.com/thread/${item.tid}`,
};
}),
};
};

0 comments on commit d4a9fe2

Please sign in to comment.