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.
First step, we need to create a project directory and plugin specification file plugin-spec.yml
.
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.
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.
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.
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
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.
-
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.