Skip to content

Commit

Permalink
modified en.ts and news.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
endme2085 committed May 21, 2024
1 parent a4f76f5 commit 0070434
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
23 changes: 8 additions & 15 deletions lib/routes/shisu/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,13 @@ import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';

const url = 'http://en.shisu.edu.cn';
const url_backup = 'https://en.shisu.edu.cn';
const urlBackup = 'https://en.shisu.edu.cn';

export const route: Route = {
path: '/en/:section',
categories: ['university'],
example: '/shisu/en/news',
parameters: { section: 'The name of resources' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['en.shisu.edu.cn/resources/:section/'],
Expand All @@ -30,7 +22,7 @@ export const route: Route = {
maintainers: ['Duuckjing'],
handler,
description: `- features: Read a series of in-depth stories about SISU faculty, students, alumni and beyond campus.
- news: SISU TODAY English site.`,
- news: SISU TODAY English site.`,
};

async function process(baseUrl: string, section: any) {
Expand All @@ -56,14 +48,15 @@ async function process(baseUrl: string, section: any) {
const $ = load(r);
j.description = $('.details-con')
.html()!
.replaceAll(/<o:p>[\S\s]*?<\/o:p>/g, '');
.replaceAll(/<o:p>[\S\s]*?<\/o:p>/g, '')
.replaceAll(/(<p[^>]*>&nbsp;<\/p>\s*)+/gm, '<p>&nbsp;</p>');
return j;
})
)
);
return {
title: 'FEATURED STORIES',
link: `${url}/resources/features/`,
title: String(section) === 'features' ? 'FEATURED STORIES' : 'SISU TODAY',
link: `${url}/resources/${section}/`,
item: items,
};
}
Expand All @@ -75,8 +68,8 @@ async function handler(ctx) {
await ofetch(url);
res = process(url, section);
} catch {
await ofetch(url_backup);
res = process(url_backup, section);
await ofetch(urlBackup);
res = process(urlBackup, section);
}
return res;
}
6 changes: 3 additions & 3 deletions lib/routes/shisu/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export const route: Route = {
maintainers: ['Duuckjing'],
handler,
description: `| 首页 | 特稿 | 学术 | 教学 | 国际 | 校园 | 人物 | 视讯 | 公告 |
| ---- | ------- | --------- | ---------- | ------------- | ------ | ------ | ---------- | ------ |
| news | gazette | research- | academics- | international | campus | people | multimedia | notice |`,
| ---- | ------- | --------- | ---------- | ------------- | ------ | ------ | ---------- | ------ |
| news | gazette | research- | academics- | international | campus | people | multimedia | notice |`,
};

async function handler(ctx) {
Expand Down Expand Up @@ -84,7 +84,7 @@ async function handler(ctx) {
);

return {
title: `上外新闻|SISU TODAY -${section.charAt(0).toUpperCase() + section.slice(1)}`,
title: `上外新闻|SISU TODAY - ${section.charAt(0).toUpperCase() + section.slice(1)}`,
image: 'https://upload.wikimedia.org/wikipedia/zh/thumb/0/06/Shanghai_International_Studies_University_logo.svg/300px-Shanghai_International_Studies_University_logo.svg.png',
link: `${url}/${section}/index.html`,
item: items,
Expand Down

0 comments on commit 0070434

Please sign in to comment.