2015-06-19 11:52:57 +09:00
|
|
|
//////////////////
|
|
|
|
// Link Helpers //
|
|
|
|
//////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get URL of a comment page.
|
|
|
|
* @param {Object} comment
|
|
|
|
*/
|
|
|
|
Comments.getPageUrl = function(comment, isAbsolute){
|
|
|
|
var isAbsolute = typeof isAbsolute === "undefined" ? false : isAbsolute; // default to false
|
|
|
|
var prefix = isAbsolute ? Telescope.utils.getSiteUrl().slice(0,-1) : "";
|
2015-09-18 16:27:59 +09:00
|
|
|
return prefix + FlowRouter.path("commentPage", comment);
|
2015-06-19 11:52:57 +09:00
|
|
|
};
|
|
|
|
Comments.helpers({getPageUrl: function () {return Comments.getPageUrl(this);}});
|
|
|
|
|
|
|
|
///////////////////
|
|
|
|
// Other Helpers //
|
|
|
|
///////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a comment author's name
|
|
|
|
* @param {Object} comment
|
|
|
|
*/
|
|
|
|
Comments.getAuthorName = function (comment) {
|
|
|
|
var user = Meteor.users.findOne(comment.userId);
|
|
|
|
if (user) {
|
2015-10-01 16:38:10 +01:00
|
|
|
return user.getDisplayName();
|
2015-06-19 11:52:57 +09:00
|
|
|
} else {
|
|
|
|
return comment.author;
|
|
|
|
}
|
|
|
|
};
|
2015-10-01 16:38:10 +01:00
|
|
|
Comments.helpers({getAuthorName: function () {return Comments.getDisplayName(this);}});
|