refactor(route): migrate greasyfork to v2 (#10655)

* feat(route): migrate greasyfork to v2

* fix(route): maintainer path
This commit is contained in:
miles
2022-08-30 19:36:29 +08:00
committed by GitHub
parent e1efae05fe
commit e6341a512c
7 changed files with 27 additions and 8 deletions
+1 -1
View File
@@ -236,7 +236,7 @@ Language
### Script Update
<RouteEn author="imlonghao" path="/greasyfork/:language/:domain?" example="/greasyfork/en/google.com" :paramsDesc="['language, located on the top right corner of Greasy Fork\'s search page, set to `all` for including all languages', 'the script\'s target domain']" />
<RouteEn author="imlonghao" path="/greasyfork/:language/:domain?" example="/greasyfork/en/google.com" :paramsDesc="['language, located on the top right corner of Greasy Fork\'s search page, set to `all` for including all languages', 'the script\'s target domain']" radar="1" />
## Hugo
+1 -1
View File
@@ -268,7 +268,7 @@ pageClass: routes
### 脚本更新
<Route author="imlonghao" example="/greasyfork/zh-CN/bilibili.com" path="/greasyfork/:language/:domain?" :paramsDesc="['语言, 可在网站右上角找到, `all` 为所有语言', '按脚本生效域名过滤, 可选']"/>
<Route author="imlonghao" example="/greasyfork/zh-CN/bilibili.com" path="/greasyfork/:language/:domain?" :paramsDesc="['语言, 可在网站右上角找到, `all` 为所有语言', '按脚本生效域名过滤, 可选']" radar="1"/>
## Hugo
+2 -2
View File
@@ -387,8 +387,8 @@ router.get('/xuangubao/subject/:subject_id', lazyloadRouteHandler('./routes/xuan
// router.get('/xueqiu/hots', lazyloadRouteHandler('./routes/xueqiu/hots'));
// router.get('/xueqiu/stock_comments/:id/:titleLength?', lazyloadRouteHandler('./routes/xueqiu/stock_comments'));
// Greasy Fork
router.get('/greasyfork/:language/:domain?', lazyloadRouteHandler('./routes/greasyfork/scripts'));
// Greasy Fork migrated to v2
// router.get('/greasyfork/:language/:domain?', lazyloadRouteHandler('./routes/greasyfork/scripts'));
// Gwern Bran­wen
router.get('/gwern/:category', lazyloadRouteHandler('./routes/gwern/category'));
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/:language/:domain?': ['imlonghao', 'miles170'],
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'greasyfork.org': {
_name: 'Greasy Fork',
'.': [
{
title: 'User scripts',
docs: 'https://docs.rsshub.app/program-update.html#greasy-fork',
source: ['/:language', '/:language/scripts/by-site/:domain?'],
target: '/greasyfork/:language/:domain?',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/:language/:domain?', require('./scripts'));
};
@@ -7,10 +7,10 @@ module.exports = async (ctx) => {
const domain = ctx.params.domain;
const filter_locale = ctx.params.language === 'all' ? 0 : 1;
const url = domain ? `by-site/${domain}` : '';
const currentUrl = `https://greasyfork.org/${language}/scripts/${url}`;
const res = await got({
method: 'get',
url: `https://greasyfork.org/${language}/scripts/${url}`,
url: currentUrl,
searchParams: queryString.stringify({
filter_locale,
sort: 'updated',
@@ -21,12 +21,12 @@ module.exports = async (ctx) => {
ctx.state.data = {
title: $('title').first().text(),
link: `https://greasyfork.org/${language}/scripts/${url}`,
link: currentUrl,
description: $('meta[name=description]').attr('content'),
item:
list &&
list
.map((index, item) => {
.map((_, item) => {
item = $(item);
return {
title: item.find('a').text(),