Skip to content

Commit 144876c

Browse files
authored
Merge pull request #8 from ruibaby/refactor/image-link
Refactor the image link replacement implementation
2 parents a6069df + 294eaa0 commit 144876c

40 files changed

+6160
-194
lines changed

.github/workflows/ci.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
ci:
13+
uses: halo-sigs/reusable-workflows/.github/workflows/plugin-ci.yaml@v1
14+
with:
15+
ui-path: "ui"

.github/workflows/workflow.yaml

Lines changed: 0 additions & 91 deletions
This file was deleted.

README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,30 @@
22

33
此插件提供对 WebP Cloud(<https://webp.se>)的集成,支持在文章页面无入侵式的自动替换图片为 WebP/AVIF 格式。
44

5-
## 使用
5+
## 特性
66

7-
### [WebP Cloud Dashboard](https://dashboard.webp.se/proxy) 创建一个代理(Proxy)
7+
- 支持无入侵式的替换网站中所有的图片链接为 WebP/AVIF 格式的链接。
8+
- 简单方便的配置界面,配置好 <https://webp.se> 的 API Key 之后即可选择或创建代理地址。
89

9-
![Create a Proxy](./images/dashboard.webp.create_proxy.png)
10+
## 安装与使用
1011

11-
创建完成之后,就可以看到你的 `Proxy Address` 了:
12+
1.[应用市场](https://www.halo.run/store/apps/app-fVJSY)中安装并启用此插件。
13+
2. 进入插件的设置页面,配置 API Key:
1214

13-
![Demo Proxy](./images/dashboard.webp.proxy.png)
15+
![API Key](./images/api-key.png)
1416

15-
## 下载并安装此插件
17+
3. 选择已有的代理配置或者创建新的:
1618

17-
进入 [Releases](https://github.com/webp-sh/halo-plugin-webp-cloud/releases) 页面,选择最新版本下载 Assets 中的 `plugin-webp-cloud-xxx.jar` 文件即可。
19+
![Proxies](./images/proxies.png)
1820

19-
安装插件的方式可以参考官方文档:<https://docs.halo.run/user-guide/plugins#%E5%AE%89%E8%A3%85%E6%8F%92%E4%BB%B6>
21+
![Create a Proxy](./images/create-a-proxy.png)
2022

21-
## 配置插件
23+
> 请注意,如果你的网站图片是相对地址,那么你需要在源站地址中填写在 Halo 中配置好的外部访问地址,例如 `https://example.com`,这样插件才能正确的替换图片地址。
2224
23-
安装完成之后,进入插件详情页面中的基础设置选项卡,填入你的 `Proxy Address`,保存即可
25+
4. 最后保存即可
2426

25-
![Plugin Setting](./images/plugin-webp-se-cloud-setting.png)
27+
## 验证
2628

27-
最后,进入任意一篇包含图片的文章,检查一下浏览器的 Network 面板,就可以看到图片的源地址已经修改为了你设置的 `Proxy Address` 了。
29+
进入任意一篇包含图片的文章,检查一下浏览器 Network 面板的图片请求地址,或者查看网页源代码,可以看到图片的源地址已经修改为了你设置的 `Proxy Address` 了。
2830

2931
![Effect](./images/effect.png)

build.gradle

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
plugins {
22
id 'java'
3+
id "com.github.node-gradle.node" version "7.0.2"
34
id "io.freefair.lombok" version "8.0.1"
4-
id "run.halo.plugin.devtools" version "0.0.5"
5+
id "run.halo.plugin.devtools" version "0.0.9"
56
}
67

78
group 'se.webp.plugin'
@@ -15,7 +16,7 @@ repositories {
1516
}
1617

1718
dependencies {
18-
implementation platform('run.halo.tools.platform:plugin:2.8.0-SNAPSHOT')
19+
implementation platform('run.halo.tools.platform:plugin:2.13.0-SNAPSHOT')
1920
compileOnly 'run.halo.app:api'
2021

2122
testImplementation 'run.halo.app:api'
@@ -24,4 +25,30 @@ dependencies {
2425

2526
test {
2627
useJUnitPlatform()
28+
}
29+
30+
31+
node {
32+
nodeProjectDir = file("${project.projectDir}/ui")
33+
}
34+
35+
tasks.register('buildFrontend', PnpmTask) {
36+
args = ['build']
37+
dependsOn('installDepsForUI')
38+
}
39+
40+
tasks.register('installDepsForUI', PnpmTask) {
41+
args = ['install']
42+
}
43+
44+
build {
45+
// build frontend before build
46+
tasks.named('compileJava').configure {
47+
dependsOn('buildFrontend')
48+
}
49+
}
50+
51+
halo {
52+
imageName = "docker.1panel.live/halohub/halo"
53+
version = "2.17"
2754
}

images/api-key.png

146 KB
Loading

images/create-a-proxy.png

172 KB
Loading
-81.1 KB
Binary file not shown.

images/dashboard.webp.proxy.png

-37.6 KB
Binary file not shown.

images/effect.png

132 KB
Loading
-49.2 KB
Binary file not shown.

images/proxies.png

147 KB
Loading
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package se.webp.plugin;
2+
3+
import lombok.Data;
4+
import reactor.core.publisher.Mono;
5+
import run.halo.app.plugin.ReactiveSettingFetcher;
6+
7+
public class Settings {
8+
9+
public static Mono<BasicConfig> getBasicConfig(ReactiveSettingFetcher settingFetcher) {
10+
return settingFetcher.fetch(BasicConfig.GROUP, BasicConfig.class);
11+
}
12+
13+
@Data
14+
public static class BasicConfig {
15+
public static final String GROUP = "basic";
16+
17+
String apiKeySecret;
18+
19+
Proxy[] proxies;
20+
}
21+
22+
@Data
23+
public static class Proxy {
24+
String origin_url;
25+
26+
String proxy_url;
27+
}
28+
}

0 commit comments

Comments
 (0)