feat: include untested Dropzone actions (#5176)
This commit is contained in:
@@ -28,7 +28,7 @@ pageClass: routes
|
||||
|
||||
### New Dropzone Actions
|
||||
|
||||
<RouteEn author="HenryQW" example="/aptonic/action" path="/aptonic/action"/>
|
||||
<RouteEn author="HenryQW" example="/aptonic/action" path="/aptonic/action/:untested?" :paramsDesc="['Set any value to include untested actions.']"/>
|
||||
|
||||
## Chocolatey
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ pageClass: routes
|
||||
|
||||
### 新的 Dropzone 动作
|
||||
|
||||
<Route author="HenryQW" example="/aptonic/action" path="/aptonic/action"/>
|
||||
<Route author="HenryQW" example="/aptonic/action" path="/aptonic/action/:untested?" :paramsDesc="['填写任意值,将会同时包括非官方的 Dropzone 动作']"/>
|
||||
|
||||
## Bugly SDK
|
||||
|
||||
|
||||
+1
-1
@@ -1768,7 +1768,7 @@ router.get('/tprtc/news', require('./routes/tprtc/news'));
|
||||
router.get('/archdaily', require('./routes/archdaily/home'));
|
||||
|
||||
// aptonic Dropzone actions
|
||||
router.get('/aptonic/action', require('./routes/aptonic/action'));
|
||||
router.get('/aptonic/action/:untested?', require('./routes/aptonic/action'));
|
||||
|
||||
// 印记中文周刊
|
||||
router.get('/docschina/jsweekly', require('./routes/docschina/jsweekly'));
|
||||
|
||||
@@ -3,28 +3,36 @@ const url = require('url');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = `https://aptonic.com/actions/`;
|
||||
const untested = ctx.params.untested || false;
|
||||
|
||||
const res = await got.get(link);
|
||||
const $ = cheerio.load(res.body);
|
||||
const getItems = async (link) => {
|
||||
const res = await got.get(link);
|
||||
const $ = cheerio.load(res.body);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Dropzone Actions',
|
||||
link,
|
||||
item: $('table.actions >> tr')
|
||||
return $('table.actions >> tr')
|
||||
.get()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.find('h2').text(),
|
||||
description: `
|
||||
<img src="${url.resolve(link, item.find('img').attr('src'))}"/>
|
||||
<br/>
|
||||
${$(item.find('td')[1]).children().remove().end().text()}
|
||||
`,
|
||||
description: `<img src="${url.resolve(link, item.find('img').attr('src'))}"/><br/>${$(item.find('td')[1]).children().remove().end().text()}`,
|
||||
pubDate: new Date().toUTCString(),
|
||||
link: url.resolve(link, item.find('td.icon a').attr('href')),
|
||||
};
|
||||
}),
|
||||
});
|
||||
};
|
||||
|
||||
const link = `https://aptonic.com/actions/`;
|
||||
|
||||
const items = await getItems(link);
|
||||
|
||||
if (untested) {
|
||||
items.push(...(await getItems('https://aptonic.com/actions/untested')));
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Dropzone Actions',
|
||||
link,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user