Skip to content

Commit 435c1ae

Browse files
authored
Merge pull request #865 from DIYgod/master
[pull] master from diygod:master
2 parents 2d1b99e + f4997c4 commit 435c1ae

29 files changed

+514
-23
lines changed

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.devcontainer
12
.github
23
.idea
34
.vscode
@@ -16,11 +17,13 @@ test
1617
.env
1718
.eslint*
1819
.gitignore
20+
.gitpod.yml
1921
.prettier*
2022
.(yarn|npm|nvm)rc
2123
*.md
2224
app.json
2325
docker-compose*
26+
fly.toml
2427
jsconfig.json
2528
npm-debug.log
2629
process.json
@@ -33,3 +36,7 @@ vercel.json
3336
.git/index
3437
.git/info
3538
.git/hooks
39+
40+
#rsshub auxiliary files
41+
lib/radar-rules.js
42+
lib/v2/**/radar.js

.puppeteerrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const { join } = require('path');
2+
3+
/**
4+
* @type {import("puppeteer").Configuration}
5+
*/
6+
module.exports = {
7+
// Changes the cache location for Puppeteer.
8+
cacheDirectory: join(__dirname, 'node_modules', '.cache', 'puppeteer'),
9+
};

Dockerfile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,14 @@ FROM node:16-bullseye-slim as chromium-downloader
7979
# Yeah, downloading Chromium never needs those dependencies below.
8080

8181
WORKDIR /app
82+
COPY ./.puppeteerrc.js /app/
8283
COPY --from=dep-version-parser /ver/.puppeteer_version /app/.puppeteer_version
8384

8485
ARG TARGETPLATFORM
8586
ARG USE_CHINA_NPM_REGISTRY=0
8687
ARG PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
8788
# The official recommended way to use Puppeteer on x86(_64) is to use the bundled Chromium from Puppeteer:
88-
# https://github.com/puppeteer/puppeteer#q-why-doesnt-puppeteer-vxxx-work-with-chromium-vyyy
89+
# https://pptr.dev/faq#q-why-doesnt-puppeteer-vxxx-work-with-chromium-vyyy
8990
RUN \
9091
set -ex ; \
9192
if [ "$PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" = 0 ] && [ "$TARGETPLATFORM" = 'linux/amd64' ]; then \
@@ -98,7 +99,7 @@ RUN \
9899
yarn add puppeteer@$(cat /app/.puppeteer_version) && \
99100
yarn cache clean ; \
100101
else \
101-
mkdir -p /root/.cache/puppeteer ; \
102+
mkdir -p /app/node_modules/.cache/puppeteer ; \
102103
fi;
103104

