Skip to content

Instantly share code, notes, and snippets.

View matthisk's full-sized avatar

Matthisk Heimensen matthisk

View GitHub Profile
Template.bookmark.helpers({
path: function() {
return Router.path('recipe', { name: this.object });
},
recipe: function() {
return RecipesData[this.object];
},
});
<template name="bookmark">
<a href="{{path}}" class="item-activity">
<span class="attribution">
<span class="avatar">
<img src="{{actor.services.twitter.profile_image_url_https}}" class="image-avatar">
</span>
<span class="meta">
<span class="author">{{actor.profile.name}}</span> bookmarked <span class="recipe">{{object}}</span>
</span>
Handlebars.registerHelper('equals', function(a1, a2) {
return a1 === a2;
});
@matthisk
matthisk / whats-cooking.html
Created December 14, 2015 10:09
Stream-meteor whats cooking check activity verb
{{#each activities}}
{{# if equals this.verb 'cook'}}
{{> activity}}
{{else}}
{{> bookmark}}
{{/if}}
{{else}}
<div class="wrapper-message">
<div class="title-message">No one is cooking yet!</div>
<div class="subtitle-message">Share that you made a recipe and it will show up here.</div>
@matthisk
matthisk / handlebars.js
Created December 14, 2015 10:05
equals operator
Handlebars.registerHelper('equals', function(a1, a2) {
return a1 === a2;
});
@matthisk
matthisk / whats-cooking.js
Last active December 14, 2015 13:10
Stream-meteor whats-cooking retrieve flat feed activities
activities: function() {
return Stream.feeds.flat.find({}, {sort: {time: -1}});
},
@matthisk
matthisk / subscriptions.js
Created December 14, 2015 09:31
Stream-meteor subscriptions
// Global subscriptions
if (Meteor.isClient) {
Meteor.subscribe('news');
Meteor.subscribe('bookmarkCounts');
feedSubscription = Meteor.subscribe('Stream.feeds.flat');
}
@matthisk
matthisk / loc.js
Created December 14, 2015 09:22
Stream-meteor, fix geolocation addActivity in browser
if (! this.isSimulation && loc && loc.coords)
activity.place = getLocationPlace(loc);
@matthisk
matthisk / bookmarks.js
Last active December 14, 2015 12:54
stream-meteor register bookmark
if(! this.isSimulation) {
var feed = Stream.feedManager.getUserFeed(this.userId);
feed.addActivity({
'verb': 'bookmark',
'actor': 'users:' + Meteor.userId(),
'object': recipeName,
}).catch(function(reason) {
console.error('failed with reason', reason.error);
});
}
@matthisk
matthisk / activities.js
Last active January 4, 2016 10:12
stream-meteor register activity collection
// Instruct the integration library to add hook handlers
// on creation and removal to add or remove items on the
// getstream.io API:
Stream.registerActivity(Activities, {
activityVerb: 'cook',
activityActorProp: 'userId',
});