From 72067b58114aa2b9c71c1624f260addb882774da Mon Sep 17 00:00:00 2001
From: Yohan Wal <59358312+CookiePieWw@users.noreply.github.com>
Date: Thu, 11 Jan 2024 01:09:48 +0800
Subject: [PATCH] feat(route): trending papers on arXiv from trendingpapers
(#14182)
---
lib/v2/trendingpapers/maintainer.js | 3 +++
lib/v2/trendingpapers/papers.js | 42 +++++++++++++++++++++++++++++
lib/v2/trendingpapers/radar.js | 11 ++++++++
lib/v2/trendingpapers/router.js | 3 +++
website/docs/routes/journal.mdx | 6 +++++
5 files changed, 65 insertions(+)
create mode 100644 lib/v2/trendingpapers/maintainer.js
create mode 100644 lib/v2/trendingpapers/papers.js
create mode 100644 lib/v2/trendingpapers/radar.js
create mode 100644 lib/v2/trendingpapers/router.js
diff --git a/lib/v2/trendingpapers/maintainer.js b/lib/v2/trendingpapers/maintainer.js
new file mode 100644
index 00000000000000..acfb2d231fc1eb
--- /dev/null
+++ b/lib/v2/trendingpapers/maintainer.js
@@ -0,0 +1,3 @@
+module.exports = {
+ '/papers/:category?/:time?/:cited?': ['CookiePieWw'],
+};
diff --git a/lib/v2/trendingpapers/papers.js b/lib/v2/trendingpapers/papers.js
new file mode 100644
index 00000000000000..f7cb8dd42bb442
--- /dev/null
+++ b/lib/v2/trendingpapers/papers.js
@@ -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,
+ };
+};
diff --git a/lib/v2/trendingpapers/radar.js b/lib/v2/trendingpapers/radar.js
new file mode 100644
index 00000000000000..243533c9d347ec
--- /dev/null
+++ b/lib/v2/trendingpapers/radar.js
@@ -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',
+ },
+ ],
+ },
+};
diff --git a/lib/v2/trendingpapers/router.js b/lib/v2/trendingpapers/router.js
new file mode 100644
index 00000000000000..d85cef26aef88d
--- /dev/null
+++ b/lib/v2/trendingpapers/router.js
@@ -0,0 +1,3 @@
+module.exports = (router) => {
+ router.get('/papers/:category?/:time?/:cited?', require('./papers.js'));
+};
diff --git a/website/docs/routes/journal.mdx b/website/docs/routes/journal.mdx
index f402a34ba8851a..4005e364838798 100644
--- a/website/docs/routes/journal.mdx
+++ b/website/docs/routes/journal.mdx
@@ -462,6 +462,12 @@ You can get all short name of a journal from [https://www.nature.com/siteindex](
+## Trending Papers {#trending-papers}
+
+### Trending Papers on arXiv {#trending-papers-trending-papers-on-arxiv}
+
+
+
## USENIX {#usenix}
### Security Symposia {#usenix-security-symposia}