Skip to content

Commit

Permalink
herald integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Kestanous authored and Kestanous committed Oct 2, 2014
1 parent b6becda commit 9be1bd7
Show file tree
Hide file tree
Showing 31 changed files with 217 additions and 214 deletions.
2 changes: 1 addition & 1 deletion .meteor/release
@@ -1 +1 @@
METEOR@0.9.3
METEOR@0.9.3.1
13 changes: 7 additions & 6 deletions .meteor/versions
Expand Up @@ -5,7 +5,7 @@ accounts-password@1.0.2
accounts-twitter@1.0.1
accounts-ui-unstyled@1.1.2
accounts-ui@1.1.1
aldeed:autoform@2.0.2
aldeed:autoform@3.1.0
aldeed:collection2@2.1.0
aldeed:simple-schema@1.0.3
application-configuration@1.0.2
Expand Down Expand Up @@ -40,9 +40,11 @@ id-map@1.0.0
iron:core@0.3.4
iron:dynamic-template@0.4.1
iron:layout@0.4.1
iron:router@0.9.3
iron:router@0.9.4
jquery@1.0.0
json@1.0.0
kestanous:herald-email@0.2.1
kestanous:herald@0.6.0
less@1.0.9
livedata@1.0.10
localstorage@1.0.0
Expand All @@ -52,8 +54,7 @@ meteor-platform@1.1.1
meteor@1.1.1
meteorhacks:async@1.0.0
meteorhacks:fast-render@1.1.2
meteorhacks:kadira-binary-deps@1.0.1
meteorhacks:kadira@2.9.2
meteorhacks:kadira@2.5.0
meteorhacks:npm@1.2.0
meteorhacks:subs-manager@1.1.0
minifiers@1.1.0
Expand Down Expand Up @@ -89,8 +90,8 @@ softwarerero:accounts-t9n@1.0.0
spacebars-compiler@1.0.2
spacebars@1.0.2
spiderable@1.0.3
splendido:accounts-templates-core@0.9.5
splendido:accounts-templates-unstyled@0.9.5
splendido:accounts-templates-core@0.9.8
splendido:accounts-templates-unstyled@0.9.8
srp@1.0.0
standard-app-packages@1.0.2
telescope-api@0.0.0
Expand Down
2 changes: 1 addition & 1 deletion packages/npm-container/versions.json
Expand Up @@ -10,6 +10,6 @@
]
],
"pluginDependencies": [],
"toolVersion": "meteor-tool@1.0.32",
"toolVersion": "meteor-tool@1.0.33",
"format": "1.0"
}
2 changes: 1 addition & 1 deletion packages/telescope-api/versions.json
Expand Up @@ -86,6 +86,6 @@
]
],
"pluginDependencies": [],
"toolVersion": "meteor-tool@1.0.32",
"toolVersion": "meteor-tool@1.0.33",
"format": "1.0"
}
2 changes: 1 addition & 1 deletion packages/telescope-base/versions.json
Expand Up @@ -82,6 +82,6 @@
]
],
"pluginDependencies": [],
"toolVersion": "meteor-tool@1.0.32",
"toolVersion": "meteor-tool@1.0.33",
"format": "1.0"
}
4 changes: 2 additions & 2 deletions packages/telescope-daily/versions.json
Expand Up @@ -82,7 +82,7 @@
],
[
"iron:router",
"0.9.3"
"0.9.4"
],
[
"jquery",
Expand Down Expand Up @@ -210,6 +210,6 @@
]
],
"pluginDependencies": [],
"toolVersion": "meteor-tool@1.0.32",
"toolVersion": "meteor-tool@1.0.33",
"format": "1.0"
}
2 changes: 1 addition & 1 deletion packages/telescope-email/versions.json
Expand Up @@ -18,6 +18,6 @@
]
],
"pluginDependencies": [],
"toolVersion": "meteor-tool@1.0.32",
"toolVersion": "meteor-tool@1.0.33",
"format": "1.0"
}
2 changes: 1 addition & 1 deletion packages/telescope-i18n/versions.json
Expand Up @@ -74,6 +74,6 @@
]
],
"pluginDependencies": [],
"toolVersion": "meteor-tool@1.0.32",
"toolVersion": "meteor-tool@1.0.33",
"format": "1.0"
}
12 changes: 2 additions & 10 deletions packages/telescope-kadira/versions.json
Expand Up @@ -72,10 +72,6 @@
"livedata",
"1.0.10"
],
[
"localstorage",
"1.0.0"
],
[
"logging",
"1.0.3"
Expand All @@ -86,11 +82,7 @@
],
[
"meteorhacks:kadira",
"2.9.2"
],
[
"meteorhacks:kadira-binary-deps",
"1.0.1"
"2.5.0"
],
[
"minimongo",
Expand Down Expand Up @@ -154,6 +146,6 @@
]
],
"pluginDependencies": [],
"toolVersion": "meteor-tool@1.0.32",
"toolVersion": "meteor-tool@1.0.33",
"format": "1.0"
}
2 changes: 1 addition & 1 deletion packages/telescope-lib/versions.json
Expand Up @@ -14,6 +14,6 @@
]
],
"pluginDependencies": [],
"toolVersion": "meteor-tool@1.0.32",
"toolVersion": "meteor-tool@1.0.33",
"format": "1.0"
}
2 changes: 1 addition & 1 deletion packages/telescope-module-embedly/versions.json
Expand Up @@ -98,6 +98,6 @@
]
],
"pluginDependencies": [],
"toolVersion": "meteor-tool@1.0.32",
"toolVersion": "meteor-tool@1.0.33",
"format": "1.0"
}
2 changes: 1 addition & 1 deletion packages/telescope-module-share/versions.json
Expand Up @@ -90,6 +90,6 @@
]
],
"pluginDependencies": [],
"toolVersion": "meteor-tool@1.0.32",
"toolVersion": "meteor-tool@1.0.33",
"format": "1.0"
}
4 changes: 2 additions & 2 deletions packages/telescope-newsletter/versions.json
Expand Up @@ -90,7 +90,7 @@
],
[
"iron:router",
"0.9.3"
"0.9.4"
],
[
"jquery",
Expand Down Expand Up @@ -214,6 +214,6 @@
]
],
"pluginDependencies": [],
"toolVersion": "meteor-tool@1.0.32",
"toolVersion": "meteor-tool@1.0.33",
"format": "1.0"
}

