generated from pot-app/pot-app-collection-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 1
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
6 changed files
with
32 additions
and
153 deletions.
There are no files selected for viewing
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,68 +1 @@ | ||
# Pot-App 生词本插件模板仓库 (以 [Anki](https://apps.ankiweb.net) 为例) | ||
|
||
### [English](./README_EN.md) | 简体中文 | ||
|
||
### 此仓库为模板仓库,编写插件时可以直接由此仓库创建插件仓库 | ||
|
||
## 插件编写指南 | ||
|
||
### 1. 插件仓库创建 | ||
|
||
- 以此仓库为模板创建一个新的仓库 | ||
- 仓库名为 `pot-app-collection-plugin-<插件名>`,例如 `pot-app-collection-plugin-anki` | ||
|
||
### 2. 插件信息配置 | ||
|
||
编辑 `info.json` 文件,修改以下字段: | ||
|
||
- `id`:插件唯一 id,必须以`[plugin]`开头,例如 `[plugin].com.pot-app.anki` | ||
- `homepage`: 插件主页,填写你的仓库地址即可,例如 `https://github.com/pot-app/pot-app-collection-plugin-template` | ||
- `display`: 插件显示名称,例如 `Anki` | ||
- `icon`: 插件图标,例如 `anki.svg` | ||
- `needs`: 插件依赖,一个数组,每个依赖为一个对象,包含以下字段: | ||
- `key`: 依赖 key,对应该项依赖在配置文件中的名称,例如 `port` | ||
- `display`: 依赖显示名称,对应用户显示的名称,例如 `端口号` | ||
|
||
### 3. 插件编写/编译 | ||
|
||
编辑 `src/lib.rs` 实现 `collection` 函数 | ||
|
||
#### 输入参数 | ||
|
||
```rust | ||
source: &str, // 原文 | ||
target: &str, // 译文 | ||
needs: HashMap<String, String>, // 插件需要的其他配置信息,由info.json定义 | ||
``` | ||
|
||
#### 返回值 | ||
|
||
```rust | ||
// 返回用Value包裹的true | ||
return Ok(Value::Bool(true)); | ||
``` | ||
|
||
#### 测试/编译 | ||
|
||
```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.anki.potext`,即可得到 pot 需要的插件。 | ||
|
||
## 自动编译打包 | ||
|
||
本仓库配置了 Github Actions,可以实现推送后自动编译打包插件。 | ||
|
||
每次将仓库推送到 GitHub 之后 actions 会自动运行,将打包好的插件上传到 artifact,在 actions 页面可以下载 | ||
|
||
每次提交 Tag 之后,actions 会自动运行,将打包好的插件上传到 release,在 release 页面可以下载打包好的插件 | ||
|
||
> 注意需要在仓库设置中添加一个名为`TOKEN`的 secret,值为一个有权限的 GitHub Token,用于上传 release | ||
# Pot-App 的 有道单词本插件 |
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,68 +1 @@ | ||
# Pot-App Collection Plugin Template Repository (Take [Anki](https://apps.ankiweb.net) for example) | ||
|
||
### English | [简体中文](./README.md) | ||
|
||
### This repository is a template repository. You can directly create a plugin repository from this repository when writing plugins | ||
|
||
## Plugin Writing Guide | ||
|
||
### 1. Create a plugin repository | ||
|
||
- Create a new repository using this repository as a template | ||
- Named `pot-app-collection-plugin-<name>`,Eg: `pot-app-collection-plugin-anki` | ||
|
||
### 2. Plugin information configuration | ||
|
||
Edit the `info.json` file and modify the following fields: | ||
|
||
- `id`: The unique ID of the plugin, which must start with `[plugin]`, for example `[plugin].com.pot-app.anki` | ||
- `homepage`: The homepage of the plugin, simply fill in your repository address, for example `https://github.com/pot-app/pot-app-collection-plugin-template` | ||
- `display`: The display name of the plugin, for example `Anki` | ||
- `icon`: The icon of the plugin, for example `anki.svg` | ||
- `needs`: Dependencies required by the plugin. It is an array where each dependency is an object that includes the following fields: | ||
- `key`: The key of the dependency, corresponding to its name in the configuration file. For example,`port`. | ||
- `display`: The display name of the dependency as shown to users. For example,`Port`. | ||
|
||
### 3. Plugin writing/compiling | ||
|
||
Edit `src/lib.rs` to implement `collection` function | ||
|
||
#### Input parameters | ||
|
||
```rust | ||
source: &str, // source text | ||
target: &str, // target text | ||
needs: HashMap<String, String>, // Additional configuration information required by the plugin, defined by info.json | ||
``` | ||
|
||
#### Return value | ||
|
||
```rust | ||
// Return the true wrapped by Value | ||
return Ok(Value::Bool(true)) | ||
``` | ||
|
||
#### Test/Compile | ||
|
||
```bash | ||
cargo test --package plugin --lib -- tests --nocapture # run the test case | ||
cargo build --release # Compile | ||
``` | ||
|
||
### 4. Package pot Plugin | ||
|
||
1. Find the `plugin.dll` (Windows)/`libplugin.dylib` (MacOS)/`libplugin.so` (Linux) file in the `target/release` directory and delete the prefix `lib`. | ||
|
||
2. Compress the `plugin.dll`/`libplugin.dylib`/`libplugin.so`, with the `info.json` and icon files, into a zip file. | ||
|
||
3. Rename the file as `<plugin id>.potext`, for example `[plugin].com.pot-app.anki.potext`, to obtain the plugin required by pot. | ||
|
||
## Automatic Compilation and Package | ||
|
||
This repository is configured with Github Actions, which allows for automatic compilation and packaging of plugins after pushing. | ||
|
||
Every time the commit is pushed to GitHub, actions will run automatically and upload the packaged plugin to artifacts. The packaged plugin can be downloaded from the actions page. | ||
|
||
After each tag submission, actions will also run automatically and upload the packaged plugin to releases. The packaged plugin can be downloaded from the release page. | ||
|
||
> Please note that you need to add a secret named `TOKEN` in the repository settings. The value should be a GitHub Token with appropriate permissions, which will be used for uploading releases. | ||
# Pot-App YouDao WordList Plugin |
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,8 +1,8 @@ | ||
{ | ||
"id": "[plugin].com.pot-app.anki", | ||
"id": "[plugin].com.pot-app.youdao_wordlist", | ||
"plugin_type": "collection", | ||
"icon": "anki.svg", | ||
"display": "Anki", | ||
"homepage": "https://github.com/pot-app/pot-app-collection-plugin-template", | ||
"needs": [{ "key": "port", "display": "端口号" }] | ||
"icon": "youdao.svg", | ||
"display": "有道单词本", | ||
"homepage": "https://github.com/pot-app/pot-app-collection-plugin-youdao", | ||
"needs": [{ "key": "cookie", "display": "Cookie" }] | ||
} |
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.