feat(route): Add dblp and format my code (#12620)

* Add dblp and format my code

* Add rule files for the dblp

* doi has been set in publication.js

* update files

* update files

* doi has been set in publication.js
This commit is contained in:
ytno1
2023-06-07 14:18:55 +08:00
committed by GitHub
parent 6b1b35de8f
commit 4f9262cd88
6 changed files with 101 additions and 0 deletions
+6
View File
@@ -24,6 +24,12 @@ pageClass: routes
<RouteEn author="HankChow" example="/cssn/iolaw/zxzp" path="/cssn/iolaw/:section?" :paramsDesc="['Section ID, can be found in the URL. For example, the Section ID of URL `http://iolaw.cssn.cn/zxzp/` is `zxzp`. The default value is `zxzp`']"/>
## DBLP
### Keyword Search
<RouteEn author="ytno1" example="/dblp/knowledge%20tracing" path="/dblp/:field" :paramsDesc="['Research field']" radar="1" />
## gradCafe
### gradCafe result
+6
View File
@@ -85,6 +85,12 @@ path="/ctfhub/upcoming/:limit?"
</Route>
## DBLP
### 关键字搜索
<Route author="ytno1" example="/dblp/knowledge%20tracing" path="/dblp/:field" :paramsDesc="['研究领域']" radar="1" />
## gradCafe
### gradCafe result
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/:field': ['ytno1'],
};
+70
View File
@@ -0,0 +1,70 @@
// 导入所需模组
const got = require('@/utils/got'); // 自订的 got
// const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
// 在此处编写您的逻辑
const field = ctx.params.field;
// 发送 HTTP GET 请求到 API 并解构返回的数据对象
const {
result: {
hits: { hit: data },
},
} = await got({
method: 'get',
url: 'https://dblp.org/search/publ/api',
searchParams: {
q: field,
format: 'json',
h: 10,
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
},
}).json();
// console.log(data);
// 从 API 响应中提取相关数据
const list = data.map((item) => {
const { info } = item;
// console.log(info);
const {
authors: { author },
title,
venue,
year,
type,
doi,
ee,
} = info;
let authorName;
if (Array.isArray(author)) {
authorName = author[0].text;
} else {
authorName = author.text;
}
return {
title,
link: ee,
author: `${authorName} et al.`,
doi,
description: `Year: ${year ?? 'unknown'}, Venue: ${venue}, Type: ${type}, Doi: ${doi}`,
};
});
ctx.state.data = {
// 在此处输出您的 RSS
// 源标题
title: `【dblp】${field}`,
// 源链接
link: `https://dblp.org/search?q=${field}`,
// 源描述
description: `DBLP ${field} RSS`,
// 处理后的数据,即文章列表
item: list,
};
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'dblp.org': {
_name: 'DBLP',
'.': [
{
title: '关键字搜索',
docs: 'https://docs.rsshub.app/study.html#dblp',
source: ['/:field'],
target: '/dblp/:field',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/:field', require('./publication'));
};