diff --git a/src/node/hooks/express/adminplugins.js b/src/node/hooks/express/adminplugins.js index 7c0db0973..543f04c0f 100644 --- a/src/node/hooks/express/adminplugins.js +++ b/src/node/hooks/express/adminplugins.js @@ -26,8 +26,8 @@ exports.expressCreateServer = (hookName, args, cb) => { epVersion, installedPlugins: `
${plugins.formatPlugins().replace(/, /g, '\n')}
`, installedParts: `
${plugins.formatParts()}
`, - installedServerHooks: `
${plugins.formatHooks()}
`, - installedClientHooks: `
${plugins.formatHooks('client_hooks')}
`, + installedServerHooks: `
${plugins.formatHooks('hooks', true)}
`, + installedClientHooks: `
${plugins.formatHooks('client_hooks', true)}
`, latestVersion: UpdateCheck.getLatestVersion(), req, })); diff --git a/src/node/server.js b/src/node/server.js index aec0d442f..fc62b4471 100755 --- a/src/node/server.js +++ b/src/node/server.js @@ -144,7 +144,7 @@ exports.start = async () => { .join(', '); logger.info(`Installed plugins: ${installedPlugins}`); logger.debug(`Installed parts:\n${plugins.formatParts()}`); - logger.debug(`Installed hooks:\n${plugins.formatHooks()}`); + logger.debug(`Installed server-side hooks:\n${plugins.formatHooks('hooks', false)}`); await hooks.aCallAll('loadSettings', {settings}); await hooks.aCallAll('createServer'); } catch (err) { diff --git a/src/static/js/pluginfw/plugins.js b/src/static/js/pluginfw/plugins.js index b705fb73a..74fbbafc8 100644 --- a/src/static/js/pluginfw/plugins.js +++ b/src/static/js/pluginfw/plugins.js @@ -28,16 +28,48 @@ exports.formatPlugins = () => Object.keys(defs.plugins).join(', '); exports.formatParts = () => defs.parts.map((part) => part.full_name).join('\n'); -exports.formatHooks = (hookSetName) => { - const res = []; - const hooks = pluginUtils.extractHooks(defs.parts, hookSetName || 'hooks'); - for (const registeredHooks of Object.values(hooks)) { - for (const hook of registeredHooks) { - res.push(`
${hook.hook_name}
${hook.hook_fn_name} ` + - `from ${hook.part.full_name}
`); +exports.formatHooks = (hookSetName, html) => { + let hooks = new Map(); + for (const [pluginName, def] of Object.entries(defs.plugins)) { + for (const part of def.parts) { + for (const [hookName, hookFnName] of Object.entries(part[hookSetName] || {})) { + let hookEntry = hooks.get(hookName); + if (!hookEntry) { + hookEntry = new Map(); + hooks.set(hookName, hookEntry); + } + let pluginEntry = hookEntry.get(pluginName); + if (!pluginEntry) { + pluginEntry = new Map(); + hookEntry.set(pluginName, pluginEntry); + } + pluginEntry.set(part.name, hookFnName); + } } } - return `
${res.join('\n')}
`; + const lines = []; + const sortStringKeys = (a, b) => String(a[0]).localeCompare(b[0]); + if (html) lines.push('
'); + hooks = new Map([...hooks].sort(sortStringKeys)); + for (const [hookName, hookEntry] of hooks) { + lines.push(html ? `
${hookName}:
` : ` ${hookName}:`); + const sortedHookEntry = new Map([...hookEntry].sort(sortStringKeys)); + hooks.set(hookName, sortedHookEntry); + for (const [pluginName, pluginEntry] of sortedHookEntry) { + lines.push(html ? `
${pluginName}:
` : ` ${pluginName}:`); + const sortedPluginEntry = new Map([...pluginEntry].sort(sortStringKeys)); + sortedHookEntry.set(pluginName, sortedPluginEntry); + for (const [partName, hookFnName] of sortedPluginEntry) { + lines.push(html + ? `
${partName}:
${hookFnName}
` + : ` ${partName}: ${hookFnName}`); + } + if (html) lines.push('
'); + } + if (html) lines.push('
'); + } + if (html) lines.push('
'); + return lines.join('\n'); }; const callInit = async () => {