mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 18:11:40 -05:00
Merge branch 'AdmitHub-telescope-master-profile-hooks'
This commit is contained in:
commit
f2965feb5a
9 changed files with 62 additions and 17 deletions
3
client/views/posts/modules/post_author.html
Normal file
3
client/views/posts/modules/post_author.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
<template name="postAuthor">
|
||||
By <a class="post-author" href="{{profileUrl}}">{{authorName}}</a>,
|
||||
</template>
|
11
client/views/posts/modules/post_author.js
Normal file
11
client/views/posts/modules/post_author.js
Normal file
|
@ -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);
|
||||
}
|
||||
})
|
|
@ -1,8 +1,10 @@
|
|||
<template name="postInfo">
|
||||
<div class="post-meta-item">
|
||||
<span class="points">{{baseScore}} <span class="unit">{{pointsUnitDisplayText}} </span></span>by <a class="post-author" href="{{profileUrl}}">{{authorName}}</a> <span class="post-time">{{timeAgo ago}}</span>
|
||||
<span class="points">{{baseScore}}</span>
|
||||
<span class="unit">{{pointsUnitDisplayText}}</span>
|
||||
<span class="post-time">{{timeAgo ago}}</span>
|
||||
{{#if can_edit}}
|
||||
| <a href="/posts/{{_id}}/edit" class="edit-link goto-edit">{{_ "edit"}}</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
});
|
|
@ -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({
|
|||
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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 ------------------------------ //
|
||||
|
||||
|
||||
|
|
|
@ -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'
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue