From 00ae4b5495328c2e7de2f0a870257e2f2e8c4585 Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Thu, 30 Apr 2020 16:06:35 +0800 Subject: [PATCH] feat: add xposed module changelog (#4624) --- docs/program-update.md | 4 ++++ lib/router.js | 3 +++ lib/routes/xposed/module.js | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 lib/routes/xposed/module.js diff --git a/docs/program-update.md b/docs/program-update.md index 490408e2c4..ad54482d9f 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -220,6 +220,10 @@ pageClass: routes +## Xposed Module + + + ## 怪物猎人世界 ### 更新 diff --git a/lib/router.js b/lib/router.js index 83fc20b0b1..1762268f8e 100755 --- a/lib/router.js +++ b/lib/router.js @@ -2616,6 +2616,9 @@ router.get('/digic-pictures/:menu/:tags?', require('./routes/digic-pictures/inde // cve.mitre.org router.get('/cve/search/:keyword', require('./routes/cve/search')); +// Xposed Module Repository +router.get('/xposed/module/:mod', require('./routes/xposed/module')); + // Microsoft Edge router.get('/edge/addon/:crxid', require('./routes/edge/addon')); diff --git a/lib/routes/xposed/module.js b/lib/routes/xposed/module.js new file mode 100644 index 0000000000..0f19054f62 --- /dev/null +++ b/lib/routes/xposed/module.js @@ -0,0 +1,34 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const link = `https://repo.xposed.info/module/${ctx.params.mod}`; + const response = await got({ + method: 'get', + url: link, + }); + + const data = response.data; + + const $ = cheerio.load(data); + const title = $('#page-title').text(); + const list = $('div.field-collection-view'); + + ctx.state.data = { + title: `${title}(${ctx.params.mod})`, + link: link, + item: + list && + list + .map((_, item) => { + item = $(item); + return { + title: item.find('div.field-name-field-version-number div.even').text(), + description: item.find('div.field-name-field-changes').html(), + link: link, + pubDate: item.find('span.date-display-single').html().replace('- ', ''), + }; + }) + .get(), + }; +};