mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 18:11:40 -05:00
using spacebars helpers for profileUrl, username, and displayName
This commit is contained in:
parent
7c39487090
commit
affec3c1c8
15 changed files with 19 additions and 24 deletions
|
@ -17,7 +17,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="comment-meta">
|
<div class="comment-meta">
|
||||||
<div class="user-avatar avatar-medium" aria-hidden="true" aria-live="off">{{> avatar userId=userId shape="circle"}}</div>
|
<div class="user-avatar avatar-medium" aria-hidden="true" aria-live="off">{{> avatar userId=userId shape="circle"}}</div>
|
||||||
<a class="comment-username" href="{{profileUrl}}">{{authorName}}</a>
|
<a class="comment-username" href="{{getProfileUrl userId}}">{{authorName}}</a>
|
||||||
<a href="{{pathFor route='comment_reply' _id=_id}}" class="comment-permalink comment-time">{{timeAgo ago}},</a>
|
<a href="{{pathFor route='comment_reply' _id=_id}}" class="comment-permalink comment-time">{{timeAgo ago}},</a>
|
||||||
<span class="points">{{upvotes}}</span> <span class="unit">points </span>
|
<span class="points">{{upvotes}}</span> <span class="unit">points </span>
|
||||||
{{#if canEdit this}}
|
{{#if canEdit this}}
|
||||||
|
|
|
@ -96,12 +96,6 @@ Template.comment_item.helpers({
|
||||||
},
|
},
|
||||||
downvoted: function(){
|
downvoted: function(){
|
||||||
return Meteor.user() && _.include(this.downvoters, Meteor.user()._id);
|
return Meteor.user() && _.include(this.downvoters, Meteor.user()._id);
|
||||||
},
|
|
||||||
profileUrl: function(){
|
|
||||||
var user = Meteor.users.findOne(this.userId);
|
|
||||||
if (user) {
|
|
||||||
return Users.getProfileUrl(user);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -63,21 +63,21 @@ Template.registerHelper('pluralize', function(count, string) {
|
||||||
return i18n.t(string);
|
return i18n.t(string);
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.registerHelper('profileUrl', function(userOrUserId) {
|
Template.registerHelper('getProfileUrl', function(userOrUserId) {
|
||||||
var user = (typeof userOrUserId === 'string') ? Meteor.users.findOne(userOrUserId) : userOrUserId;
|
var user = (typeof userOrUserId === 'string') ? Meteor.users.findOne(userOrUserId) : userOrUserId;
|
||||||
if (!!user) {
|
if (!!user) {
|
||||||
return Users.getProfileUrl(user);
|
return Users.getProfileUrl(user);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.registerHelper('userName', function(userOrUserId) {
|
Template.registerHelper('getUsername', function(userOrUserId) {
|
||||||
var user = (typeof userOrUserId === 'string') ? Meteor.users.findOne(userOrUserId) : userOrUserId;
|
var user = (typeof userOrUserId === 'string') ? Meteor.users.findOne(userOrUserId) : userOrUserId;
|
||||||
if (!!user) {
|
if (!!user) {
|
||||||
return Users.getUserName(user);
|
return Users.getUserName(user);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.registerHelper('displayName', function(userOrUserId) {
|
Template.registerHelper('getDisplayName', function(userOrUserId) {
|
||||||
var user = (typeof userOrUserId === 'string') ? Meteor.users.findOne(userOrUserId) : userOrUserId;
|
var user = (typeof userOrUserId === 'string') ? Meteor.users.findOne(userOrUserId) : userOrUserId;
|
||||||
if (!!user) {
|
if (!!user) {
|
||||||
return Users.getDisplayName(user);
|
return Users.getDisplayName(user);
|
||||||
|
|
|
@ -62,7 +62,7 @@ Router._filters = {
|
||||||
if(!this.ready() || Meteor.loggingIn()){
|
if(!this.ready() || Meteor.loggingIn()){
|
||||||
this.render('loading');
|
this.render('loading');
|
||||||
} else if (!Users.can.view()) {
|
} else if (!Users.can.view()) {
|
||||||
this.render('no_rights');
|
this.render('no_invite');
|
||||||
} else {
|
} else {
|
||||||
this.next();
|
this.next();
|
||||||
}
|
}
|
||||||
|
@ -200,10 +200,10 @@ Meteor.startup( function (){
|
||||||
// Before Hooks
|
// Before Hooks
|
||||||
|
|
||||||
Router.onBeforeAction(filters.isReady);
|
Router.onBeforeAction(filters.isReady);
|
||||||
|
Router.onBeforeAction(filters.hasCompletedProfile);
|
||||||
Router.onBeforeAction(filters.canView, {except: ['atSignIn', 'atSignUp', 'atForgotPwd', 'atResetPwd', 'signOut']});
|
Router.onBeforeAction(filters.canView, {except: ['atSignIn', 'atSignUp', 'atForgotPwd', 'atResetPwd', 'signOut']});
|
||||||
Router.onBeforeAction(filters.canViewPendingPosts, {only: ['post_page']});
|
Router.onBeforeAction(filters.canViewPendingPosts, {only: ['post_page']});
|
||||||
Router.onBeforeAction(filters.canViewRejectedPosts, {only: ['post_page']});
|
Router.onBeforeAction(filters.canViewRejectedPosts, {only: ['post_page']});
|
||||||
Router.onBeforeAction(filters.hasCompletedProfile);
|
|
||||||
Router.onBeforeAction(filters.isLoggedOut, {only: []});
|
Router.onBeforeAction(filters.isLoggedOut, {only: []});
|
||||||
Router.onBeforeAction(filters.canPost, {only: ['posts_pending', 'post_submit']});
|
Router.onBeforeAction(filters.canPost, {only: ['posts_pending', 'post_submit']});
|
||||||
Router.onBeforeAction(filters.canEditPost, {only: ['post_edit']});
|
Router.onBeforeAction(filters.canEditPost, {only: ['post_edit']});
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<template name="postAuthor">
|
<template name="postAuthor">
|
||||||
<a class="post-author" href="{{profileUrl userId}}">{{displayName userId}}</a>
|
<a class="post-author" href="{{getProfileUrl userId}}">{{getDisplayName userId}}</a>
|
||||||
</template>
|
</template>
|
|
@ -1,12 +1,12 @@
|
||||||
<template name="postAvatars">
|
<template name="postAvatars">
|
||||||
<div aria-hidden="true" aria-live="off">
|
<div aria-hidden="true" aria-live="off">
|
||||||
<a href="{{profileUrl userId}}" class="avatar-link avatar-small author-avatar">
|
<a href="{{getProfileUrl userId}}" class="avatar-link avatar-small author-avatar">
|
||||||
{{> avatar userId=userId shape="circle"}}
|
{{> avatar userId=userId shape="circle"}}
|
||||||
</a>
|
</a>
|
||||||
{{#if commenters}}
|
{{#if commenters}}
|
||||||
<div class="post-commenters">
|
<div class="post-commenters">
|
||||||
{{#each commenters}}
|
{{#each commenters}}
|
||||||
<a href="{{profileUrl this}}" class="avatar-link avatar-small commenter-avatar">
|
<a href="{{getProfileUrl this}}" class="avatar-link avatar-small commenter-avatar">
|
||||||
{{> avatar userId=this shape="circle"}}
|
{{> avatar userId=this shape="circle"}}
|
||||||
</a>
|
</a>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
|
@ -31,7 +31,7 @@ function setupUser (user, options) {
|
||||||
user.telescope.displayName = user.username;
|
user.telescope.displayName = user.username;
|
||||||
|
|
||||||
// create slug from username
|
// create slug from username
|
||||||
user.telescope.slug = Telescope.utils.slugify(user.username);
|
user.telescope.slug = Telescope.utils.slugify(Users.getUserName(user));
|
||||||
|
|
||||||
// if this is not a dummy account, and is the first user ever, make them an admin
|
// if this is not a dummy account, and is the first user ever, make them an admin
|
||||||
user.isAdmin = (!user.profile.isDummy && Meteor.users.find({'profile.isDummy': {$ne: true}}).count() === 0) ? true : false;
|
user.isAdmin = (!user.profile.isDummy && Meteor.users.find({'profile.isDummy': {$ne: true}}).count() === 0) ? true : false;
|
||||||
|
|
|
@ -9,7 +9,7 @@ Template.usersDashboard.helpers({
|
||||||
{ key: 'createdAt', label: 'Member Since', tmpl: Template.users_list_created_at, sort: 'descending' },
|
{ key: 'createdAt', label: 'Member Since', tmpl: Template.users_list_created_at, sort: 'descending' },
|
||||||
{ key: 'isAdmin', label: 'Admin', fn: function(val){return val ? 'Yes':'No'} },
|
{ key: 'isAdmin', label: 'Admin', fn: function(val){return val ? 'Yes':'No'} },
|
||||||
{ key: 'username', label: 'Username', tmpl: Template.users_list_username },
|
{ key: 'username', label: 'Username', tmpl: Template.users_list_username },
|
||||||
{ key: 'telescope.displayName', label: 'Display Name' },
|
{ key: 'telescope.displayName', label: 'Display Name', tmpl: Template.users_list_display_name },
|
||||||
{ key: 'telescope.email', label: 'Email', tmpl: Template.users_list_email },
|
{ key: 'telescope.email', label: 'Email', tmpl: Template.users_list_email },
|
||||||
{ key: 'telescope.postCount', label: 'Posts' },
|
{ key: 'telescope.postCount', label: 'Posts' },
|
||||||
{ key: 'telescope.commentCount', label: 'Comments' },
|
{ key: 'telescope.commentCount', label: 'Comments' },
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<template name="users_list_avatar">
|
<template name="users_list_avatar">
|
||||||
{{> avatar user=this shape="circle"}}
|
<a href="{{getProfileUrl this}}">{{> avatar user=this shape="circle"}}</a>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
<template name="users_list_display_name">
|
||||||
|
<a href="{{getProfileUrl this}}">{{getDisplayName this}}</a>
|
||||||
|
</template>
|
|
@ -1,3 +1,3 @@
|
||||||
<template name="users_list_username">
|
<template name="users_list_username">
|
||||||
<a href="{{profileUrl this}}">{{username}}</a>
|
<a href="{{getProfileUrl this}}">{{getUsername this}}</a>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<tr class="user">
|
<tr class="user">
|
||||||
<td aria-hidden="true">{{> avatar user=this shape="circle"}}</td>
|
<td aria-hidden="true">{{> avatar user=this shape="circle"}}</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{getProfileUrl}}">{{displayName}}</a>
|
<a href="{{getProfileUrl}}">{{getDisplayName this}}</a>
|
||||||
<br/>
|
<br/>
|
||||||
<a href="mailto:{{getEmail}}">{{getEmail}}</a>
|
<a href="mailto:{{getEmail}}">{{getEmail}}</a>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -2,9 +2,6 @@ Template.user_item.helpers({
|
||||||
createdAtFormatted: function(){
|
createdAtFormatted: function(){
|
||||||
return this.createdAt ? moment(this.createdAt).fromNow() : '–';
|
return this.createdAt ? moment(this.createdAt).fromNow() : '–';
|
||||||
},
|
},
|
||||||
displayName: function(){
|
|
||||||
return Users.getDisplayName(this);
|
|
||||||
},
|
|
||||||
getEmail: function(){
|
getEmail: function(){
|
||||||
return Users.getEmail(this);
|
return Users.getEmail(this);
|
||||||
},
|
},
|
||||||
|
|
|
@ -40,7 +40,7 @@ Users.getDisplayNameById = function (userId) {return Users.getDisplayName(Meteor
|
||||||
* @param {Object} user
|
* @param {Object} user
|
||||||
*/
|
*/
|
||||||
Users.getProfileUrl = function (user) {
|
Users.getProfileUrl = function (user) {
|
||||||
return this.getProfileUrlBySlugOrId(user.telescope.slug);
|
return Users.getProfileUrlBySlugOrId(user.telescope.slug);
|
||||||
};
|
};
|
||||||
Users.helpers({getProfileUrl: function () {return Users.getProfileUrl(this);}});
|
Users.helpers({getProfileUrl: function () {return Users.getProfileUrl(this);}});
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ Package.onUse(function (api) {
|
||||||
'lib/client/templates/dashboard/users_list_created_at.html',
|
'lib/client/templates/dashboard/users_list_created_at.html',
|
||||||
'lib/client/templates/dashboard/users_list_email.html',
|
'lib/client/templates/dashboard/users_list_email.html',
|
||||||
'lib/client/templates/dashboard/users_list_username.html',
|
'lib/client/templates/dashboard/users_list_username.html',
|
||||||
|
'lib/client/templates/dashboard/users_list_display_name.html',
|
||||||
'lib/client/templates/profile/user_comments.html',
|
'lib/client/templates/profile/user_comments.html',
|
||||||
'lib/client/templates/profile/user_comments.js',
|
'lib/client/templates/profile/user_comments.js',
|
||||||
'lib/client/templates/profile/user_downvoted_posts.html',
|
'lib/client/templates/profile/user_downvoted_posts.html',
|
||||||
|
|
Loading…
Add table
Reference in a new issue