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
var debug = function(str) { | |
console.log('counter-cache: ' + str); | |
}; | |
Meteor.Collection.prototype.maintainCountOf = function(collection, field, counterField) { | |
var self = this; | |
// what is Meteor.users an instanceof ? | |
// if (! (collection instanceof Meteor.Collection)) | |
// throw new Error("Expected first parameter to be a Meteor Collection"); |
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
// | |
// publish list of books (and authors) | |
// | |
Books.mainListCursor = function() { | |
return Books.find({}, { sort: { createdAt: -1 }, limit: 10 }); | |
}; | |
if (Meteor.isServer) { | |
Meteor.publish('books', 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
<form id="filter"> | |
{{#with profileFilter}} | |
<input type="text" name="nameFilter" value="{{search}}" placeholder="Filter users" /> | |
<fieldset class="radio-fieldset"> | |
<label> | |
<input type="radio" name="typeFilter" value="" {{typeSelected ''}} /> | |
Show all | |
</label> | |
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 ## | |
---------- | |
# Simple Search | |
- Avoid duplicating the same query code on the client and server. | |
- Provide some simple search results. | |
> common/utils.js |
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 |
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 |
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
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.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
Router.query = (function(router) { | |
var current = function() { | |
return router.current(); | |
}; | |
var currentParams = function() { | |
return current().params; | |
}; | |
var currentQueryParams = function() { |