add plugin loader

This commit is contained in:
2023-08-13 15:07:41 +02:00
parent 029181329a
commit 1beba0131a
11 changed files with 90 additions and 7 deletions

View File

@@ -84,16 +84,17 @@ if ( settings.init ) {
require( './admin/adminAPIRoutes.js' )( app, settings ); // admin api routes require( './admin/adminAPIRoutes.js' )( app, settings ); // admin api routes
require( './backend/userAPIRoutes.js' )( app, settings ); // admin api routes require( './backend/userAPIRoutes.js' )( app, settings ); // admin api routes
require( './backend/userRoutes.js' )( app, settings ); // user routes require( './backend/userRoutes.js' )( app, settings ); // user routes
require( './backend/payments/paymentRoutes.js' )( app, settings ); // payment routes
console.log( '[ Server ] loading plugins' );
require( './backend/plugins/pluginLoader.js' )( app, settings );
} else { } else {
require( './setup/setupRoutes.js' )( app, settings ); // setup routes require( './setup/setupRoutes.js' )( app, settings ); // setup routes
file = path.join( __dirname + '/webapp/setup/dist/index.html' ); file = path.join( __dirname + '/webapp/setup/dist/index.html' );
} }
console.log( '[ Server ] loading plugins' );
// TODO: load dynamically // TODO: load dynamically
// require( './backend/plugins/payments/stripe/stripeRoutes.js' )( app, settings ); // stripe routes // require( './backend/plugins/payments/stripe/stripeRoutes.js' )( app, settings ); // stripe routes
require( './backend/plugins/payments/payrexx/payrexxRoutes.js' )( app, settings ); // payrexx routes // require( './backend/plugins/payments/payrexx/payrexxRoutes.js' )( app, settings ); // payrexx routes
require( './backend/payments/paymentRoutes.js' )( app, settings ); // payment routes
app.use( ( request, response ) => { app.use( ( request, response ) => {
response.sendFile( file ); response.sendFile( file );

View File

@@ -0,0 +1,5 @@
# Plugins
If you want to create a new plugin for libreevent, please follow our guide and guidelines in the official documentation [here](https://libreevent.janishutz.com/docs/contributing/plugins)
Each plugin should have a plugin.json file that uses the layout of the plugin.json file in this directory. As future libreevent might change what is required by the plugin.json file, please follow this repository to get news when this is about to happen. To retain backwards compatibility, we will for as long as possible not remove anything from the plugin.json files as possible, which means you can already update your plugin.json file before the next version of libreevent is released.

View File

@@ -0,0 +1,10 @@
/*
* libreevent - newsletterRoutes.js
*
* Created by Janis Hutz 08/13/2023, Licensed under the GPL V3 License
* https://janishutz.com, development@janishutz.com
*
*
*/
module.exports = ( app, settings ) => {};

View File

@@ -0,0 +1,12 @@
{
"pluginName": "Newsletter",
"pluginDescription": "Send newsletters to your customers using a file editor",
"creator": "Janis Hutz",
"maintainer": "Janis Hutz",
"pluginWebsite": "https://libreevent.janishutz.com/plugins/newsletter",
"pluginDocs": "https://libreevent.janishutz.com/docs/plugins/newsletter",
"gitURL": "https://github.com/simplePCBuilding/libreevent/tree/master/src/server/backend/plugins/others/newsletter",
"settingsURL": "/admin/plugins/newsletter/settings",
"mainPluginURL": "/admin/plugins/newsletter",
"version": "1.0.0"
}

View File

@@ -0,0 +1,12 @@
{
"pluginName": "Polls",
"pluginDescription": "Create polls to ask the customers questions about your event!",
"creator": "Janis Hutz",
"maintainer": "Janis Hutz",
"pluginWebsite": "https://libreevent.janishutz.com/plugins/polls",
"pluginDocs": "https://libreevent.janishutz.com/docs/plugins/polls",
"gitURL": "https://github.com/simplePCBuilding/libreevent/tree/master/src/server/backend/plugins/others/poll",
"settingsURL": "/admin/plugins/polls/settings",
"mainPluginURL": "/polls",
"version": "1.0.0"
}

View File

@@ -0,0 +1,12 @@
/*
* libreevent - pollRoutes.js
*
* Created by Janis Hutz 08/13/2023, Licensed under the GPL V3 License
* https://janishutz.com, development@janishutz.com
*
*
*/
module.exports = ( app, settings ) => {
};

View File

@@ -13,10 +13,6 @@ The express.js routes it has to expose are the following:
It can contain any number of (not interfering) routes. Please always use the /payments/ route as a base to avoid running into problems. It can contain any number of (not interfering) routes. Please always use the /payments/ route as a base to avoid running into problems.
## The plugin.json file
The plugin.json file should look as follows:
## configOption.json ## configOption.json
This file contains the settings that should be available in the settings page of libreevent. It should contain the following fields, as required by the settings.vue module. This file contains the settings that should be available in the settings page of libreevent. It should contain the following fields, as required by the settings.vue module.

View File

@@ -0,0 +1,12 @@
{
"pluginName": "",
"pluginDescription": "",
"creator": "",
"maintainer": "",
"pluginWebsite": "",
"pluginDocs": "",
"gitURL": "",
"settingsURL": "",
"mainPluginURL": "",
"version": ""
}

View File

@@ -0,0 +1,23 @@
/*
* libreevent - pluginLoader.js
*
* Created by Janis Hutz 08/13/2023, Licensed under the GPL V3 License
* https://janishutz.com, development@janishutz.com
*
*
*/
const fs = require( 'fs' );
const path = require( 'path' );
module.exports = ( app, settings ) => {
let otherPlugins = fs.readdirSync( path.join( __dirname + '/others' ) );
console.log( '\n\n' );
for ( let plugin in otherPlugins ) {
console.log( '[ Plugin Loader ] Loaded plugin "' + otherPlugins[ plugin ] + '"' );
require( './others/' + otherPlugins[ plugin ] + '/' + otherPlugins[ plugin ] + 'Routes.js' )( app, settings );
}
require( './payments/' + settings.payments + '/' + settings.payments + 'Routes.js' )( app, settings );
console.log( '[ Plugin Loader ] Loaded ' + settings.payments + ' as payment gateway' );
};