Skip to content

Commit

Permalink
feat(route): trending papers on arXiv from trendingpapers (#14182)
Browse files Browse the repository at this point in the history
  • Loading branch information
CookiePieWw authored Jan 10, 2024
1 parent 1cf341f commit 72067b5
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/v2/trendingpapers/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/papers/:category?/:time?/:cited?': ['CookiePieWw'],
};
42 changes: 42 additions & 0 deletions lib/v2/trendingpapers/papers.js
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,
};
};
11 changes: 11 additions & 0 deletions lib/v2/trendingpapers/radar.js
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',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/trendingpapers/router.js
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'));
};
6 changes: 6 additions & 0 deletions website/docs/routes/journal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,12 @@ You can get all short name of a journal from [https://www.nature.com/siteindex](

<Route author="TonyRL" example="/uchicago/journals/current/jpe" path="/uchicago/journals/current/:journal" paramsDesc={['Journal id, can be found in URL. [Browse journals by title](https://www.journals.uchicago.edu/action/showPublications)']} radar="1" anticrawler="1" />

## Trending Papers {#trending-papers}

### Trending Papers on arXiv {#trending-papers-trending-papers-on-arxiv}

<Route author="CookiePieWw" example="/trendingpapers/papers" path="/trendingpapers/papers/:category?/:time?/:cited?" paramsDesc={['Category of papers, can be found in URL. `All categories` by default.', 'Time like `24 hours` to specify the duration of ranking, can be found in URL. `Since beginning` by default.', 'Cited or uncited papers, can be found in URL. `Cited and uncited papers` by default.']} />

## USENIX {#usenix}

### Security Symposia {#usenix-security-symposia}
Expand Down

0 comments on commit 72067b5

Please sign in to comment.