UNPKG

nodebb-theme-peace

Version:
69 lines (57 loc) 1.74 kB
'use strict'; const meta = require.main.require('./src/meta'); const library = module.exports; library.init = async function (params) { const { router } = params; const routeHelpers = require.main.require('./src/routes/helpers'); routeHelpers.setupAdminPageRoute(router, '/admin/plugins/peace', function (req, res) { res.render('admin/plugins/peace', { title: 'Peace Theme', }); }); }; library.defineWidgetAreas = async function (areas) { const locations = ['header', 'sidebar', 'footer']; const templates = [ 'categories.tpl', 'category.tpl', 'topic.tpl', 'users.tpl', 'unread.tpl', 'recent.tpl', 'popular.tpl', 'top.tpl', 'tags.tpl', 'tag.tpl', 'login.tpl', 'register.tpl', ]; function capitalizeFirst(str) { return str.charAt(0).toUpperCase() + str.slice(1); } templates.forEach((template) => { locations.forEach((location) => { areas.push({ name: `${capitalizeFirst(template.split('.')[0])} ${capitalizeFirst(location)}`, template: template, location: location, }); }); }); areas = areas.concat([ { name: 'Account Header', template: 'account/profile.tpl', location: 'header', }, ]); return areas; }; library.filterConfigGet = async function (config) { const settings = await meta.settings.get('peace'); config.enableQuickReply = settings.enableQuickReply === 'on'; return config; }; library.addAdminNavigation = async function (header) { header.plugins.push({ route: '/plugins/peace', icon: 'fa-paint-brush', name: 'Peace Theme', }); return header; }; library.filterMiddlewareRenderHeader = async function (hookData) { hookData.templateData.bootswatchSkinOptions = await meta.css.getSkinSwitcherOptions(hookData.req.uid); return hookData; };