feat(route): add 国家林业和草原局国家林草科技大讲堂 (#13650)

* chore(deps-dev): bump @tsconfig/docusaurus in /website (#686)

Bumps [@tsconfig/docusaurus](https://github.com/tsconfig/bases/tree/HEAD/bases) from 2.0.1 to 2.0.2.
- [Commits](https://github.com/tsconfig/bases/commits/HEAD/bases)

---
updated-dependencies:
- dependency-name: "@tsconfig/docusaurus"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat(route): add 国家林业和草原局国家林草科技大讲堂

* update gjlckjdjt.js

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
Ethan Shen 2023-10-29 22:09:40 +08:00 committed by GitHub
parent 4356fad91a
commit bd6528e9a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 182 additions and 0 deletions

View File

@ -0,0 +1,96 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
const { category = 'gjlckjdjt' } = ctx.params;
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30;
const rootUrl = 'http://www.forestry.gov.cn';
const currentUrl = new URL(`${category}.jhtml`, rootUrl).href;
const { data: response } = await got(currentUrl);
const $ = cheerio.load(response);
let items = $('a.items')
.slice(0, limit)
.toArray()
.map((item) => {
item = $(item);
const title = item.find('p.name').text();
const link = new URL(item.prop('href'), rootUrl).href;
const pubDateMatches = link.match(/\/\d{8}\//);
return {
title,
link,
description: art(path.join(__dirname, 'templates/description.art'), {
image: {
src: item.find('img').prop('src'),
alt: title,
},
}),
pubDate: pubDateMatches ? parseDate(pubDateMatches[1]) : undefined,
};
});
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = cheerio.load(detailResponse);
content('p').each((_, e) => {
e = content(e);
if (e.find('img, video, embed.edui-faked-video').length === 0 && e.text().match(/^\s*$/)) {
e.remove();
}
});
content('video, embed.edui-faked-video').each((_, e) => {
e = content(e);
const src = e.prop('src');
item.enclosure_url = item.enclosure_url ?? src;
e.replaceWith(
art(path.join(__dirname, 'templates/description.art'), {
video: {
src,
},
})
);
});
const pubDateMatches = item.link.match(/\/\d{8}\//);
item.title = content('div.tit').text();
item.description += content('div.zhengwen').html();
item.pubDate = pubDateMatches ? parseDate(pubDateMatches[1]) : undefined;
item.enclosure_type = item.enclosure_url ? 'video/mp4' : undefined;
return item;
})
)
);
const icon = new URL('favicon.ico', rootUrl).href;
ctx.state.data = {
item: items,
title: $('title').text(),
link: currentUrl,
language: $('html').prop('lang'),
image: new URL('r/cms/www/default/zhuanti/2021djt/images/top.png', rootUrl).href,
icon,
logo: icon,
subtitle: $('div.weizhi').contents().last().text(),
author: '国家林业和草原局',
allowEmpty: true,
};
};

View File

@ -0,0 +1,15 @@
{{ if image }}
<figure>
<img src="{{ image.src }}" alt="{{ image.alt }}">
</figure>
{{ /if }}
{{ if video }}
<video controls>
<source
src="{{ video.src }}">
<object data="{{ video.src }}">
<embed src="{{ video.src }}">
</object>
</video>
{{ /if }}

View File

@ -18,6 +18,7 @@ module.exports = {
'/csrc/news/:suffix*': ['chinobing', 'LogicJake'],
'/customs/list/:gchannel?': ['Jeason0228', 'TonyRL', 'he1q'],
'/fmprc/:category?': ['nicolaszf', 'nczitzk'],
'/forestry/gjlckjdjt/:category?': ['nczitzk'],
'/immiau/news': ['liu233w'],
'/jinan/healthcommission/medical_exam_notice': ['tzjyxb'],
'/mee/ywdt/:category?': ['liuxsdev'],

View File

@ -509,6 +509,58 @@ module.exports = {
},
],
},
'forestry.gov.cn': {
_name: '国家林业和草原局',
'.': [
{
title: '国家林草科技大讲堂',
docs: 'https://docs.rsshub.app/routes/government#guo-jia-lin-ye-he-cao-yuan-ju-guo-jia-lin-cao-ke-ji-da-jiang-tang',
source: ['gjlckjdjt.jhtml'],
target: (_, url) => {
url = new URL(url);
const path = url.href.match(/\/([\w]+)\.jhtml/)[1];
return `/gov/forestry/gjlckjdjt${path ? `/${path}` : ''}`;
},
},
{
title: '国家林草科技大讲堂 - 经济林',
docs: 'https://docs.rsshub.app/routes/government#guo-jia-lin-ye-he-cao-yuan-ju-guo-jia-lin-cao-ke-ji-da-jiang-tang',
source: ['jjl.jhtml'],
target: '/gov/forestry/gjlckjdjt/jjl',
},
{
title: '国家林草科技大讲堂 - 林木良种',
docs: 'https://docs.rsshub.app/routes/government#guo-jia-lin-ye-he-cao-yuan-ju-guo-jia-lin-cao-ke-ji-da-jiang-tang',
source: ['lmlz.jhtml'],
target: '/gov/forestry/gjlckjdjt/lmlz',
},
{
title: '国家林草科技大讲堂 - 林下经济',
docs: 'https://docs.rsshub.app/routes/government#guo-jia-lin-ye-he-cao-yuan-ju-guo-jia-lin-cao-ke-ji-da-jiang-tang',
source: ['lxjj.jhtml'],
target: '/gov/forestry/gjlckjdjt/lxjj',
},
{
title: '国家林草科技大讲堂 - 生态修复',
docs: 'https://docs.rsshub.app/routes/government#guo-jia-lin-ye-he-cao-yuan-ju-guo-jia-lin-cao-ke-ji-da-jiang-tang',
source: ['stxf.jhtml'],
target: '/gov/forestry/gjlckjdjt/stxf',
},
{
title: '国家林草科技大讲堂 - 用材林',
docs: 'https://docs.rsshub.app/routes/government#guo-jia-lin-ye-he-cao-yuan-ju-guo-jia-lin-cao-ke-ji-da-jiang-tang',
source: ['ycl.jhtml'],
target: '/gov/forestry/gjlckjdjt/ycl',
},
{
title: '国家林草科技大讲堂 - 其他',
docs: 'https://docs.rsshub.app/routes/government#guo-jia-lin-ye-he-cao-yuan-ju-guo-jia-lin-cao-ke-ji-da-jiang-tang',
source: ['qt.jhtml'],
target: '/gov/forestry/gjlckjdjt/qt',
},
],
},
'gaozhou.gov.cn': {
_name: '高州市人民政府',
www: [

View File

@ -10,6 +10,7 @@ module.exports = function (router) {
router.get('/csrc/news/:suffix*', require('./csrc/news'));
router.get('/customs/list/:gchannel?', require('./customs/list'));
router.get('/fmprc/:category?', require('./mfa/wjdt'));
router.get('/forestry/gjlckjdjt/:category?', require('./forestry/gjlckjdjt'));
router.get('/immiau/news', require('./immiau/news'));
router.get('/jinan/healthcommission/medical_exam_notice', require('./jinan/healthcommission/medical_exam_notice'));
router.get('/mee/ywdt/:category?', require('./mee/ywdt'));

View File

@ -475,6 +475,23 @@ Language
</Route>
## 国家林业和草原局 {#guo-jia-lin-ye-he-cao-yuan-ju}
### 国家林草科技大讲堂 {#guo-jia-lin-ye-he-cao-yuan-ju-guo-jia-lin-cao-ke-ji-da-jiang-tang}
<Route author="nczitzk" example="/gov/forestry/gjlckjdjt" path="/gov/forestry/gjlckjdjt/:category?" paramsDesc={['分类,见下表,默认为全部']} radar="1" rssbud="1">
| 分类 | id |
| -------- | ---- |
| 经济林 | jjl |
| 林木良种 | lmlz |
| 林下经济 | lxjj |
| 生态修复 | stxf |
| 用材林 | ycl |
| 其他 | qt |
</Route>
## 国家税务总局 {#guo-jia-shui-wu-zong-ju}
### 最新文件 {#guo-jia-shui-wu-zong-ju-zui-xin-wen-jian}