This file contains 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
// server | |
Hooks.onLoggedIn = function (userId) { | |
Meteor.users.update({_id: userId}, {set: {'profile.status': 'online'}}); | |
} | |
Hooks.onLoggedOut = function (userId) { | |
Meteor.users.update({_id: userId}, {set: {'profile.status': 'offline'}}); | |
} |
This file contains 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
// CLIENT | |
Session.setDefault('search-terms', null); // They haven't searched for anything initially | |
Deps.autorun(function () { | |
// This will reactively update the subscription when the value of the search-terms session variable changes | |
Meteor.subscribe('foobar', Session.get('search-terms')); | |
}); | |
// SERVER | |
Meteor.publish('foobar', function (searchTerms) { |
This file contains 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 resetFields = function () { | |
var p = Meteor.user().profile; | |
$('#profile-name').val(p.name); | |
$('#profile-country-list').select2('val', p.country); | |
$('#profile-email').val(Meteor.user().emails[0].address); | |
$('#profile-paypal-email').val(p.paypal_email); | |
$('#profile-password').val(''); | |
$('#profile-confirm-password').val(''); | |
} |
This file contains 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.admin.events = | |
"click #createPost": () -> | |
Meteor.render(() -> | |
"{{> create_news_post}}" | |
) |
This file contains 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 (MyCollection.find().count() === 0) { | |
// Insert all of the MyCollection data here | |
} |
This file contains 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
Session.setDefault('game-list-position', 0); // The current position for the skip | |
Session.setDefault('viewport', 10); // The number of games to display in the list | |
Template.gameList.scrollableList = function () { | |
return Games.find({}, { | |
limit: Session.get('viewport'), // Limit the games to the current viewport number | |
skip: Session.get('game-list-position') * Session.get('viewport') // Skip the right number of games | |
}); | |
} |
This file contains 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
Session.setDefault('done-shit', false); // In the beginning, we haven't done shit | |
Meteor.subscribe('foobar', function () { | |
// We have recieved the data (either for the first time, or in an update) | |
if (Session.equals('done-shit', false)) { | |
// This is the first time we've got it | |
// Do data manipulation, or something | |
Session.set('done-shit', true); | |
} | |
}); |
This file contains 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
Deps.autorun(function () { | |
// The current game they're playing | |
var game = Games.findOne(Session.get('current-game')); // or whatever your equivalent of that is | |
if (! Session.equals('current-game-version', game.version)) { | |
// The game's version has updated | |
Session.set('current-game-version', game.version); | |
// Alert the user here | |
} | |
}); |
This file contains 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
client.addListener('PING', function() { | |
Fiber(function() { | |
client.send('PONG'); | |
}).run(); | |
}); |
This file contains 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
<head> | |
<title>Title</title> | |
<meta charset="utf-8"> | |
<meta name="robots" content="all"> | |
</head> | |
<body> | |
{{> nav_header}} | |
{{> index}} | |
</body> |