Giter VIP home page Giter VIP logo

pot-app-recognize-plugin-latex-ocr's Introduction

Pot-App 文字识别插件模板仓库 (以 OCR Space 为例)

English | 简体中文

此仓库为模板仓库,编写插件时可以直接由此仓库创建插件仓库

插件编写指南

1. 插件仓库创建

  • 以此仓库为模板创建一个新的仓库
  • 仓库名为 pot-app-recognize-plugin-<插件名>,例如 pot-app-recognize-plugin-ocrspace

2. 插件信息配置

编辑 info.json 文件,修改以下字段:

  • id:插件唯一 id,必须以[plugin]开头,例如 [plugin].com.pot-app.ocrspace
  • display: 插件显示名称,例如 OCR Space
  • homepage: 插件主页,填写你的仓库地址即可,例如 https://github.com/pot-app/pot-app-recognize-plugin-template
  • icon: 插件图标,填写当前目录下的图标名称,例如 icon.png
  • needs: 插件依赖,一个数组,每个依赖为一个对象,包含以下字段:
    • key: 依赖 key,对应该项依赖在配置文件中的名称,例如 apikey
    • display: 依赖显示名称,对应用户显示的名称,例如 API Key
    • type: 组件类型 input | select
    • options: 选项列表(仅select组件需要),例如 {"engine_a":"Engina A","engine_b":"Engina B"}
  • language: 插件支持的语言映射,将 pot 的语言代码和插件发送请求时的语言代码一一对应

3. 插件编写/编译

编辑 src/lib.rs 实现 recognize 函数

Input parameters

    base64: &str, // 图像 Base64
    lang: &str, // 语言代码
    needs: HashMap<String, String>, // 插件需要的其他配置信息,由info.json定义

Return value

// 返回用Value包裹的String
  return Ok(Value::String(result));

测试/编译

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.ocrspace.potext,即可得到 pot 需要的插件。

自动编译打包

本仓库配置了 Github Actions,可以实现推送后自动编译打包插件。

每次将仓库推送到 GitHub 之后 actions 会自动运行,将打包好的插件上传到 artifact,在 actions 页面可以下载

每次提交 Tag 之后,actions 会自动运行,将打包好的插件上传到 release,在 release 页面可以下载打包好的插件

注意需要在仓库设置中添加一个名为TOKEN的 secret,值为一个有权限的 GitHub Token,用于上传 release

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.