From 04dcd38d045e738b75b2b05e38345c160822d8c1 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 29 Oct 2015 13:48:58 -0400 Subject: [PATCH 1/5] added new client-side hook on thread tools open --- public/src/client/topic/threadTools.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/src/client/topic/threadTools.js b/public/src/client/topic/threadTools.js index 69c8fad673..7f6c2a773c 100644 --- a/public/src/client/topic/threadTools.js +++ b/public/src/client/topic/threadTools.js @@ -112,6 +112,7 @@ define('forum/topic/threadTools', ['forum/topic/fork', 'forum/topic/move', 'comp templates.parse('partials/topic/topic-menu-list', data, function(html) { translator.translate(html, function(html) { dropdownMenu.html(html); + $(window).trigger('action:topic.tools.load'); }); }); }); From 7148d44f9097f687c26c33e71505d7126469e782 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Thu, 29 Oct 2015 14:55:04 -0400 Subject: [PATCH 2/5] default cover images for groups --- src/coverPhoto.js | 24 ++++++++++++++++++++++++ src/groups.js | 7 ++----- src/views/admin/settings/group.tpl | 6 ++++++ 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 src/coverPhoto.js diff --git a/src/coverPhoto.js b/src/coverPhoto.js new file mode 100644 index 0000000000..137d0e0078 --- /dev/null +++ b/src/coverPhoto.js @@ -0,0 +1,24 @@ +"use strict"; + +var coverPhoto = {}; +var meta = require('./meta'); +var nconf = require('nconf'); + + +coverPhoto.getDefaultCover = function(groupName) { + return getCover('groups', groupName); +}; + +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; + } + + return covers && covers.length ? covers[id] : (nconf.get('relative_path') + '/images/cover-default.png'); +} + +module.exports = coverPhoto; \ No newline at end of file diff --git a/src/groups.js b/src/groups.js index 646843bde3..246ca618eb 100644 --- a/src/groups.js +++ b/src/groups.js @@ -163,11 +163,8 @@ var async = require('async'), return callback(new Error('[[error:no-group]]')); } - // Default image - if (!results.base['cover:url']) { - results.base['cover:url'] = nconf.get('relative_path') + '/images/cover-default.png'; - results.base['cover:position'] = '50% 50%'; - } + results.base['cover:url'] = results.base['cover:url'] || require('./coverPhoto').getDefaultCover(groupName); + results.base['cover:position'] = results.base['cover:position'] || '50% 50%'; plugins.fireHook('filter:parse.raw', results.base.description, function(err, descriptionParsed) { if (err) { diff --git a/src/views/admin/settings/group.tpl b/src/views/admin/settings/group.tpl index fb71beda6b..c04abe872a 100644 --- a/src/views/admin/settings/group.tpl +++ b/src/views/admin/settings/group.tpl @@ -28,6 +28,12 @@

If enabled, users can create groups (Default: disabled)

+ + +

+ Add comma-separated default cover images for groups that don't have an uploaded cover image +

+
From 8e893869ff0028be5fc303b944cc62a33026f1b0 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Thu, 29 Oct 2015 15:11:52 -0400 Subject: [PATCH 3/5] custom user profile covers --- src/controllers/accounts/helpers.js | 2 +- src/controllers/accounts/profile.js | 5 +++++ src/coverPhoto.js | 24 ++++++++++++++++-------- src/groups.js | 2 +- src/views/admin/settings/user.tpl | 13 +++++++++++++ 5 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/controllers/accounts/helpers.js b/src/controllers/accounts/helpers.js index 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.js index 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.js index 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 file diff --git a/src/groups.js b/src/groups.js index 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.tpl index f5cc3884ee..dab4ea1196 100644 --- a/src/views/admin/settings/user.tpl +++ b/src/views/admin/settings/user.tpl @@ -119,6 +119,19 @@ +
+
Profile Cover
+
+
+ +

+ Add comma-separated default cover images for accounts that don't have an uploaded cover image +

+ +
+
+
+
Themes
From a670f2facc29b099d489a0888af075904f5fa5da Mon Sep 17 00:00:00 2001 From: psychobunny Date: Thu, 29 Oct 2015 15:13:06 -0400 Subject: [PATCH 4/5] organized cover acp pages --- src/views/admin/settings/group.tpl | 7 +++++++ src/views/admin/settings/user.tpl | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/views/admin/settings/group.tpl b/src/views/admin/settings/group.tpl index c04abe872a..17cefdf00e 100644 --- a/src/views/admin/settings/group.tpl +++ b/src/views/admin/settings/group.tpl @@ -28,7 +28,14 @@

If enabled, users can create groups (Default: disabled)

+ +
+
+
+
Group Cover Image
+
+

Add comma-separated default cover images for groups that don't have an uploaded cover image diff --git a/src/views/admin/settings/user.tpl b/src/views/admin/settings/user.tpl index dab4ea1196..8156621812 100644 --- a/src/views/admin/settings/user.tpl +++ b/src/views/admin/settings/user.tpl @@ -120,7 +120,7 @@

-
Profile Cover
+
Profile Cover Image
From f385e1353168228c1c62c01ec045c6e1e4b55232 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Thu, 29 Oct 2015 15:16:49 -0400 Subject: [PATCH 5/5] fix default cover on groups/list page --- src/groups.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/groups.js b/src/groups.js index ab0be677a9..194534839d 100644 --- a/src/groups.js +++ b/src/groups.js @@ -403,10 +403,9 @@ var async = require('async'), group.hidden = parseInt(group.hidden, 10) === 1; group.system = parseInt(group.system, 10) === 1; group.private = parseInt(group.private, 10) === 1; - if (!group['cover:url']) { - group['cover:url'] = nconf.get('relative_path') + '/images/cover-default.png'; - group['cover:position'] = '50% 50%'; - } + + group['cover:url'] = group['cover:url'] || require('./coverPhoto').getDefaultGroupCover(group.name); + group['cover:position'] = group['cover:position'] || '50% 50%'; } });