Node.js based forum software built for the modern web
custom user profile covers
psychobunny8e893869ff00
diff --git a/src/controllers/accounts/helpers.js b/src/controllers/accounts/helpers.jsindex 63a25a992a..a34d0df40d 100644--- a/src/controllers/accounts/helpers.js+++ b/src/controllers/accounts/helpers.js@@ -140,7 +140,7 @@ helpers.getBaseUser = function(userslug, callerUID, callback) {results.user.showHidden = results.user.isSelf || results.isAdmin;results.user.profile_links = results.profile_links;- results['cover:url'] = results['cover:url'] || nconf.get('relative_path') + '/images/cover-default.png';+ results['cover:url'] = results['cover:url'] || require('../../coverPhoto').getDefaultProfileCover(results.user.uid);results['cover:position'] = results['cover:position'] || '50% 50%';next(null, results.user);diff --git a/src/controllers/accounts/profile.js b/src/controllers/accounts/profile.jsindex e55ee0d157..40d7fe5367 100644--- a/src/controllers/accounts/profile.js+++ b/src/controllers/accounts/profile.js@@ -72,6 +72,11 @@ profileController.get = function(req, res, callback) {userData.isFollowing = results.isFollowing;userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username}]);userData.title = userData.username;++ userData['cover:url'] = userData['cover:url'] || require('../../coverPhoto').getDefaultProfileCover(userData.uid);+ userData['cover:position'] = userData['cover:position'] || '50% 50%';+ console.log(userData['cover:url']);+if (!userData.profileviews) {userData.profileviews = 1;}diff --git a/src/coverPhoto.js b/src/coverPhoto.jsindex 137d0e0078..d699ace785 100644--- a/src/coverPhoto.js+++ b/src/coverPhoto.js@@ -5,20 +5,28 @@ var meta = require('./meta');var nconf = require('nconf');-coverPhoto.getDefaultCover = function(groupName) {+coverPhoto.getDefaultGroupCover = function(groupName) {return getCover('groups', groupName);};+coverPhoto.getDefaultProfileCover = function(uid) {+ return getCover('profile', parseInt(uid, 10));+};+function getCover(type, id) {- var covers = meta.config[type + ':defaultCovers'].split(/\s*?,\s*?/g);-- if (typeof id === 'string') {- id = (id.charCodeAt(0) + id.charCodeAt(1)) % covers.length;- } else {- id = id % covers.length;+ if (meta.config[type + ':defaultCovers']) {+ var covers = meta.config[type + ':defaultCovers'].split(/\s*?,\s*?/g);++ if (typeof id === 'string') {+ id = (id.charCodeAt(0) + id.charCodeAt(1)) % covers.length;+ } else {+ id = id % covers.length;+ }++ return covers[id];}- return covers && covers.length ? covers[id] : (nconf.get('relative_path') + '/images/cover-default.png');+ return nconf.get('relative_path') + '/images/cover-default.png';}module.exports = coverPhoto;\ No newline at end of filediff --git a/src/groups.js b/src/groups.jsindex 246ca618eb..ab0be677a9 100644--- a/src/groups.js+++ b/src/groups.js@@ -163,7 +163,7 @@ var async = require('async'),return callback(new Error('[[error:no-group]]'));}- results.base['cover:url'] = results.base['cover:url'] || require('./coverPhoto').getDefaultCover(groupName);+ results.base['cover:url'] = results.base['cover:url'] || require('./coverPhoto').getDefaultGroupCover(groupName);results.base['cover:position'] = results.base['cover:position'] || '50% 50%';plugins.fireHook('filter:parse.raw', results.base.description, function(err, descriptionParsed) {diff --git a/src/views/admin/settings/user.tpl b/src/views/admin/settings/user.tplindex f5cc3884ee..dab4ea1196 100644--- a/src/views/admin/settings/user.tpl+++ b/src/views/admin/settings/user.tpl@@ -119,6 +119,19 @@</div></div>+<div class="row">+ <div class="col-sm-2 col-xs-12 settings-header">Profile Cover</div>+ <div class="col-sm-10 col-xs-12">+ <form>+ <label for="profile:defaultCovers"><strong>Default Cover Images</strong></label>+ <p class="help-block">+ Add comma-separated default cover images for accounts that don't have an uploaded cover image+ </p>+ <input type="text" class="form-control input-lg" id="profile:defaultCovers" data-field="profile:defaultCovers" value="{config.relative_path}/images/cover-default.png" placeholder="https://example.com/group1.png, https://example.com/group2.png" />+ </form>+ </div>+</div>+<div class="row"><div class="col-sm-2 col-xs-12 settings-header">Themes</div><div class="col-sm-10 col-xs-12">