Skip to content

Latest commit

 

History

History
105 lines (70 loc) · 3.97 KB

general_guide.md

File metadata and controls

105 lines (70 loc) · 3.97 KB

General Plugin Guide

Start from this tutorial, you'll learn how to write a plugin in practice. In this chapter, we will discuss how to write a general plugin with action, placeholder updater and theme provider.

And we will use commandline, http, python and qlexress to implement these functions, you can read the parts which you're interesting, get ready, let's start.

Creating Project Directory And Plugin Specification File

First step, we need to create a project directory and plugin specification file plugin-spec.yml.

Commandline

In this plugin, we create a project directory named commandline-demo-plugin, and write the following content to plugin-spec.yml file.

id: runflow.commandline
name: Commandline Plugin
entry: ./{os}/commandline-demo-plugin
customize-loader: commandline
version: 1.0.0
compatible-version:
  since-build: 961
  until-build: 961

In this implementation, we will pass a parameter to you via commandline which is a base64 encoded json string, so when you get the argument, first you should decode it to json string by base64, then use a json library you liked to parse it.

The Example Full Code.

HTTP

In this plugin, we create a project directory named http-demo-plugin, and write the following content to plugin-spec.yml file.

id: runflow.http
name: HTTP Plugin
entry: http://127.0.0.1:8080
customize-loader: http
version: 1.0.0
compatible-version:
  since-build: 961
  until-build: 961

In this implementation, we will use http post method to request you with a json body, and we require your http interface to respond within 500 milliseconds.

The Example Full Code.

Python

In this plugin, we create a project directory named python-demo-plugin, and write the following content to plugin-spec.yml file.

id: runflow.python
name: Python Plugin
customize-loader: python
version: 1.0.0
compatible-version:
  since-build: 961
  until-build: 961

In python implementation, it is essentially same as commandline, we will pass a parameter to you via commandline which is a base64 encoded json string.

The Example Full Code.

QLExpress

In this plugin, we create a project directory named qlexpress-demo-plugin, and write the following content to plugin-spec.yml file.

id: runflow.qlexpress
name: QLExpress Plugin
customize-loader: qlexpress
version: 1.0.0
compatible-version:
  since-build: 961
  until-build: 961

In this implementation, the request json parameter we will put them into the context directly, you can use them as variables. Learn our qlexpress optimization & Learn QLExpress

The Example Full Code.

What do these fields mean?

The Request Parameter Common Fields

Learn the request parameter common fields, you can also read it later.

In qlexpress plugin, all of these fields are variables, otherwise as a json string.

Writing Functions

  • Cycle Listener demonstrates how to listen plugin loading state.

  • Action demonstrates how to parse the argument and response the action results.

  • Placeholder demonstrates how to update our placeholder.

  • Theme demonstrates how to update our theme.