Skip to content

Commit

Permalink
Added plugin live view.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTV12345 committed Oct 8, 2023
1 parent cfa5369 commit 6a245a4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ out/
/src/bin/convertSettings.json
/src/bin/etherpad-1.deb
/src/bin/node.exe
plugin_packages
1 change: 1 addition & 0 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"mime-types": "^2.1.35",
"openapi-backend": "^5.10.0",
"proxy-addr": "^2.0.7",
"live-plugin-manager": "^0.18.1",
"rate-limiter-flexible": "^3.0.0",
"rehype": "^13.0.1",
"rehype-minify-whitespace": "^6.0.0",
Expand Down
29 changes: 16 additions & 13 deletions src/static/js/pluginfw/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ const hooks = require('./hooks');
const runCmd = require('../../../node/utils/run_cmd');
const settings = require('../../../node/utils/Settings');
const axios = require('axios');

const {PluginManager} = require('live-plugin-manager');
const logger = log4js.getLogger('plugins');

exports.manager = new PluginManager();


const onAllTasksFinished = async () => {
settings.reloadSettings();
await hooks.aCallAll('loadSettings', {settings});
Expand Down Expand Up @@ -66,19 +69,19 @@ exports.getAvailablePlugins = (maxCacheAge) => {
const nowTimestamp = Math.round(Date.now() / 1000);

return new Promise(async (resolve, reject) => {
// check cache age before making any request
if (exports.availablePlugins && maxCacheAge && (nowTimestamp - cacheTimestamp) <= maxCacheAge) {
return resolve(exports.availablePlugins);
}
// check cache age before making any request
if (exports.availablePlugins && maxCacheAge && (nowTimestamp - cacheTimestamp) <= maxCacheAge) {
return resolve(exports.availablePlugins);
}

await axios.get('https://static.etherpad.org/plugins.json')
.then(pluginsLoaded => {
exports.availablePlugins = pluginsLoaded.data;
cacheTimestamp = nowTimestamp;
resolve(exports.availablePlugins);
})
})
}
await axios.get('https://static.etherpad.org/plugins.json')
.then((pluginsLoaded) => {
exports.availablePlugins = pluginsLoaded.data;
cacheTimestamp = nowTimestamp;
resolve(exports.availablePlugins);
});
});
};


exports.search = (searchTerm, maxCacheAge) => exports.getAvailablePlugins(maxCacheAge).then(
Expand Down
2 changes: 2 additions & 0 deletions src/static/js/pluginfw/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const runCmd = require('../../../node/utils/run_cmd');
const tsort = require('./tsort');
const pluginUtils = require('./shared');
const defs = require('./plugin_defs');
const {manager} = require('./installer');

const logger = log4js.getLogger('plugins');

Expand Down Expand Up @@ -124,6 +125,7 @@ exports.getPackages = async () => {
};

const loadPlugin = async (packages, pluginName, plugins, parts) => {
console.log('Plugins', manager.list());
const pluginPath = path.resolve(packages[pluginName].path, 'ep.json');
try {
const data = await fs.readFile(pluginPath);
Expand Down

0 comments on commit 6a245a4

Please sign in to comment.