diff --git a/client/views/posts/modules/post_author.html b/client/views/posts/modules/post_author.html
new file mode 100644
index 000000000..d0b127baf
--- /dev/null
+++ b/client/views/posts/modules/post_author.html
@@ -0,0 +1,3 @@
+
+ By {{authorName}},
+
\ No newline at end of file
diff --git a/client/views/posts/modules/post_author.js b/client/views/posts/modules/post_author.js
new file mode 100644
index 000000000..76fdc6954
--- /dev/null
+++ b/client/views/posts/modules/post_author.js
@@ -0,0 +1,11 @@
+Template[getTemplate('postAuthor')].helpers({
+ authorName: function(){
+ return getAuthorName(this);
+ },
+ profileUrl: function(){
+ // note: we don't want the post to be re-rendered every time user properties change
+ var user = Meteor.users.findOne(this.userId, {reactive: false});
+ if(user)
+ return getProfileUrl(user);
+ }
+})
diff --git a/client/views/posts/modules/post_info.html b/client/views/posts/modules/post_info.html
index 19b0b860c..b6359837c 100644
--- a/client/views/posts/modules/post_info.html
+++ b/client/views/posts/modules/post_info.html
@@ -1,8 +1,10 @@
-
{{baseScore}} {{pointsUnitDisplayText}} by
{{authorName}} {{timeAgo ago}}
+
{{baseScore}}
+
{{pointsUnitDisplayText}}
+
{{timeAgo ago}}
{{#if can_edit}}
|
{{_ "edit"}}
{{/if}}
-
\ No newline at end of file
+
diff --git a/client/views/posts/modules/post_info.js b/client/views/posts/modules/post_info.js
index 1711b4df3..1468c632d 100644
--- a/client/views/posts/modules/post_info.js
+++ b/client/views/posts/modules/post_info.js
@@ -5,18 +5,12 @@ Template[getTemplate('postInfo')].helpers({
can_edit: function(){
return canEdit(Meteor.user(), this);
},
- authorName: function(){
- return getAuthorName(this);
- },
ago: function(){
// if post is approved show submission time, else show creation time.
time = this.status == STATUS_APPROVED ? this.postedAt : this.createdAt;
return time;
},
- profileUrl: function(){
- // note: we don't want the post to be re-rendered every time user properties change
- var user = Meteor.users.findOne(this.userId, {reactive: false});
- if(user)
- return getProfileUrl(user);
+ getTemplate: function() {
+ return getTemplate("postAuthor");
}
});
\ No newline at end of file
diff --git a/client/views/users/user_edit.js b/client/views/users/user_edit.js
index ae36adff6..146d6fd2c 100644
--- a/client/views/users/user_edit.js
+++ b/client/views/users/user_edit.js
@@ -71,6 +71,10 @@ Template[getTemplate('user_edit')].events({
});
}
+ update = userEditClientCallbacks.reduce(function(result, currentFunction) {
+ return currentFunction(user, result);
+ }, update);
+
Meteor.users.update(user._id, {
$set: update
}, function(error){
@@ -89,4 +93,4 @@ Template[getTemplate('user_edit')].events({
}
-});
\ No newline at end of file
+});
diff --git a/collections/users.js b/collections/users.js
index ebd7a73b7..060b9e07f 100644
--- a/collections/users.js
+++ b/collections/users.js
@@ -1,6 +1,5 @@
var Schema = {};
-
-Schema.User = new SimpleSchema({
+var userSchemaObj = {
_id: {
type: String,
optional: true
@@ -42,7 +41,14 @@ Schema.User = new SimpleSchema({
optional: true,
blackbox: true
}
+};
+
+
+// add any extra properties to postSchemaObject (provided by packages for example)
+_.each(addToUserSchema, function(item){
+ userSchemaObj[item.propertyName] = item.propertySchema;
});
+Schema.User = new SimpleSchema(userSchemaObj);
// Meteor.users.attachSchema(Schema.User);
diff --git a/lib/users.js b/lib/users.js
index fc4029d61..0cfd5386f 100644
--- a/lib/users.js
+++ b/lib/users.js
@@ -93,7 +93,12 @@ getCurrentUserEmail = function(){
return Meteor.user() ? getEmail(Meteor.user()) : '';
};
userProfileComplete = function(user) {
- return !!getEmail(user);
+ for (var i = 0; i < userProfileCompleteChecks.length; i++) {
+ if (!userProfileCompleteChecks[i](user)) {
+ return false;
+ }
+ }
+ return true;
};
findLast = function(user, collection){
diff --git a/packages/telescope-base/lib/base.js b/packages/telescope-base/lib/base.js
index bdbb15452..ecda3d1ab 100644
--- a/packages/telescope-base/lib/base.js
+++ b/packages/telescope-base/lib/base.js
@@ -4,6 +4,7 @@
addToPostSchema = [];
addToCommentsSchema = [];
addToSettingsSchema = [];
+addToUserSchema = [];
SimpleSchema.extendOptions({
editable: Match.Optional(Boolean), // editable: true means the field can be edited by the document's owner
@@ -155,13 +156,17 @@ postHeading = [
template: 'postDomain',
order: 5
}
-]
+];
postMeta = [
{
- template: 'postInfo',
+ template: 'postAuthor',
order: 1
},
+ {
+ template: 'postInfo',
+ order: 2
+ },
{
template: 'postCommentsLink',
order: 3
@@ -193,6 +198,16 @@ commentEditClientCallbacks = [];
commentEditMethodCallbacks = []; // not used yet
commentAfterEditMethodCallbacks = []; // not used yet
+userEditRenderedCallbacks = [];
+userEditClientCallbacks = [];
+
+userProfileCompleteChecks = [
+ function(user) {
+ return !!getEmail(user) && !!user.username;
+ }
+];
+
+
// ------------------------------ Dynamic Templates ------------------------------ //
diff --git a/packages/telescope-base/package.js b/packages/telescope-base/package.js
index 3120132ab..5ee4af58a 100644
--- a/packages/telescope-base/package.js
+++ b/packages/telescope-base/package.js
@@ -20,6 +20,7 @@ Package.onUse(function (api) {
'addToPostSchema',
'addToCommentsSchema',
'addToSettingsSchema',
+ 'addToUserSchema',
'preloadSubscriptions',
'primaryNav',
'secondaryNav',
@@ -50,10 +51,14 @@ Package.onUse(function (api) {
'commentEditClientCallbacks',
'commentEditMethodCallbacks',
'commentAfterEditMethodCallbacks',
+
+ 'userEditRenderedCallbacks',
+ 'userEditClientCallbacks',
+ 'userProfileCompleteChecks',
'getTemplate',
'templates',
'themeSettings'
]);
-});
\ No newline at end of file
+});