Compare commits

...

1 Commits

Author SHA1 Message Date
SamTV12345 cf32d45f66 Added plugin live view. 2023-10-14 09:48:24 +02:00
4 changed files with 20 additions and 13 deletions

1
.gitignore vendored
View File

@ -21,3 +21,4 @@ out/
/src/bin/convertSettings.json /src/bin/convertSettings.json
/src/bin/etherpad-1.deb /src/bin/etherpad-1.deb
/src/bin/node.exe /src/bin/node.exe
plugin_packages

View File

@ -56,6 +56,7 @@
"npm": "^6.14.18", "npm": "^6.14.18",
"openapi-backend": "^5.10.5", "openapi-backend": "^5.10.5",
"proxy-addr": "^2.0.7", "proxy-addr": "^2.0.7",
"live-plugin-manager": "^0.18.1",
"rate-limiter-flexible": "^3.0.0", "rate-limiter-flexible": "^3.0.0",
"rehype": "^13.0.1", "rehype": "^13.0.1",
"rehype-minify-whitespace": "^6.0.0", "rehype-minify-whitespace": "^6.0.0",

View File

@ -6,9 +6,12 @@ const hooks = require('./hooks');
const runCmd = require('../../../node/utils/run_cmd'); const runCmd = require('../../../node/utils/run_cmd');
const settings = require('../../../node/utils/Settings'); const settings = require('../../../node/utils/Settings');
const axios = require('axios'); const axios = require('axios');
const {PluginManager} = require('live-plugin-manager');
const logger = log4js.getLogger('plugins'); const logger = log4js.getLogger('plugins');
exports.manager = new PluginManager();
const onAllTasksFinished = async () => { const onAllTasksFinished = async () => {
settings.reloadSettings(); settings.reloadSettings();
await hooks.aCallAll('loadSettings', {settings}); await hooks.aCallAll('loadSettings', {settings});
@ -72,19 +75,19 @@ exports.getAvailablePlugins = (maxCacheAge) => {
const nowTimestamp = Math.round(Date.now() / 1000); const nowTimestamp = Math.round(Date.now() / 1000);
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
// check cache age before making any request // check cache age before making any request
if (exports.availablePlugins && maxCacheAge && (nowTimestamp - cacheTimestamp) <= maxCacheAge) { if (exports.availablePlugins && maxCacheAge && (nowTimestamp - cacheTimestamp) <= maxCacheAge) {
return resolve(exports.availablePlugins); return resolve(exports.availablePlugins);
} }
await axios.get('https://static.etherpad.org/plugins.json') await axios.get('https://static.etherpad.org/plugins.json')
.then(pluginsLoaded => { .then((pluginsLoaded) => {
exports.availablePlugins = pluginsLoaded.data; exports.availablePlugins = pluginsLoaded.data;
cacheTimestamp = nowTimestamp; cacheTimestamp = nowTimestamp;
resolve(exports.availablePlugins); resolve(exports.availablePlugins);
}) });
}) });
} };
exports.search = (searchTerm, maxCacheAge) => exports.getAvailablePlugins(maxCacheAge).then( exports.search = (searchTerm, maxCacheAge) => exports.getAvailablePlugins(maxCacheAge).then(

View File

@ -8,6 +8,7 @@ const runCmd = require('../../../node/utils/run_cmd');
const tsort = require('./tsort'); const tsort = require('./tsort');
const pluginUtils = require('./shared'); const pluginUtils = require('./shared');
const defs = require('./plugin_defs'); const defs = require('./plugin_defs');
const {manager} = require('./installer');
const logger = log4js.getLogger('plugins'); const logger = log4js.getLogger('plugins');
@ -124,6 +125,7 @@ exports.getPackages = async () => {
}; };
const loadPlugin = async (packages, pluginName, plugins, parts) => { const loadPlugin = async (packages, pluginName, plugins, parts) => {
console.log('Plugins', manager.list());
const pluginPath = path.resolve(packages[pluginName].path, 'ep.json'); const pluginPath = path.resolve(packages[pluginName].path, 'ep.json');
try { try {
const data = await fs.readFile(pluginPath); const data = await fs.readFile(pluginPath);