104105
# ---------------------------------------------------------------------------------------------------------------------
@@ -115,11 +116,11 @@ WORKDIR /app
115116
# install deps first to avoid cache miss or disturbing buildkit to build concurrently
116117
ARG TARGETPLATFORM
117118
ARG PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
118-
# https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-unix
119+
# https://pptr.dev/troubleshooting#chrome-headless-doesnt-launch-on-unix
119120
# https://github.com/puppeteer/puppeteer/issues/7822
120121
# https://www.debian.org/releases/bullseye/amd64/release-notes/ch-information.en.html#noteworthy-obsolete-packages
121122
# The official recommended way to use Puppeteer on arm/arm64 is to install Chromium from the distribution repositories:
122-
# https://github.com/puppeteer/puppeteer/blob/94cb08c85955c0688d12b6ed10e61a4581a01280/src/node/BrowserFetcher.ts#L116-L119
123+
# https://github.com/puppeteer/puppeteer/blob/07391bbf5feaf85c191e1aa8aa78138dce84008d/packages/puppeteer-core/src/node/BrowserFetcher.ts#L128-L131
123124
RUN \
124125
set -ex && \
125126
apt-get update && \
@@ -143,14 +144,14 @@ RUN \
143144
fi; \
144145
rm -rf /var/lib/apt/lists/*
145146

146-
COPY --from=chromium-downloader /root/.cache/puppeteer /root/.cache/puppeteer
147+
COPY --from=chromium-downloader /app/node_modules/.cache/puppeteer /app/node_modules/.cache/puppeteer
147148

148149
# if grep matches nothing then it will exit with 1, thus, we cannot `set -e` here
149150
RUN \
150151
set -x && \
151152
if [ "$PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" = 0 ] && [ "$TARGETPLATFORM" = 'linux/amd64' ]; then \
152153
echo 'Verifying Chromium installation...' && \
153-
ldd $(find /root/.cache/puppeteer/ -name chrome) | grep "not found" ; \
154+
ldd $(find /app/node_modules/.cache/puppeteer/ -name chrome -type f) | grep "not found" ; \
154155
if [ "$?" = 0 ]; then \
155156
echo "!!! Chromium has unmet shared libs !!!" && \
156157
exit 1 ; \
@@ -177,7 +178,7 @@ CMD ["npm", "run", "start"]
177178
# apt-file \
178179
# && \
179180
# apt-file update && \
180-
# ldd $(find /app/node_modules/puppeteer/ -name chrome) | grep -Po "\S+(?= => not found)" | \
181+
# ldd $(find /app/node_modules/.cache/puppeteer/ -name chrome -type f) | grep -Po "\S+(?= => not found)" | \
181182
# sed 's/\./\\./g' | awk '{print $1"$"}' | apt-file search -xlf - | grep ^lib | \
182183
# xargs -d '\n' -- \
183184
# apt-get install -yq --no-install-recommends \

docs/anime.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,22 @@ Sources
436436

437437
<Route author="aether17" path="/thwiki/calendar/:before?/:after?" example="/thwiki/calendar" :paramsDesc="['从多少天前(默认30)', '到多少天后(默认30)']" radar="1" rssbud="1"/>
438438

439+
## VCB-Studio
440+
441+
### 最新文章
442+
443+
<Route author="cxfksword" example="/vcb-s" path="/vcb-s" radar="1"/>
444+
445+
### 分类文章
446+
447+
<Route author="cxfksword" example="/vcb-s/category/works" path="/vcb-s/category/:cate" :paramsDesc="['分类']" radar="1">
448+
449+
| 作品项目 | 科普系列 | 计划与日志 |
450+
| ----- | ---- | ------- |
451+
| works | kb | planlog |
452+
453+
</Route>
454+
439455
## Vol.moe
440456

441457
### vol

docs/en/reading.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ Eg:<https://kakuyomu.jp/works/1177354054883783581>
5656

5757
<RouteEn author="nczitzk" example="/literotica/category/anal-sex-stories" path="/literotica/category/:category?" :paramsDesc="['Category, can be found in URL']"/>
5858

59+
## MagazineLib
60+
61+
### Latest Magazine
62+
63+
<RouteEn author="NavePnow" example="/magazinelib/latest-magazine/new+yorker" path="/magazinelib/latest-magazine/:query?" :paramsDesc="['query, search page querystring']"/>
64+
65+
For instance, when doing search at <https://magazinelib.com/> and you get url <https://magazinelib.com/?s=new+yorker>, the query is `new+yorker`
66+
67+
</RouteEn>
68+
5969
## Mobilism
6070

6171
### eBook Releases

docs/new-media.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3331,6 +3331,12 @@ column 为 third 时可选的 category:
33313331

33323332
</Route>
33333333

3334+
## 千篇网
3335+
3336+
### 知识库/资讯
3337+
3338+
<Route author="TonyRL" example="/qianp/news" path="/qianp/news/:path*" :paramsDesc="['路径,可在URL中找到,默认为 `news/recommend`']" radar="1" rssbud="1"/>
3339+
33343340
## 求是网
33353341

33363342
### 分类

docs/reading.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ pageClass: routes
6767

6868
<Route author="nczitzk" example="/literotica/category/anal-sex-stories" path="/literotica/category/:category?" :paramsDesc="['分类,可在对应分类页地址栏中找到']"/>
6969

70+
## MagazineLib
71+
72+
### Latest Magazine
73+
74+
<Route author="NavePnow" example="/magazinelib/latest-magazine/new+yorker" path="/magazinelib/latest-magazine/:query?" :paramsDesc="['query,search page querystring']"/>
75+
76+
For instance, when doing search at <https://magazinelib.com/> and you get url <https://magazinelib.com/?s=new+yorker>, the query is `new+yorker`
77+
78+
</Route>
79+
7080
## Mobilism
7181

7282
### 电子书

docs/traditional-media.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2570,3 +2570,15 @@ category 对应的关键词有
25702570
`https://www.rfa.org/cantonese/news/htm` 对应 `/rfa/cantonese/news/htm`
25712571

25722572
</Route>
2573+
2574+
## 组织人事报
2575+
2576+
### 电子报
2577+
2578+
<Route author="5upernove-heng" example="/zuzhirenshi" path="/zuzhirenshi/:id?" :paramsDesc="['报纸版号,默认为全部']" radar="1">
2579+
2580+
| 第一版 要闻 | 第二版 要闻 | 第三版 人才 | 第四版 人社工作 | 第五版 基层党建 | 第六版 理论评论 | 第七版 史事通鉴 | 第八版 关注 |
2581+
| ------ | ------ | ------ | -------- | -------- | -------- | -------- | ------ |
2582+
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
2583+
2584+
</Route>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
const got = require('@/utils/got');
2+
const cheerio = require('cheerio');
3+
const { art } = require('@/utils/render');
4+
const path = require('path');
5+
6+
const host = 'https://magazinelib.com';
7+
module.exports = async (ctx) => {
8+
const query = ctx.params.query;
9+
const url = `${host}/wp-json/wp/v2/posts/`;
10+
const response = await got({
11+
method: 'get',
12+
url,
13+
searchParams: {
14+
search: query,
15+
per_page: 30,
16+
_embed: 1,
17+
},
18+
});
19+
let subTitle = query;
20+
if (subTitle !== undefined) {
21+
subTitle = subTitle.replace(/[^a-zA-Z0-9]+/g, ' ').toUpperCase();
22+
subTitle = ` - ${subTitle}`;
23+
} else {
24+
subTitle = '';
25+
}
26+
27+
const items = response.data.map((obj) => {
28+
const data = {};
29+
data.date = obj.date_gmt;
30+
data.link = obj.link;
31+
data.featuredMediaLink = obj._links['wp:featuredmedia'][0].href;
32+
data.title = obj.title.rendered;
33+
const $ = cheerio.load(obj.content.rendered);
34+
const content = $('.vk-att');
35+
content.find('img[src="https://magazinelib.com/wp-includes/images/media/default.png"]').remove();
36+
data.content = content.html();
37+
const imgUrl = obj._embedded['wp:featuredmedia'][0].source_url;
38+
data.description = data.content + art(path.join(__dirname, 'templates/magazine-description.art'), { imgUrl });
39+
data.categories = obj._embedded['wp:term'][0].map((item) => item.name);
40+
return data;
41+
});
42+
43+
ctx.state.data = {
44+
title: `MagazineLib - Latest Magazines${subTitle}`,
45+
link: `{host}/?s=${query}`,
46+
description: `MagazineLib - Latest Magazines${subTitle}`,
47+
item: items.map((item) => ({
48+
title: item.title,
49+
link: item.link,
50+
category: item.categories,
51+
pubDate: new Date(item.pubDate).toUTCString(),
52+
description: item.description,
53+
})),
54+
};
55+
};

lib/v2/magazinelib/maintainer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
'/latest-magazine/:query?': ['NavePnow'],
3+
};

0 commit comments

Comments
 (0)