Skip to content

Instantly share code, notes, and snippets.

View matthisk's full-sized avatar

Matthisk Heimensen matthisk

View GitHub Profile
@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>
Handlebars.registerHelper('equals', function(a1, a2) {
return a1 === a2;
});
Template.bookmark.helpers({
path: function() {
return Router.path('recipe', { name: this.object });
},
recipe: function() {
return RecipesData[this.object];
},
});
<template name="activity">
{{#with object}}
<a href="{{path}}" class="item-activity">
<span class="attribution">
<span class="avatar">
<img src="{{userAvatar}}" class="image-avatar">
</span>
<span class="meta">
<span class="author">{{firstName}}</span> made <span class="recipe">{{recipeTitle}}</span>: {{text}}
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);
});
}
<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>
@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}});
},
<template name="activity">
{{#if equals this.verb 'cook'}}
{{> cook object}}
{{/if}}
{{#if equals this.verb 'bookmark'}}
{{> bookmark}}
{{/if}}
</template>
<template name="cook">
<a href="{{path}}" class="item-activity">
<span class="attribution">
<span class="avatar">
<img src="{{userAvatar}}" class="image-avatar">
</span>
<span class="meta">
<span class="author">{{firstName}}</span> made <span class="recipe">{{recipeTitle}}</span>: {{text}}
{{#if place}}<span class="location">&mdash;{{place}}</span>{{/if}}