This file was deleted.

Expand Up @@ -5,4 +5,4 @@
{{{notificationHTML}}}
</div>
</li>
</template>
</template>
Expand Up @@ -3,17 +3,17 @@ Template[getTemplate('notificationItem')].helpers({
return moment(this.timestamp).fromNow();
},
properties: function(){
return this.properties;
return this.data;
},
notificationHTML: function(){
return buildSiteNotification(this);
return this.message();
}
});

Template[getTemplate('notificationItem')].events({
'click .action-link': function(event, instance){
var notificationId=instance.data._id;
Notifications.update(
Herald.collection.update(
{_id: notificationId},
{
$set:{
Expand All @@ -27,4 +27,4 @@ Template[getTemplate('notificationItem')].events({
}
);
}
});
});
Expand Up @@ -4,4 +4,4 @@
left a new comment on
<a href="{{postCommentUrl}}" class="action-link">{{postTitle}}</a>
</p>
</template>
</template>
@@ -1,7 +1,7 @@
<template name="notificationNewReply">
<p>
<a href="{{profileUrl}}">{{author}}</a>
<a href="{{profileUrl}}">{{author}}</a>
has replied to your comment on
<a href="{{postCommentUrl}}" class="action-link">{{postTitle}}</a>
</p>
</template>
</template>
Expand Up @@ -3,13 +3,13 @@ Template[getTemplate('notificationsMenu')].helpers({
return getTemplate('notificationItem');
},
notifications: function(){
return Notifications.find({userId: Meteor.userId(), read: false}, {sort: {timestamp: -1}});
return Herald.collection.find({userId: Meteor.userId(), read: false}, {sort: {timestamp: -1}});
},
hasNotifications: function () {
return !!Notifications.find({userId: Meteor.userId(), read: false}, {sort: {timestamp: -1}}).count();
return !!Herald.collection.find({userId: Meteor.userId(), read: false}, {sort: {timestamp: -1}}).count();
},
notification_count: function(){
var notifications=Notifications.find({userId: Meteor.userId(), read: false}).fetch();
var notifications=Herald.collection.find({userId: Meteor.userId(), read: false}).fetch();
if(notifications.length==0){
return i18n.t('No notifications');
}else if(notifications.length==1){
Expand All @@ -19,7 +19,7 @@ Template[getTemplate('notificationsMenu')].helpers({
}
},
notification_class: function(){
var notifications=Notifications.find({userId: Meteor.userId(), read: false}).fetch();
var notifications=Herald.collection.find({userId: Meteor.userId(), read: false}).fetch();
if(notifications.length==0)
return 'no-notifications';
}
Expand All @@ -37,4 +37,4 @@ Template[getTemplate('notificationsMenu')].events({
}
);
}
});
});
101 changes: 101 additions & 0 deletions packages/telescope-notifications/lib/herald.js
@@ -0,0 +1,101 @@
Herald.collection.deny({
update: ! can.editById,
remove: ! can.editById
});

