This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tinytest.add('Working', function(test) { | |
Books = new Meteor.Collection('books' + test.id); | |
Authors = new Meteor.Collection('authors' + test.id); | |
var author1 = Authors.insert({ | |
firstName: 'Charles', | |
lastName: 'Darwin' | |
}); | |
var book1 = Books.insert({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sendVideoMessagingSMS: function(to, message) { | |
check([this.userId, to, message], [String]); | |
twilio.sendSms({ | |
to: to, | |
from: "...", | |
body: message | |
}, function(error, response) { | |
if (error) | |
throw new Meteor.Error(503, "Failed to send SMS."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Link service accounts when signed in | |
orig_updateOrCreateUserFromExternalService = Accounts.updateOrCreateUserFromExternalService; | |
Accounts.updateOrCreateUserFromExternalService = function(serviceName, serviceData, options) { | |
var loggedInUser = Meteor.user(); | |
if (loggedInUser) { | |
var setAttr = {}; | |
setAttr['linkedServices.' + serviceName] = serviceData; | |
Meteor.users.update(loggedInUser._id, { $set: setAttr }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GroupOneController = RouteController.extend({ | |
activeTab: 'groupOne', | |
// ... | |
}); | |
PageController = GroupOneController.extend({ | |
// inherits 'activeTab' | |
// ... | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Router.handlebars = function(options) { | |
options = options || {}; | |
options.data = options.data || {}; | |
if (! options.template) | |
throw new Meteor.Error("Router.handlebars: options.template is required"); | |
if (! options.path) | |
throw new Meteor.Error("Router.handlebars: options.path is required"); | |
return { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Meteor.isServer) { | |
Router.handlebars = (function(fn) { | |
return function (options) { | |
options.template = Handlebars.templates[options.template]; | |
return fn(options); | |
}; | |
}(Router.handlebars)); | |
} | |
Router.configure({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Router.static = function(options) { | |
options = options || {}; | |
if (! options.path) | |
throw new Meteor.Error("Router.static: options.path is required"); | |
return { | |
where: 'server', | |
path: options.path, | |
action: function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Template.foo.events({ | |
'keyup .bar': _.debounce(function(event) { | |
// ... | |
}, 300) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Meteor.isClient) { | |
Template.hello.created = function() { | |
this.setDefault('counter', 0); | |
}; | |
Template.hello.helpers({ | |
counter: function() { | |
var template = Template.instance(); | |
return template.get('counter'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Blaze.TemplateInstance.prototype.setDefault = function(key, value) { | |
return Session.setDefault(this.view.name + '.' + key, value); | |
}; | |
Blaze.TemplateInstance.prototype.set = function(key, value) { | |
return Session.set(this.view.name + '.' + key, value); | |
}; | |
Blaze.TemplateInstance.prototype.get = function(key) { | |
return Session.get(this.view.name + '.' + key); |