From 64998cedafb076657d53ffe9a58395f8a31a3ec7 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Thu, 18 Apr 2019 16:34:59 +0900 Subject: [PATCH] =?UTF-8?q?Add=201point3acres=20=E4=B8=80=E4=BA=A9?= =?UTF-8?q?=E4=B8=89=E5=88=86=E5=9C=B0=20(#1954)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/social-media.md | 6 ++++++ lib/router.js | 4 ++++ lib/routes/1point3acres/posts.js | 21 +++++++++++++++++++++ lib/routes/1point3acres/threads.js | 21 +++++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 lib/routes/1point3acres/posts.js create mode 100644 lib/routes/1point3acres/threads.js diff --git a/docs/social-media.md b/docs/social-media.md index 3e38c505bf..c65980ffb0 100644 --- a/docs/social-media.md +++ b/docs/social-media.md @@ -485,3 +485,9 @@ ## 方格子 + +## 一亩三分地 + + + + diff --git a/lib/router.js b/lib/router.js index b0ea54011e..f759798e8b 100755 --- a/lib/router.js +++ b/lib/router.js @@ -1263,4 +1263,8 @@ router.get('/bupt/yz/:type', require('./routes/universities/bupt/yz')); // VOCUS 方格子 router.get('/vocus/publication/:id', require('./routes/vocus/publication')); +// 一亩三分地 1point3acres +router.get('/1point3acres/user/:id/threads', require('./routes/1point3acres/threads')); +router.get('/1point3acres/user/:id/posts', require('./routes/1point3acres/posts')); + module.exports = router; diff --git a/lib/routes/1point3acres/posts.js b/lib/routes/1point3acres/posts.js new file mode 100644 index 0000000000..59c55eb305 --- /dev/null +++ b/lib/routes/1point3acres/posts.js @@ -0,0 +1,21 @@ +const axios = require('../../utils/axios'); + +module.exports = async (ctx) => { + const { id } = ctx.params; + + const { posts } = (await axios.get(`https://instant.1point3acres.com/v2/api/user/post?pg=1&ps=10&user_id=${id}`)).data; + const [{ author_name: author }] = posts; + + ctx.state.data = { + title: `${author}的回复 - 一亩三分地`, + link: `https://instant.1point3acres.com/profile/${id}`, + description: `${author}的回复 - 一亩三分地`, + item: posts.map((item) => ({ + title: item.message, + author, + description: item.message, + pubDate: new Date(item.create_time + ' GMT+8').toUTCString(), + link: `https://instant.1point3acres.com/thread/${item.thread_id}/post/${item.id}`, + })), + }; +}; diff --git a/lib/routes/1point3acres/threads.js b/lib/routes/1point3acres/threads.js new file mode 100644 index 0000000000..09932cabb6 --- /dev/null +++ b/lib/routes/1point3acres/threads.js @@ -0,0 +1,21 @@ +const axios = require('../../utils/axios'); + +module.exports = async (ctx) => { + const { id } = ctx.params; + + const { threads } = (await axios.get(`https://instant.1point3acres.com/v2/api/user/thread?pg=1&ps=10&user_id=${id}`)).data; + const [{ author_name: author }] = threads; + + ctx.state.data = { + title: `${author}的主题帖 - 一亩三分地`, + link: `https://instant.1point3acres.com/profile/${id}`, + description: `${author}的主题帖 - 一亩三分地`, + item: threads.map((item) => ({ + title: item.title, + author, + description: item.description, + pubDate: new Date(item.update_time + ' GMT+8').toUTCString(), + link: `https://instant.1point3acres.com/thread/${item.id}`, + })), + }; +};