From 3efad2e13b7319eb9a1f4fda7af047be43ebc11f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 5 Jan 2023 17:24:03 -0500 Subject: [PATCH] feat: add template name to body class allows styling pages based on template ie .template-groups-details add allowCoverPicture to all profile routes --- src/controllers/accounts/helpers.js | 1 + src/controllers/accounts/profile.js | 1 - src/middleware/helpers.js | 4 ++++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/controllers/accounts/helpers.js b/src/controllers/accounts/helpers.js index a0c0a0608c..a70ba77580 100644 --- a/src/controllers/accounts/helpers.js +++ b/src/controllers/accounts/helpers.js @@ -77,6 +77,7 @@ helpers.getUserDataByUserSlug = async function (userslug, callerUID, query = {}) userData.isFollowing = results.isFollowing; userData.hasPrivateChat = results.hasPrivateChat; userData.showHidden = results.canEdit; // remove in v1.19.0 + userData.allowCoverPicture = !userData.isSelf || !!meta.config['reputation:disabled'] || userData.reputation >= meta.config['min:rep:cover-picture']; userData.groups = Array.isArray(results.groups) && results.groups.length ? results.groups[0] : []; userData.selectedGroup = userData.groups.filter(group => group && userData.groupTitleArray.includes(group.name)) .sort((a, b) => userData.groupTitleArray.indexOf(a.name) - userData.groupTitleArray.indexOf(b.name)); diff --git a/src/controllers/accounts/profile.js b/src/controllers/accounts/profile.js index 0401f5b31e..5992cda0ca 100644 --- a/src/controllers/accounts/profile.js +++ b/src/controllers/accounts/profile.js @@ -49,7 +49,6 @@ profileController.get = async function (req, res, next) { userData.bestPosts = bestPosts; userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username }]); userData.title = userData.username; - userData.allowCoverPicture = !userData.isSelf || !!meta.config['reputation:disabled'] || userData.reputation >= meta.config['min:rep:cover-picture']; // Show email changed modal on first access after said change userData.emailChanged = req.session.emailChanged; diff --git a/src/middleware/helpers.js b/src/middleware/helpers.js index e31d86299a..e92f8b272b 100644 --- a/src/middleware/helpers.js +++ b/src/middleware/helpers.js @@ -42,6 +42,10 @@ helpers.buildBodyClass = function (req, res, templateData = {}) { parts[index] = index ? `${parts[0]}-${p}` : `page-${p || 'home'}`; }); + if (templateData.template) { + parts.push(`template-${templateData.template.name.split('/').join('-')}`); + } + if (templateData.template && templateData.template.topic) { parts.push(`page-topic-category-${templateData.category.cid}`); parts.push(`page-topic-category-${slugify(templateData.category.name)}`);