Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(route): hex-rays news pubDate and author #8202

Merged
merged 5 commits into from
Jan 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2513,8 +2513,8 @@ router.get('/galaxylab', lazyloadRouteHandler('./routes/galaxylab/index'));
// NOSEC 安全讯息平台
router.get('/nosec/:keykind?', lazyloadRouteHandler('./routes/nosec/index'));

// Hex-Rays News
router.get('/hex-rays/news', lazyloadRouteHandler('./routes/hex-rays/index'));
// Hex-Rays News migrated to v2
// router.get('/hex-rays/news', lazyloadRouteHandler('./routes/hex-rays/index'));

// 新趣集
router.get('/xinquji/today', lazyloadRouteHandler('./routes/xinquji/today'));
Expand Down
28 changes: 0 additions & 28 deletions lib/routes/hex-rays/index.js

This file was deleted.

47 changes: 47 additions & 0 deletions lib/v2/hex-rays/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const link = 'https://www.hex-rays.com/blog/';
const response = await got.get(link);
const $ = cheerio.load(response.data);

const list = $('.post-list-container')
.map((_, ele) => ({
title: $('h3 > a', ele).text(),
link: $('h3 > a', ele).attr('href'),
pubDate: parseDate($('.post-meta:nth-of-type(1)', ele).first().text().trim().replace('Posted on:', '')),
author: $('.post-meta:nth-of-type(2)', ele).first().text().replace('By:', '').trim(),
}))
.get();

const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got.get(item.link);
const content = cheerio.load(detailResponse.data);

item.category = (
content('.category-link')
.toArray()
.map((e) => $(e).text()) +
',' +
content('.tag-link')
.toArray()
.map((e) => $(e).text())
).split(',');

item.description = content('.post-content').html();

return item;
})
)
);

ctx.state.data = {
title: 'Hex-Rays Blog',
link,
item: items,
};
};
3 changes: 3 additions & 0 deletions lib/v2/hex-rays/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/news': ['hellodword ', 'TonyRL'],
};
13 changes: 13 additions & 0 deletions lib/v2/hex-rays/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'hex-rays.com': {
_name: 'Hex-Rays',
'.': [
{
title: 'Hex-Rays News',
docs: 'https://docs.rsshub.app/programming.html#hex-rays',
source: ['/', '/blog'],
target: '/hex-rays/news',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/hex-rays/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/news', require('./index'));
};