2016-08-24 10:05:53 +09:00
|
|
|
import Telescope from 'meteor/nova:lib';
|
2016-06-23 12:17:39 +09:00
|
|
|
import Comments from './collection.js';
|
2016-10-05 08:37:48 +02:00
|
|
|
import Posts from 'meteor/nova:posts';
|
|
|
|
import Users from 'meteor/nova:users';
|
2016-06-23 12:17:39 +09:00
|
|
|
|
2016-07-19 17:30:59 +09:00
|
|
|
Comments.helpers({getCollection: () => Comments});
|
|
|
|
Comments.helpers({getCollectionName: () => "comments"});
|
|
|
|
|
2015-06-19 11:52:57 +09:00
|
|
|
//////////////////
|
|
|
|
// Link Helpers //
|
|
|
|
//////////////////
|
|
|
|
|
|
|
|
/**
|
2016-04-09 09:41:20 +09:00
|
|
|
* @summary Get URL of a comment page.
|
2015-06-19 11:52:57 +09:00
|
|
|
* @param {Object} comment
|
|
|
|
*/
|
2016-08-10 07:49:40 +02:00
|
|
|
Comments.getPageUrl = function(comment, isAbsolute = false){
|
|
|
|
const post = Posts.findOne(comment.postId);
|
|
|
|
return `${Posts.getPageUrl(post, isAbsolute)}/#${comment._id}`;
|
2015-06-19 11:52:57 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
///////////////////
|
|
|
|
// Other Helpers //
|
|
|
|
///////////////////
|
|
|
|
|
|
|
|
/**
|
2016-04-09 09:41:20 +09:00
|
|
|
* @summary Get a comment author's name
|
2015-06-19 11:52:57 +09:00
|
|
|
* @param {Object} comment
|
|
|
|
*/
|
|
|
|
Comments.getAuthorName = function (comment) {
|
2016-10-05 08:37:48 +02:00
|
|
|
var user = Users.findOne(comment.userId);
|
2016-11-30 10:21:25 +09:00
|
|
|
return user ? Users.getDisplayName(user) : comment.author;
|
2015-06-19 11:52:57 +09:00
|
|
|
};
|
2016-02-17 21:57:07 +09:00
|
|
|
|