-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
289 additions
and
65 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
[package] | ||
name = "plugin" | ||
name = "plugin" # 名称固定为plugin,请勿更改 | ||
version = "1.0.0" | ||
authors = ["Pylogmon"] | ||
authors = ["pot-app"] | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["dylib"] | ||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
crate-type = ["dylib"] # pot只支持dylib类型动态库,请勿修改 | ||
|
||
[dependencies] | ||
reqwest = {version="0.11.18",features = ["blocking","json"]} | ||
urlencoding = "2.1.3" | ||
serde_json = "1.0" | ||
|
||
[target.'cfg(target_os = "linux")'.dependencies] | ||
openssl={version="0.10",features=["vendored"]} | ||
openssl={version="0.10",features=["vendored"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,47 @@ | ||
# Pot 翻译插件 Demo (Bing 为例) | ||
# Pot-App 翻译插件模板仓库 (以 [Lingva](https://github.com/TheDavidDelta/lingva-translate) 为例) | ||
|
||
### 此仓库为模板仓库,编写插件时可以直接由此仓库创建插件仓库 | ||
|
||
## 插件编写指南 | ||
|
||
### 1. 插件仓库创建 | ||
|
||
- 以此仓库为模板创建一个新的仓库 | ||
- 仓库名为 `pot-app-<插件名>`,例如 `pot-app-lingva` | ||
|
||
### 2. 插件信息配置 | ||
|
||
编辑 `info.json` 文件,修改以下字段: | ||
|
||
- `id`:插件唯一 id,必须以`[plugin]`开头,例如 `[plugin].com.pot-app.lingva` | ||
- `display`: 插件显示名称,例如 `Lingva` | ||
- `icon`: 插件图标,例如 `lingva.svg` | ||
- `needs`: 插件依赖,一个数组,每个依赖为一个对象,包含以下字段: | ||
- `key`: 依赖 key,对应该项依赖在配置文件中的名称,例如 `requestPath` | ||
- `display`: 依赖显示名称,对应用户显示的名称,例如 `请求地址` | ||
- `language`: 插件支持的语言映射,将 pot 的语言代码和插件发送请求时的语言代码一一对应 | ||
|
||
### 3. 插件编写/编译 | ||
|
||
编辑 `src/lib.rs` 实现 `translate` 函数 | ||
|
||
```bash | ||
cargo test --package plugin --lib -- tests --nocapture # 运行测试用例 | ||
cargo build --release # 编译 | ||
``` | ||
|
||
### 4. 打包 pot 插件 | ||
|
||
1. 在`target/release`目录找到`plugin.dll`(Windows)/`libplugin.dylib`(MacOS)/`libplugin.so`(Linux)文件,统一删除`lib`前缀. | ||
|
||
2. 将`plugin.dll`/`libplugin.dylib`/`libplugin.so`文件和`info.json`以及图标文件压缩为 zip 文件。 | ||
|
||
3. 将文件重命名为`<插件id>.potext`,例如`[plugin].com.pot-app.lingva.potext`,即可得到 pot 需要的插件。 | ||
|
||
## 自动编译打包 | ||
|
||
本仓库配置了 Github Actions,可以实现推送后自动编译打包插件。 | ||
|
||
每次将仓库推送到 GitHub 之后 actions 会自动运行,将打包好的插件上传到 artifact,在 actions 页面可以下载 | ||
|
||
每次提交 Tag 之后,actions 会自动运行,将打包好的插件上传到 release,在 release 页面可以下载打包好的插件 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.