feat(core): serve logo locally (#12629)

* feat(core): serve logo locally

* test: add test for logo
This commit is contained in:
Tony
2023-06-07 09:30:54 -04:00
committed by GitHub
parent 2f8aa2e183
commit 08d894548a
8 changed files with 79 additions and 7 deletions
+2
View File
@@ -13,6 +13,7 @@ const cache = require('./middleware/cache');
const parameter = require('./middleware/parameter');
const template = require('./middleware/template');
const favicon = require('koa-favicon');
const serve = require('koa-static');
const debug = require('./middleware/debug');
const accessControl = require('./middleware/access-control');
const antiHotlink = require('./middleware/anti-hotlink');
@@ -37,6 +38,7 @@ app.proxy = true;
// favicon
app.use(favicon(__dirname + '/favicon.png'));
app.use(serve(__dirname + '/static'));
// global error handing
app.use(onerror);
Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

+7 -3
View File
@@ -26,13 +26,17 @@
a {
color: #F5712C;
}
img {
filter: grayscale(1);
}
</style>
</head>
<body>
<div class="content">
<p>
<img src="https://i.loli.net/2019/09/04/lmBbNQoLzrKGgiM.jpg" alt="RSSHub" width="120">
<img src="/logo.png" alt="RSSHub" width="120">
</p>
<h1>Looks like something went wrong</h1>
@@ -46,14 +50,14 @@ Node version: {{@ nodeVersion}}
Git Hash: {{@ gitHash}}
</pre>
<pre class="message">
如果您认为 RSSHub 导致了该错误,请在Github按照模版,复制本页面信息进行<a href="https://github.com/DIYgod/RSSHub/issues/new?assignees=&labels=RSS+bug&template=bug_report_zh.yml" target="_blank">汇报</a>
If you believe this is an error caused by RSSHub, please <a href="https://github.com/DIYgod/RSSHub/issues/new?assignees=&labels=RSS+bug&template=bug_report_en.yml" target="_blank">report on github</a>
如果您认为 RSSHub 导致了该错误,请在 GitHub 按照模版,复制本页面信息进行 <a href="https://github.com/DIYgod/RSSHub/issues/new?assignees=&labels=RSS+bug&template=bug_report_zh.yml" target="_blank">汇报</a>
</pre>
<div style="margin: 50px 0">
<p>在线文档与支持,请访问<a href="https://docs.rsshub.app/" target="_blank">docs.rsshub.app</a>。</p>
<p>For online documentation and support please refer to
<a href="https://docs.rsshub.app/" target="_blank">docs.rsshub.app</a>.</p>
<p>在线文档与支持,请访问 <a href="https://docs.rsshub.app/" target="_blank">docs.rsshub.app</a>。</p>
</div>
</div>
</body>
+1 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"
{{ if itunes_author || itunes_category || (item && item.some((i) => (i.itunes_item_image || i.itunes_duration))) }}
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
{{ /if }}
+2 -2
View File
@@ -79,13 +79,13 @@
<body>
<div class="content">
<p>
<img src="https://i.loli.net/2019/04/23/5cbeb7e41414c.png" alt="RSSHub" width="100">
<img src="/logo.png" alt="RSSHub" width="100">
</p>
<h1>Welcome to
<span style="color: #F5712C;">RSSHub</span>!</h1>
<p>If you see this page, the RSSHub{{ if hash }} ({{ hash }}){{ /if }} is successfully installed and working.</p>
<p>If you see this page, the RSSHub is successfully installed and working.</p>
<p>For online documentation and support please refer to
<a href="https://docs.rsshub.app/" target="_blank">docs.rsshub.app</a>.</p>
+1
View File
@@ -109,6 +109,7 @@
"koa-basic-auth": "4.0.0",
"koa-favicon": "2.1.0",
"koa-mount": "4.0.0",
"koa-static": "5.0.0",
"lru-cache": "9.1.1",
"lz-string": "1.5.0",
"mailparser": "3.6.4",
+50 -1
View File
@@ -103,6 +103,9 @@ dependencies:
koa-mount:
specifier: 4.0.0
version: 4.0.0
koa-static:
specifier: 5.0.0
version: 5.0.0
lru-cache:
specifier: 9.1.1
version: 9.1.1
@@ -2517,7 +2520,6 @@ packages:
dependencies:
ms: 2.1.3
supports-color: 5.5.0
dev: true
/debug@4.3.4:
resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==}
@@ -3820,6 +3822,16 @@ packages:
resolution: {integrity: sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==}
dev: false
/http-errors@1.6.3:
resolution: {integrity: sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A==}
engines: {node: '>= 0.6'}
dependencies:
depd: 1.1.2
inherits: 2.0.3
setprototypeof: 1.1.0
statuses: 1.5.0
dev: false
/http-errors@1.8.1:
resolution: {integrity: sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==}
engines: {node: '>= 0.6'}
@@ -4017,6 +4029,10 @@ packages:
once: 1.4.0
wrappy: 1.0.2
/inherits@2.0.3:
resolution: {integrity: sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==}
dev: false
/inherits@2.0.4:
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
@@ -4921,6 +4937,27 @@ packages:
- supports-color
dev: false
/koa-send@5.0.1:
resolution: {integrity: sha512-tmcyQ/wXXuxpDxyNXv5yNNkdAMdFRqwtegBXUaowiQzUKqJehttS0x2j0eOZDQAyloAth5w6wwBImnFzkUz3pQ==}
engines: {node: '>= 8'}
dependencies:
debug: 4.3.4
http-errors: 1.8.1
resolve-path: 1.4.0
transitivePeerDependencies:
- supports-color
dev: false
/koa-static@5.0.0:
resolution: {integrity: sha512-UqyYyH5YEXaJrf9S8E23GoJFQZXkBVJ9zYYMPGz919MSX1KuvAcycIuS0ci150HCoPf4XQVhQ84Qf8xRPWxFaQ==}
engines: {node: '>= 7.6.0'}
dependencies:
debug: 3.2.7(supports-color@5.5.0)
koa-send: 5.0.1
transitivePeerDependencies:
- supports-color
dev: false
/koa@2.14.2:
resolution: {integrity: sha512-VFI2bpJaodz6P7x2uyLiX6RLYpZmOJqNmoCst/Yyd7hQlszyPwG/I9CQJ63nOtKSxpt5M7NH67V6nJL2BwCl7g==}
engines: {node: ^4.8.4 || ^6.10.1 || ^7.10.1 || >= 8.1.4}
@@ -6702,6 +6739,14 @@ packages:
engines: {node: '>=8'}
dev: true
/resolve-path@1.4.0:
resolution: {integrity: sha512-i1xevIst/Qa+nA9olDxLWnLk8YZbi8R/7JPbCMcgyWaFR6bKWaexgJgEB5oc2PKMjYdrHynyz0NY+if+H98t1w==}
engines: {node: '>= 0.8'}
dependencies:
http-errors: 1.6.3
path-is-absolute: 1.0.1
dev: false
/resolve.exports@2.0.2:
resolution: {integrity: sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==}
engines: {node: '>=10'}
@@ -6818,6 +6863,10 @@ packages:
/set-blocking@2.0.0:
resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==}
/setprototypeof@1.1.0:
resolution: {integrity: sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==}
dev: false
/setprototypeof@1.2.0:
resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==}
dev: false
+16
View File
@@ -0,0 +1,16 @@
const supertest = require('supertest');
const server = require('../lib/index');
const request = supertest(server);
afterAll(() => {
server.close();
});
describe('index', () => {
it('serve logo', async () => {
const response = await request.get('/logo.png');
expect(response.status).toBe(200);
expect(response.headers['content-type']).toBe('image/png');
expect(response.headers['content-length']).toBe('89034');
});
});