-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route): trending papers on arXiv from trendingpapers (#14182)
- Loading branch information
1 parent
1cf341f
commit 72067b5
Showing
5 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/papers/:category?/:time?/:cited?': ['CookiePieWw'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const got = require('@/utils/got'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const { time = 'Since beginning', cited = 'Cited and uncited papers', category = 'All categories' } = ctx.params; | ||
|
||
const rootUrl = 'https://trendingpapers.com'; | ||
const currentUrl = `${rootUrl}/api/papers?p=1&o=pagerank_growth&pd=${time}&cc=${cited}&c=${category}`; | ||
|
||
const response = await got({ | ||
method: 'get', | ||
url: currentUrl, | ||
}); | ||
|
||
const $ = response.data; | ||
|
||
const papers = $.data | ||
.map((_) => { | ||
const title = _.title; | ||
const abstract = _.abstract; | ||
const url = _.url; | ||
const arxivId = _.arxiv_id; | ||
|
||
const pubDate = parseDate(_.pub_date); | ||
const summaryCategories = _.summary_categories; | ||
|
||
return { | ||
title, | ||
description: abstract, | ||
link: url, | ||
guid: arxivId, | ||
pubDate, | ||
category: summaryCategories, | ||
}; | ||
}); | ||
|
||
ctx.state.data = { | ||
title: `Trending Papers on arXiv.org | ${category} | ${time} | ${cited} | `, | ||
link: currentUrl, | ||
item: papers, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = { | ||
'trendingpapers.com': { | ||
_name: 'trendingpapers', | ||
'.': [ | ||
{ | ||
title: 'Trending Papers on arXiv', | ||
docs: 'https://docs.rsshub.app/routes/journal#trending-papers-trending-papers-on-arxiv', | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = (router) => { | ||
router.get('/papers/:category?/:time?/:cited?', require('./papers.js')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters