# Server-side hooks These hooks are called on server-side. ## loadSettings Called from: src/node/server.js Things in context: 1. settings - the settings object Use this hook to receive the global settings in your plugin. ## shutdown Called from: src/node/server.js Things in context: None This hook runs before shutdown. Use it to stop timers, close sockets and files, flush buffers, etc. The database is not available while this hook is running. The shutdown function must not block for long because there is a short timeout before the process is forcibly terminated. The shutdown function must return a Promise, which must resolve to `undefined`. Returning `callback(value)` will return a Promise that is resolved to `value`. Example: ``` // using an async function exports.shutdown = async (hookName, context) => { await flushBuffers(); }; ``` ## pluginUninstall Called from: src/static/js/pluginfw/installer.js Things in context: 1. plugin_name - self-explanatory If this hook returns an error, the callback to the uninstall function gets an error as well. This mostly seems useful for handling additional features added in based on the installation of other plugins, which is pretty cool! ## pluginInstall Called from: src/static/js/pluginfw/installer.js Things in context: 1. plugin_name - self-explanatory If this hook returns an error, the callback to the install function gets an error, too. This seems useful for adding in features when a particular plugin is installed. ## init_`` Called from: src/static/js/pluginfw/plugins.js Things in context: None This function is called after a specific plugin is initialized. This would probably be more useful than the previous two functions if you only wanted to add in features to one specific plugin. ## expressConfigure Called from: src/node/hooks/express.js Things in context: 1. app - the main application object This is a helpful hook for changing the behavior and configuration of the application. It's called right after the application gets configured. ## expressCreateServer Called from: src/node/hooks/express.js Things in context: 1. app - the main express application object (helpful for adding new paths and such) 2. server - the http server object This hook gets called after the application object has been created, but before it starts listening. This is similar to the expressConfigure hook, but it's not guaranteed that the application object will have all relevant configuration variables. ## eejsBlock_`` Called from: src/node/eejs/index.js Things in context: 1. content - the content of the block This hook gets called upon the rendering of an ejs template block. For any specific kind of block, you can change how that block gets rendered by modifying the content object passed in. Available blocks in `pad.html` are: * `htmlHead` - after `` and immediately before the title tag * `styles` - the style ``s * `body` - the contents of the body tag * `editbarMenuLeft` - the left tool bar (consider using the toolbar controller instead of manually adding html here) * `editbarMenuRight` - right tool bar * `afterEditbar` - allows you to add stuff immediately after the toolbar * `userlist` - the contents of the userlist dropdown * `loading` - the initial loading message * `mySettings` - the left column of the settings dropdown ("My view"); intended for adding checkboxes only * `mySettings.dropdowns` - add your dropdown settings here * `globalSettings` - the right column of the settings dropdown ("Global view") * `importColumn` - import form * `exportColumn` - export form * `modals` - Contains all connectivity messages * `embedPopup` - the embed dropdown * `scripts` - Add your script tags here, if you really have to (consider use client-side hooks instead) `timeslider.html` blocks: * `timesliderStyles` * `timesliderScripts` * `timesliderBody` * `timesliderTop` * `timesliderEditbarRight` * `modals` `index.html` blocks: * `indexCustomStyles` - contains the `index.css` `` tag, allows you to add your own or to customize the one provided by the active skin * `indexWrapper` - contains the form for creating new pads * `indexCustomScripts` - contains the `index.js` `