Skip to content

Commit

Permalink
feat(route): keepass (#14301)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyRL authored Jan 22, 2024
1 parent b50d1d7 commit f965e0b
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/v2/keepass/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/': ['TonyRL'],
};
46 changes: 46 additions & 0 deletions lib/v2/keepass/news.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const baseUrl = 'https://keepass.info/news/news_all.html';
const { data: response } = await got(baseUrl);
const $ = cheerio.load(response);

const list = $('p > a')
.toArray()
.map((elem) => {
elem = $(elem);
return {
title: elem.find('b').text(),
link: new URL(elem.attr('href'), baseUrl).href,
pubDate: parseDate(elem.next().next('small').text().split('.')[0]),
};
})
.slice(0, ctx.query.limit ? Number.parseInt(ctx.query.limit, 10) : 10);

const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
if (!item.link.startsWith('https://keepass.info/')) {
return item;
}

const { data } = await got(item.link);
const $ = cheerio.load(data);

$('.sectionheader').remove();
$('.laytablews > tbody> tr:nth-child(1) > td:nth-child(2) > p').first().remove();

item.description = $('.laytablews > tbody> tr:nth-child(1) > td:nth-child(2)').html();
return item;
})
)
);

ctx.state.data = {
title: $('head title').attr('content'),
link: baseUrl,
item: items,
};
};
13 changes: 13 additions & 0 deletions lib/v2/keepass/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'keepass.info': {
_name: 'KeePass',
'.': [
{
title: 'News',
docs: 'https://docs.rsshub.app/routes/program-update.html#keepass',
source: ['/news/news_all.html', '/'],
target: '/keepass/news',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/keepass/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/', require('./news'));
};
6 changes: 6 additions & 0 deletions website/docs/routes/program-update.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ Need to configure `CIVITAI_COOKIE` to obtain image information of NSFW models.

<Route author="Jeason0228" example="/ipsw/index/ipsws/iPhone11,8" path="/ipsw/index/:ptype/:pname/" paramsDesc={['Fill in ipsws or otas to get different versions of firmware','Product name, `http://rsshub.app/ipsw/index/ipsws/iPod`, if you fill in the iPad, follow the entire iPad series(ptype default to ipsws).`http://rsshub.app/ipsw/index/ipsws/iPhone11,8`, if you fill in the specific iPhone11,8, submit to the ipsws firmware information of this model']} />

## KeePass {#keepass}

### News {#keepass-news}

<Route author="TonyRL" example="/keepass" path="/keepass" radar="1" />

## Logseq {#logseq}

:::warning
Expand Down

0 comments on commit f965e0b

Please sign in to comment.