feat(route): add FossHub (#10266)
* feat(route): add FossHub * fix: add pubDate * fix: parseDate
This commit is contained in:
parent
8b04fef528
commit
9703916bce
|
|
@ -198,6 +198,12 @@ Language
|
|||
|
||||
<RouteEn author="DIYgod" example="/firefox/addons/rsshub-radar" path="/firefox/addons/:id" :paramsDesc="['Add-ons id, can be found in add-ons url']"/>
|
||||
|
||||
## FossHub
|
||||
|
||||
### Software Update
|
||||
|
||||
<RouteEn author="nczitzk" example="/fosshub/qBittorrent" path="/fosshub/:id" :paramsDesc="['Software id, can be found in URL']"/>
|
||||
|
||||
## Greasy Fork
|
||||
|
||||
### Script Update
|
||||
|
|
|
|||
|
|
@ -240,6 +240,12 @@ pageClass: routes
|
|||
|
||||
<Route author="DIYgod" example="/firefox/addons/rsshub-radar" path="/firefox/addons/:id" :paramsDesc="['附加组件 id, 可在应用页 URL 中找到']" />
|
||||
|
||||
## FossHub
|
||||
|
||||
### Software Update
|
||||
|
||||
<Route author="nczitzk" example="/fosshub/qBittorrent" path="/fosshub/:id" :paramsDesc="['软件 id,可在对应软件页 URL 中找到']"/>
|
||||
|
||||
## Greasy Fork
|
||||
|
||||
### 脚本更新
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id ?? '';
|
||||
|
||||
const rootUrl = 'https://www.fosshub.com';
|
||||
const currentUrl = `${rootUrl}/${id}.html`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const version = $('dd[itemprop="softwareVersion"]').first().text();
|
||||
|
||||
const items = [
|
||||
{
|
||||
title: version,
|
||||
link: `${currentUrl}#${version}`,
|
||||
description: art(path.join(__dirname, 'templates/description.art'), {
|
||||
links: $('.dwn-dl')
|
||||
.toArray()
|
||||
.map((l) =>
|
||||
$(l)
|
||||
.find('.w')
|
||||
.toArray()
|
||||
.map((w) => ({
|
||||
dt: $(w).find('dt').text(),
|
||||
dd: $(w).find('dd').html(),
|
||||
}))
|
||||
),
|
||||
changelog: $('div[itemprop="releaseNotes"]').html(),
|
||||
}),
|
||||
pubDate: parseDate($('.ma__upd .v').text(), 'MMM DD, YYYY'),
|
||||
},
|
||||
];
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${$('#fh-ssd__hl').text()} - FossHub`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/:id': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'fosshub.com': {
|
||||
_name: 'FossHub',
|
||||
'.': [
|
||||
{
|
||||
title: 'Software Update',
|
||||
docs: 'https://docs.rsshub.app/program-update.html#fosshub-software-update',
|
||||
source: ['/'],
|
||||
target: (params, url) => `/fosshub/${new URL(url).match(/\/(.*?)\.html$/)[1]}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/:id', require('./index'));
|
||||
};
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<table>
|
||||
<tbody>
|
||||
{{ each links link }}
|
||||
<tr>
|
||||
{{ each link l }}
|
||||
<th>{{ l.dt }}</th>
|
||||
{{ /each }}
|
||||
<tr>
|
||||
<tr>
|
||||
{{ each link l }}
|
||||
<td>{{@ l.dd }}</td>
|
||||
{{ /each }}
|
||||
<tr>
|
||||
{{ /each }}
|
||||
</tbody>
|
||||
</table>
|
||||
{{ if changelog }}
|
||||
<br>
|
||||
{{@ changelog }}
|
||||
{{ /if }}
|
||||
Loading…
Reference in New Issue