nodebb-theme-harmony
Advanced tools
Comparing version 0.0.1 to 0.0.2
125
library.js
'use strict'; | ||
const meta = require.main.require('./src/meta'); | ||
const _ = require.main.require('lodash'); | ||
const user = require.main.require('./src/user'); | ||
const controllers = require('./lib/controllers'); | ||
@@ -24,29 +28,100 @@ | ||
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, | ||
// }); | ||
// }); | ||
// }); | ||
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', | ||
// }, | ||
// ]); | ||
areas = areas.concat([ | ||
{ | ||
name: 'Sidebar Footer', | ||
template: 'global', | ||
location: 'sidebar-footer', | ||
}, | ||
]); | ||
return areas; | ||
}; | ||
library.getThemeConfig = async function (config) { | ||
const { enableQuickReply, centerHeaderElements } = await meta.settings.get('harmony'); | ||
config.enableQuickReply = enableQuickReply === 'on'; | ||
config.centerHeaderElements = centerHeaderElements === 'on'; | ||
return config; | ||
}; | ||
library.addUserToTopic = async function (hookData) { | ||
const { enableQuickReply } = await meta.settings.get('harmony'); | ||
if (enableQuickReply === 'on') { | ||
if (hookData.req.user) { | ||
const userData = await user.getUserData(hookData.req.user.uid); | ||
hookData.templateData.loggedInUser = userData; | ||
} else { | ||
hookData.templateData.loggedInUser = { | ||
uid: 0, | ||
username: '[[global:guest]]', | ||
picture: user.getDefaultAvatar(), | ||
'icon:text': '?', | ||
'icon:bgColor': '#aaa', | ||
}; | ||
} | ||
} | ||
return hookData; | ||
}; | ||
library.filterMiddlewareRenderHeader = async function (hookData) { | ||
const userSettings = await user.getSettings(hookData.req.uid); | ||
const lightSkins = [ | ||
'default', 'cerulean', 'cosmo', 'flatly', 'journal', 'litera', | ||
'lumen', 'lux', 'materia', 'minty', 'morph', 'pulse', 'quartz', 'sandstone', | ||
'simplex', 'sketchy', 'spacelab', 'united', 'yeti', 'zephyr', | ||
]; | ||
const darkSkins = [ | ||
'cyborg', 'darkly', 'slate', 'solar', 'superhero', 'vapor', | ||
]; | ||
function parseSkins(skins) { | ||
skins = skins.map(skin => ({ | ||
name: _.capitalize(skin), | ||
value: skin === 'default' ? '' : skin, | ||
})); | ||
skins.forEach((skin) => { | ||
skin.selected = skin.value === userSettings.bootswatchSkin; | ||
}); | ||
return skins; | ||
} | ||
hookData.templateData.bootswatchSkinOptions = { | ||
light: parseSkins(lightSkins), | ||
dark: parseSkins(darkSkins), | ||
}; | ||
hookData.templateData.currentBSSkin = _.capitalize(hookData.templateData.bootswatchSkin); | ||
return hookData; | ||
}; | ||
library.removeFinalBreadcrumb = async (hookData) => { | ||
const { templateData } = hookData; | ||
const { breadcrumbs } = templateData; | ||
const applyTo = ['category', 'topic']; | ||
// Remove the last breadcrumb (the current page) as it is not part of Harmony's design | ||
if (applyTo.includes(hookData.templateData.template.name) && breadcrumbs && breadcrumbs.length) { | ||
breadcrumbs.pop(); | ||
} | ||
return hookData; | ||
}; |
{ | ||
"name": "nodebb-theme-harmony", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"nbbpm": { | ||
@@ -39,3 +39,6 @@ "compatibility": "^3.0.0" | ||
}, | ||
"dependencies": {}, | ||
"dependencies": { | ||
"@fontsource/inter": "^4.5.14", | ||
"@fontsource/poppins": "^4.5.10" | ||
}, | ||
"devDependencies": { | ||
@@ -42,0 +45,0 @@ "eslint": "^8.0.0", |
@@ -6,7 +6,19 @@ { | ||
{ "hook": "filter:admin.header.build", "method": "addAdminNavigation" }, | ||
{ "hook": "filter:widgets.getAreas", "method": "defineWidgetAreas" } | ||
{ "hook": "filter:widgets.getAreas", "method": "defineWidgetAreas" }, | ||
{ "hook": "filter:config.get", "method": "getThemeConfig" }, | ||
{ "hook": "filter:topic.build", "method": "addUserToTopic" }, | ||
{ "hook": "filter:middleware.renderHeader", "method": "filterMiddlewareRenderHeader" }, | ||
{ "hook": "filter:middleware.render", "method": "removeFinalBreadcrumb" } | ||
], | ||
"scripts": [ | ||
"public/harmony.js" | ||
], | ||
"modules": { | ||
"../admin/plugins/harmony.js": "public/admin.js" | ||
} | ||
}, | ||
"staticDirs": { | ||
"inter": "node_modules/@fontsource/inter/files", | ||
"poppins": "node_modules/@fontsource/poppins/files" | ||
}, | ||
"languages": "languages" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
256907
173
249
0
2
4
1
+ Added@fontsource/inter@^4.5.14
+ Added@fontsource/poppins@^4.5.10
+ Added@fontsource/inter@4.5.15(transitive)
+ Added@fontsource/poppins@4.5.10(transitive)