Skip to content

Commit

Permalink
feat: add template name to body class
Browse files Browse the repository at this point in the history
allows styling pages based on template ie .template-groups-details
add allowCoverPicture to all profile routes
  • Loading branch information
barisusakli committed Jan 5, 2023
1 parent 71743af commit 3efad2e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/controllers/accounts/helpers.js
Expand Up @@ -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));
Expand Down
1 change: 0 additions & 1 deletion src/controllers/accounts/profile.js
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/middleware/helpers.js
Expand Up @@ -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)}`);
Expand Down

0 comments on commit 3efad2e

Please sign in to comment.