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
| 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
| // 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
| 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
| 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
| Router.query = (function(router) { | |
| var current = function() { | |
| return router.current(); | |
| }; | |
| var currentParams = function() { | |
| return current().params; | |
| }; | |
| var currentQueryParams = 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.facetFilterItem.helpers({ | |
| isChecked: function(name, _id) { | |
| return _.indexOf(Facet.get(name), _id) !== -1; | |
| } | |
| }); | |
| Facet = (function() { | |
| var set = function(name, value) { | |
| var current = Router.current(); | |
| var params = {}; |
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
| UI.registerHelper('sourceCode', function() { | |
| return Template.sourceCode; | |
| }); | |
| <template name="sourceCode"> | |
| <pre><code data-language="html"> | |
| {{> UI.contentBlock}} | |
| </code></pre> | |
| </template> |
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.layout.events({ | |
| 'click .terms-modal': function() { | |
| Session.set('showTermsModal', true); | |
| } | |
| }); | |
| Template.layout.helpers({ | |
| termsModalOpen: function() { | |
| return !!Session.get('showTermsModal'); | |
| } |
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
| ## Meteor Patterns ## | |
| ---------- | |
| # 1. Simple Search | |
| - Avoid duplicating the same query code on the client and server. | |
| - Provide some simple search results. | |
| > common/utils.js |