From 65f09c7ae24c9571437815dff292e2a124d9bfd8 Mon Sep 17 00:00:00 2001 From: KTachibanaM Date: Mon, 26 Feb 2024 01:39:36 -0800 Subject: [PATCH] feat(route): add unraid community apps (#14564) * add unraid community apps feed * unraid ca support limit query parameter --- lib/v2/unraid/community-apps.js | 35 ++++++++++++++++++++++++++ lib/v2/unraid/maintainer.js | 3 +++ lib/v2/unraid/radar.js | 13 ++++++++++ lib/v2/unraid/router.js | 3 +++ website/docs/routes/program-update.mdx | 6 +++++ 5 files changed, 60 insertions(+) create mode 100644 lib/v2/unraid/community-apps.js create mode 100644 lib/v2/unraid/maintainer.js create mode 100644 lib/v2/unraid/radar.js create mode 100644 lib/v2/unraid/router.js diff --git a/lib/v2/unraid/community-apps.js b/lib/v2/unraid/community-apps.js new file mode 100644 index 000000000..c19834469 --- /dev/null +++ b/lib/v2/unraid/community-apps.js @@ -0,0 +1,35 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); + +const appFeedUrl = 'https://raw.githubusercontent.com/Squidly271/AppFeed/master/applicationFeed.json'; +const defaultLimit = 20; + +module.exports = async (ctx) => { + const { data } = await got(appFeedUrl); + const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : defaultLimit; + + let appList = data.applist; + appList = appList.map((app) => { + const _pubDate = app.LastUpdate ?? app.FirstSeen ?? 0; + return { + ...app, + _pubDate, + }; + }); + appList.sort((a, b) => b._pubDate - a._pubDate); + const returnedAppList = appList.slice(0, limit); + + ctx.state.data = { + title: 'Unraid Community Apps', + link: 'https://unraid.net/community/apps', + image: 'https://craftassets.unraid.net/static/favicon/favicon.ico?v=1.0', + item: returnedAppList.map((app) => ({ + title: `${app.Name} (${app.Repository ?? 'Unknown repository'})`, + link: app.Registry ?? `https://unraid.net/community/apps?q=${app.Name}`, + description: app.Overview.replaceAll('\r\n', '
').replaceAll('\n', '
').replaceAll('[br]', '
'), + pubDate: parseDate(app._pubDate * 1000), + category: app.CategoryList, + upvotes: app.stars, + })), + }; +}; diff --git a/lib/v2/unraid/maintainer.js b/lib/v2/unraid/maintainer.js new file mode 100644 index 000000000..159db7249 --- /dev/null +++ b/lib/v2/unraid/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/community-apps': ['KTachibanaM'], +}; diff --git a/lib/v2/unraid/radar.js b/lib/v2/unraid/radar.js new file mode 100644 index 000000000..58de116d8 --- /dev/null +++ b/lib/v2/unraid/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'unraid.net': { + _name: 'Unraid', + '.': [ + { + title: 'Community Apps', + docs: 'https://docs.rsshub.app/routes/program-update#unraid', + source: ['/community/apps'], + target: '/unraid/community-apps', + }, + ], + }, +}; diff --git a/lib/v2/unraid/router.js b/lib/v2/unraid/router.js new file mode 100644 index 000000000..6aa87f760 --- /dev/null +++ b/lib/v2/unraid/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/community-apps', require('./community-apps')); +}; diff --git a/website/docs/routes/program-update.mdx b/website/docs/routes/program-update.mdx index f67d994fd..bbfe64f4f 100644 --- a/website/docs/routes/program-update.mdx +++ b/website/docs/routes/program-update.mdx @@ -643,6 +643,12 @@ Logseq 开发团队已经放弃了 [旧网站](https://logseq.com/blog)。 +## Unraid {#unraid} + +### Community Apps {#unraid-community-apps} + + + ## Western Digital {#western-digital} ### Download {#western-digital-download}