From f9ebd68f5870724babdea5f17fe70c3baac96763 Mon Sep 17 00:00:00 2001 From: Chenyang Shi Date: Thu, 28 Feb 2019 16:55:25 +0800 Subject: [PATCH] =?UTF-8?q?add=20WeGene=20=E5=BE=AE=E8=A7=A3=E8=AF=BB=20?= =?UTF-8?q?=E5=92=8C=20=E6=9C=80=E8=BF=91=E6=9B=B4=E6=96=B0=20(#1635)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #1601 --- docs/README.md | 15 +++++++++++++++ lib/router.js | 4 ++++ lib/routes/wegene/column.js | 30 ++++++++++++++++++++++++++++++ lib/routes/wegene/newest.js | 20 ++++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 lib/routes/wegene/column.js create mode 100644 lib/routes/wegene/newest.js diff --git a/docs/README.md b/docs/README.md index 4017b3d31..ec1cac5c9 100644 --- a/docs/README.md +++ b/docs/README.md @@ -3053,6 +3053,21 @@ board 和 build 可在[这里](http://api.ineal.me/tss/status)查看 +### WeGene + + + + +::: +type 为 all 时,category 参数不支持 cost 和 free +::: + +| 全部 | 祖源分析 | 付费 | 遗传性疾病 | 药物指南 | 免费 | 运动基因 | 营养代谢 | 心理特质 | 健康风险 | 皮肤特性 | 遗传特征 | +| ---- | -------- | ---- | ---------- | -------- | ---- | -------- | ---------- | ---------- | -------- | -------- | -------- | +| all | ancestry | cost | disease | drug | free | genefit | metabolism | psychology | risk | skin | traits | + + + ### instapaper diff --git a/lib/router.js b/lib/router.js index 5e335cfbe..4d6bac2c8 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1086,6 +1086,10 @@ router.get('/security/pulses', require('./routes/security/pulses')); // DoNews router.get('/donews/:column?', require('./routes/donews/index')); +// WeGene +router.get('/wegene/column/:type/:category', require('./routes/wegene/column')); +router.get('/wegene/newest', require('./routes/wegene/newest')); + // instapaper router.get('/instapaper/person/:name', require('./routes/instapaper/person')); diff --git a/lib/routes/wegene/column.js b/lib/routes/wegene/column.js new file mode 100644 index 000000000..cf765fa54 --- /dev/null +++ b/lib/routes/wegene/column.js @@ -0,0 +1,30 @@ +const axios = require('../../utils/axios'); + +module.exports = async (ctx) => { + const type = ctx.params.type; + let name; + if (type === 'all') { + name = '全部项目'; + } else { + name = '专业版'; + } + const category = ctx.params.category; + + const link = 'https://www.wegene.com/crowdsourcing'; + const api = `https://www.wegene.com/crowdsourcing/ajax/get_list/?&htmlspecialchars_decode=true&type=${type}&page=1&limit=10&category=${category}&sort=NEW`; + + const response = await axios.get(api); + const data = response.data.rsm.list; + + ctx.state.data = { + title: `${name}的${category}最近更新-WeGene`, + link: link, + item: data.map((item) => ({ + title: item.title, + link: `https://www.wegene.com/crowdsourcing/details/${item.id}`, + date: new Date(item.add_time * 1000).toUTCString(), + author: item.user.user_name, + description: item.description, + })), + }; +}; diff --git a/lib/routes/wegene/newest.js b/lib/routes/wegene/newest.js new file mode 100644 index 000000000..5998fc7ec --- /dev/null +++ b/lib/routes/wegene/newest.js @@ -0,0 +1,20 @@ +const axios = require('../../utils/axios'); + +module.exports = async (ctx) => { + const link = 'https://www.wegene.com/'; + const api = 'https://www.wegene.com/contents/ajax/update/get_list/?htmlspecialchars_decode=true&page=1'; + + const response = await axios.get(api); + const data = response.data.rsm; + + ctx.state.data = { + title: '最近更新-WeGene', + link: link, + item: data.map((item) => ({ + title: item.title, + description: item.description, + pubDate: new Date(item.add_time * 1000).toUTCString(), + link: item.url, + })), + }; +};