From f9f8406ba1e110b9b52676352bd7308bbd87c3bc Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Thu, 4 Jul 2019 09:21:29 +0100 Subject: [PATCH] feat: add aptonic Dropzone action (#2545) * feat: add aptonic Dropzone action * doc: aptonic Dropzone action --- docs/en/README.md | 6 ++++++ docs/program-update.md | 6 ++++++ lib/router.js | 3 +++ lib/routes/aptonic/action.js | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 lib/routes/aptonic/action.js diff --git a/docs/en/README.md b/docs/en/README.md index d912cea103..39fba36c14 100644 --- a/docs/en/README.md +++ b/docs/en/README.md @@ -651,3 +651,9 @@ Supported sub-sites: #### Poems + +## aptonic + +### New Dropzone Actions + + diff --git a/docs/program-update.md b/docs/program-update.md index d1a8db458f..50c0172270 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -32,6 +32,12 @@ pageClass: routes +## aptonic + +### 新的 Dropzone 动作 + + + ## Bugly SDK ### 更新日志 diff --git a/lib/router.js b/lib/router.js index 66282cac8f..4ff09e2462 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1467,4 +1467,7 @@ router.get('/tprtc/news', require('./routes/tprtc/news')); // ArchDaily router.get('/archdaily', require('./routes/archdaily/home')); +// aptonic Dropzone actions +router.get('/aptonic/action', require('./routes/aptonic/action')); + module.exports = router; diff --git a/lib/routes/aptonic/action.js b/lib/routes/aptonic/action.js new file mode 100644 index 0000000000..93f94b97f5 --- /dev/null +++ b/lib/routes/aptonic/action.js @@ -0,0 +1,34 @@ +const got = require('@/utils/got'); +const url = require('url'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const link = `https://aptonic.com/actions/`; + + const res = await got.get(link); + const $ = cheerio.load(res.body); + + ctx.state.data = { + title: 'Dropzone Actions', + link, + item: $('table.actions >> tr') + .get() + .map((item) => { + item = $(item); + return { + title: item.find('h2').text(), + description: ` + +
+ ${$(item.find('td')[1]) + .children() + .remove() + .end() + .text()} + `, + pubDate: new Date().toUTCString(), + link: url.resolve(link, item.find('td.icon a').attr('href')), + }; + }), + }; +};