mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-21 23:12:58 +01:00
* feat: add enable/disable checkbox for plugin usage * feat: submit plugin data to packages.nodebb.org only submit in production mode submit once every 24 hours dont submit for plugins that have "private": true in plugin.json enabled on new installs disabled on existing installs * fix: hash not working after first send fix statusCode * fix: remove url * feat: show compatibilty * feat: add install question for submit plugin usage
68 lines
1.8 KiB
JavaScript
68 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
var async = require('async');
|
|
var nconf = require('nconf');
|
|
var plugins = require('../../plugins');
|
|
var meta = require('../../meta');
|
|
|
|
var pluginsController = module.exports;
|
|
|
|
pluginsController.get = function (req, res, next) {
|
|
async.waterfall([
|
|
function (next) {
|
|
async.parallel({
|
|
compatible: function (next) {
|
|
plugins.list(function (err, plugins) {
|
|
if (err || !Array.isArray(plugins)) {
|
|
plugins = [];
|
|
}
|
|
|
|
next(null, plugins);
|
|
});
|
|
},
|
|
all: function (next) {
|
|
plugins.list(false, function (err, plugins) {
|
|
if (err || !Array.isArray(plugins)) {
|
|
plugins = [];
|
|
}
|
|
|
|
next(null, plugins);
|
|
});
|
|
},
|
|
}, next);
|
|
},
|
|
function (payload) {
|
|
var compatiblePkgNames = payload.compatible.map(function (pkgData) {
|
|
return pkgData.name;
|
|
});
|
|
var installedPlugins = payload.compatible.filter(function (plugin) {
|
|
return plugin && plugin.installed;
|
|
});
|
|
var activePlugins = payload.all.filter(function (plugin) {
|
|
return plugin && plugin.installed && plugin.active;
|
|
});
|
|
|
|
res.render('admin/extend/plugins', {
|
|
installed: installedPlugins,
|
|
installedCount: installedPlugins.length,
|
|
activeCount: activePlugins.length,
|
|
inactiveCount: Math.max(0, installedPlugins.length - activePlugins.length),
|
|
upgradeCount: payload.compatible.reduce(function (count, current) {
|
|
if (current.installed && current.outdated) {
|
|
count += 1;
|
|
}
|
|
return count;
|
|
}, 0),
|
|
download: payload.compatible.filter(function (plugin) {
|
|
return !plugin.installed;
|
|
}),
|
|
incompatible: payload.all.filter(function (plugin) {
|
|
return !compatiblePkgNames.includes(plugin.name);
|
|
}),
|
|
submitPluginUsage: meta.config.submitPluginUsage,
|
|
version: nconf.get('version'),
|
|
});
|
|
},
|
|
], next);
|
|
};
|