From d3207daf2b29159df99ca867b99288f1392427e1 Mon Sep 17 00:00:00 2001 From: lesion Date: Fri, 30 Jun 2023 23:49:16 +0200 Subject: [PATCH] improve example plugin --- plugins/gancioPluginExample.js | 55 +++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/plugins/gancioPluginExample.js b/plugins/gancioPluginExample.js index 9cc135cd..66b1d4e7 100644 --- a/plugins/gancioPluginExample.js +++ b/plugins/gancioPluginExample.js @@ -1,9 +1,62 @@ +const express = require('express') +const myPluginRouter = express.Router() + +// this will answer at http://localhost:13120/api/plugin/Example/test +myPluginRouter.get('/test', (req, res) => { + return res.json('OK!') +}) const plugin = { + routeAPI: myPluginRouter, + configuration: { + name: 'Example', + author: 'lesion', + url: 'https://framagit.org/les/gancio', + description: 'Example plugin', + settings: { + my_plugin_string_setting: { + type: 'TEXT', + description: 'My plugin string setting', + required: true, + hint: 'My plugin setting support html too' + }, + enable_this_feature_in_my_plugin: { + type: 'CHECK', + description: 'My plugin best feature', + required: true, + hint: 'This feature is super dupe, enable it!' + }, + min_post: { + type: 'NUMBER', + description: 'it supports number too' + }, + my_default_language: { + description: 'My default language', + type: 'LIST', + items: ['it', 'en', 'fr'] + } + } + }, gancio: null, - load (gancio) { + settings: null, + load (gancio, settings) { console.error('Plugin GancioPluginExample loaded!') + console.error('Your settings are in ', settings) + console.error(`For example, you can access to your default language setting by using ${settings.my_default_language}`) plugin.gancio = gancio + plugin.settings = settings + + // gancio.db.models.event.findAll({ where: }) + // gancio.db.query('CREATE TABLE IF NOT EXISTS ()... ') + + }, + + unload () { + console.error('Unload this plugin!') + }, + + onTest () { + console.error('called on "TEST" button pressed in admin interface') }, onEventCreate (event) {