feat: bring back noskin option

if forum sets a default skin there was no way for the user to go back to the no skin version
This commit is contained in:
Barış Soner Uşaklı
2023-06-10 11:55:59 -04:00
parent 33a6b3e1da
commit 2edfe0ef3e
7 changed files with 51 additions and 19 deletions

View File

@@ -56,16 +56,8 @@ settingsController.get = async function (req, res, next) {
{ value: 'biweek', name: '[[user:digest_biweekly]]', selected: userData.settings.dailyDigestFreq === 'biweek' },
{ value: 'month', name: '[[user:digest_monthly]]', selected: userData.settings.dailyDigestFreq === 'month' },
];
userData.bootswatchSkinOptions = [
{ name: 'Default', value: '' },
];
userData.bootswatchSkinOptions.push(
...meta.css.supportedSkins.map(skin => ({ name: _.capitalize(skin), value: skin }))
);
userData.bootswatchSkinOptions.forEach((skin) => {
skin.selected = skin.value === userData.settings.bootswatchSkin;
});
getSkinOptions(userData);
userData.languages.forEach((language) => {
language.selected = language.code === userData.settings.userLang;
@@ -227,3 +219,18 @@ async function getHomePageRoutes(userData) {
return routes;
}
function getSkinOptions(userData) {
const defaultSkin = _.capitalize(meta.config.bootswatchSkin) || '[[user:no-skin]]';
userData.bootswatchSkinOptions = [
{ name: '[[user:no-skin]]', value: 'noskin' },
{ name: `[[user:default, ${defaultSkin}]]`, value: '' },
];
userData.bootswatchSkinOptions.push(
...meta.css.supportedSkins.map(skin => ({ name: _.capitalize(skin), value: skin }))
);
userData.bootswatchSkinOptions.forEach((skin) => {
skin.selected = skin.value === userData.settings.bootswatchSkin;
});
}

View File

@@ -98,7 +98,7 @@ apiController.loadConfig = async function (req) {
}
// Handle old skin configs
const oldSkins = ['noskin', 'default'];
const oldSkins = ['default'];
settings.bootswatchSkin = oldSkins.includes(settings.bootswatchSkin) ? '' : settings.bootswatchSkin;
config.usePagination = settings.usePagination;
@@ -113,7 +113,14 @@ apiController.loadConfig = async function (req) {
config.categoryTopicSort = settings.categoryTopicSort || config.categoryTopicSort;
config.topicSearchEnabled = settings.topicSearchEnabled || false;
config.disableCustomUserSkins = meta.config.disableCustomUserSkins === 1;
config.bootswatchSkin = (meta.config.disableCustomUserSkins !== 1 && settings.bootswatchSkin && settings.bootswatchSkin !== '') ? settings.bootswatchSkin : '';
config.defaultBootswatchSkin = config.bootswatchSkin;
if (!config.disableCustomUserSkins && settings.bootswatchSkin) {
if (settings.bootswatchSkin === 'noskin') {
config.bootswatchSkin = '';
} else if (settings.bootswatchSkin !== '') {
config.bootswatchSkin = settings.bootswatchSkin;
}
}
// Overrides based on privilege
config.disableChatMessageEditing = isAdminOrGlobalMod ? false : config.disableChatMessageEditing;

View File

@@ -179,13 +179,13 @@ async function getBundleMetadata(target) {
let themeData = null;
if (target === 'client') {
themeData = await db.getObjectFields('config', ['theme:type', 'theme:id', 'bootswatchSkin']);
themeData = await db.getObjectFields('config', ['theme:type', 'theme:id']);
const themeId = (themeData['theme:id'] || 'nodebb-theme-harmony');
const baseThemePath = path.join(nconf.get('themes_path'), (themeData['theme:type'] && themeData['theme:type'] === 'local' ? themeId : 'nodebb-theme-harmony'));
paths.unshift(baseThemePath);
paths.unshift(`${baseThemePath}/node_modules`);
themeData.bootswatchSkin = skin || themeData.bootswatchSkin;
themeData.bootswatchSkin = skin;
}
const [scssImports, cssImports, acpScssImports] = await Promise.all([

View File

@@ -197,7 +197,7 @@ module.exports = function (middleware) {
results.user['email:confirmed'] = results.user['email:confirmed'] === 1;
results.user.isEmailConfirmSent = !!results.isEmailConfirmSent;
templateValues.bootswatchSkin = (parseInt(meta.config.disableCustomUserSkins, 10) !== 1 ? res.locals.config.bootswatchSkin : '') || meta.config.bootswatchSkin || '';
templateValues.bootswatchSkin = res.locals.config.bootswatchSkin || '';
templateValues.browserTitle = results.browserTitle;
({
navigation: templateValues.navigation,