mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-08 16:05:05 -04:00
Added plugin live view.
This commit is contained in:
parent
6a2ffe6aaf
commit
71a29884d6
4 changed files with 19 additions and 13 deletions
|
@ -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});
|
||||
|
@ -76,22 +79,21 @@ 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', {headers: headers})
|
||||
.then(pluginsLoaded => {
|
||||
exports.availablePlugins = pluginsLoaded.data;
|
||||
cacheTimestamp = nowTimestamp;
|
||||
resolve(exports.availablePlugins);
|
||||
})
|
||||
await axios.get('https://static.etherpad.org/plugins.json', {headers: headers})
|
||||
.then((pluginsLoaded) => {
|
||||
exports.availablePlugins = pluginsLoaded.data;
|
||||
cacheTimestamp = nowTimestamp;
|
||||
resolve(exports.availablePlugins);})
|
||||
.catch(async err => {
|
||||
return reject(err);
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
exports.search = (searchTerm, maxCacheAge) => exports.getAvailablePlugins(maxCacheAge).then(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue