mirror of
https://github.com/UiO-Gaming/infoscreen3.git
synced 2026-11-05 13:56:52 +01:00
small fixes.. implemented cache for ping-plugin to reduce calls
This commit is contained in:
1 parent
1f28c345d1
commit
e42ddb5454
6 files changed
+76
-37
No files matched your search
@@ -1,5 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
const bundle = require(`./bundle.js`);
|
||||
let fs = require("fs");
|
||||
let cli = require(`./cli.js`);
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
'use strict'
|
||||
let fs = require("fs");
|
||||
let cli = require(`./cli.js`);
|
||||
let bundleManager = require(`./bundleManager.js`);
|
||||
let config = require('../config.js');
|
||||
let plugins = {};
|
||||
|
||||
|
||||
/**
|
||||
* handles one display instance
|
||||
|
||||
+40
-4
@@ -1,12 +1,20 @@
|
||||
let express = require('express');
|
||||
let Twig = require('twig');
|
||||
let fs = require('fs');
|
||||
let cli = require('./cli');
|
||||
|
||||
|
||||
/**
|
||||
* Base plugin class
|
||||
*
|
||||
* Strucure of plugin:
|
||||
* D /public/ -- serves files statically at http path: /data/pluginName/
|
||||
* D /views/ -- directory for twig templates
|
||||
* F /plugin.js -- pluginfile which will be loaded
|
||||
*
|
||||
* if you need external libs, just add `package.json` to the plugin dir, and call npm install :)
|
||||
*/
|
||||
class plugin {
|
||||
|
||||
constructor(pluginName, app, io, dispatcher) {
|
||||
constructor(pluginName, app, io, dispatcher) {
|
||||
this.pluginName = pluginName;
|
||||
this.subApp = express();
|
||||
this.subApp.set('views', "plugins/" + pluginName + "/views");
|
||||
@@ -27,10 +35,34 @@ class plugin {
|
||||
return Twig.twig({ data: fs.readFileSync("plugins/" + this.pluginName + "/views/" + template + ".twig").toString() }).render(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called at infoscreen init-phase
|
||||
*
|
||||
* the example will render a view from `pluginName/Views/test.twig` to route `/admin/test`
|
||||
* @example
|
||||
* let self = this;
|
||||
* router.get("/test", function (req, res, next) {
|
||||
* res.send(self.renderPluginView("test", { test: "hello!" }));
|
||||
* // res.render(); will render from infoscreen/views/*.twig
|
||||
* });
|
||||
* @param {express.Router} router
|
||||
*/
|
||||
onAdminRouter(router) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called at infoscreen init-phase
|
||||
*
|
||||
* the example will render a view from `pluginName/Views/test.twig` to route `/test`
|
||||
*
|
||||
* @example
|
||||
* router.get("/test", function (req, res) {
|
||||
* res.render("test", { test: "hello!" });
|
||||
* });
|
||||
*
|
||||
* @param {express.Router} router
|
||||
*/
|
||||
onPluginRouter(router) {
|
||||
|
||||
}
|
||||
@@ -38,7 +70,11 @@ class plugin {
|
||||
onInit() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts html to display views
|
||||
*
|
||||
* @returns {string} HTML to be added to display View
|
||||
*/
|
||||
setDisplayViewAdditions() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -12,15 +12,15 @@ class pluginManager {
|
||||
try {
|
||||
let pluginclass = require("../plugins/" + pluginName + "/plugin.js").default;
|
||||
let pluginInstance = new pluginclass(pluginName, app, io, eventDispatcher);
|
||||
cli.info("Plugin: " + pluginName, 'plugin');
|
||||
cli.info("" + pluginName, 'plugin');
|
||||
this.plugins[pluginName] = pluginInstance;
|
||||
} catch (err) {
|
||||
cli.error("Plugin " + pluginName, err);
|
||||
cli.error(err, pluginName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
callMethod(method, params) {
|
||||
|
||||
callMethod(method, params) {
|
||||
this.dispatcher.emit("plugin." + method, params);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user