var commentEmail = function (userToNotify) {
var notification = this;
// put in setTimeout so it doesn't hold up the rest of the method
Meteor.setTimeout(function () {
notificationEmail = buildEmailNotification(notification);
sendEmail(getEmail(userToNotify), notificationEmail.subject, notificationEmail.html);
}, 1);
}

Herald.addCourier('newPost', {
media: {
email: {
emailRunner: function (user) {
var p = getPostProperties(this.data);
var subject = p.postAuthorName+' has created a new post: '+p.postTitle;
var html = buildEmailTemplate(getEmailTemplate('emailNewPost')(p));
sendEmail(getEmail(user), subject, html);
}
}
}
// message: function (user) { return 'email template?' }
});

Herald.addCourier('newComment', {
media: {
onsite: {},
email: {
emailRunner: commentEmail
}
},
message: {
default: function (user) {
return Blaze.toHTML(Blaze.With(this, function(){
return Template[getTemplate('notificationNewComment')]
}));
}
},
transform: {
profileUrl: function () {
var user = Meteor.users.findOne(this.data.comment.userId);
if(user)
return getProfileUrl(user);
},
postCommentUrl: function () {
return '/posts/'+ this.data.post._id;
},
author: function () {
var user = Meteor.users.findOne(this.data.comment.userId);
if(user)
return getUserName(user);
},
postTitle: function () {
return this.data.post.title;
},
url: function () {
return /comments/ + this.comment._id;
}
}
});

Herald.addCourier('newReply', {
media: {
onsite: {},
email: {
emailRunner: commentEmail
}
},
message: {
default: function (user) {
return Blaze.toHTML(Blaze.With(this, function(){
return Template[getTemplate('notificationNewReply')]
}));
}
},
transform: {
profileUrl: function () {
var user = Meteor.users.findOne(this.data.comment.userId);
if(user)
return getProfileUrl(user);
},
postCommentUrl: function () {
return '/posts/'+ this.data.post._id;
},
author: function () {
var user = Meteor.users.findOne(this.data.comment.userId);
if(user)
return getUserName(user);
},
postTitle: function () {
return this.data.post.title;
},
url: function () {
return /comments/ + this.parentComment._id;
}
}
});

0 comments on commit 9be1bd7

Please sign in to comment.