Skip to content

Instantly share code, notes, and snippets.

postData = {}; // Setup the postData global
// Have this run on startup.
Meteor.startup(function(){
postsData = [
{
title: 'Introducing Telescope',
author: 'Sacha Greif',
url: 'http://sachagreif.com/introducing-telescope/'
currentCategory: function () {
return this.slug; // Make the capitolization correct
}
Template.myPosts.helpers({
posts: function(){
var posts = Posts.find({}).fetch();
return posts
}
})
//Collection:
Site = new Meteor.Collection('site');
// Publication:
Meteor.publish('site', function () {
var host = headers.get(this, 'host');
return Site.find({'domain': host});
});
// helper for all templates.
Handlebars.registerHelper("site", function(){
return Site.findOne({}); // Missing the query for the collection here. Need to narrow it down.
});
Handlebars.registerHelper("siteTheme", function(){
site = Site.findOne({}); // See comment on line 3.
if(typeof site == 'object'){
Session.set('theme', site.theme);
}
[digilord@Io meteor-weak-dependency-test[master]]$ meteor
[[[[[ ~/projects/meteor-weak-dependency-test ]]]]]
=> Errors prevented startup:
While building package `weak-test`:
error: no such package: 'iron-router'
=> Your application has errors. Waiting for file change.
@Lexicon = new Meteor.Collection "lexicon"
if Meteor.isServer
Meteor.methods
Langs: -> Lexicon.distinct('lang')
if Meteor.isClient
Meteor.call 'Langs', (err, res) ->
console.log res
@Lexicon = new Meteor.Collection "lexicon"
@Langs = new Meteor.Collection(null)
if Meteor.isServer
for lang in Lexicon.distinct('lang')
Langs.insert lang
Meteor.publish 'lexicon', () ->
return Lexicon.find()
@Lexicon = new Meteor.Collection "lexicon"
if Meteor.isClient
Template.language_dropdown.rendered = ->
Lexicon.distinct "lang", (err, res) =>
$("#langs").autocomplete {source: res}
@digilord
digilord / gist:8283707
Created January 6, 2014 14:42
Sample CoffeeScript controller for Iron Router
class @AuthorizedController extends RouteController
before: ->
console.log 'AuthorizedController :before action'
if not Meteor.user()?
@redirect 'salesLanding'