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
BB = require 'badass-backbone' | |
M = require './models' | |
V = require './views' | |
# Inherit from BadassAppRouter to get Badass Backbone conventions | |
module.exports = class Router extends BB.BadassAppRouter | |
logging: on | |
pushState: off # Set off for simple example |
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
""" | |
BadassRouter takes the philosophical position that only one router can be | |
used for one html page / single page app. It is conceptually the top most | |
container object other than window that contains all instances associated with the app. | |
""" | |
module.exports = class BadassRouter extends Backbone.Router | |
# Set logging on /off - Very dandy during dev to see flow of routes | |
logging: off |
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
#!/bin/sh | |
killall node | |
brunch watch --server -c config-test.coffee & | |
mocha test/server/all.coffee | |
mocha-phantomjs http://localhost:3333/test/index.html |
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
""" BadassView add 3 basic bits of functionality to a normal Backbone.View | |
1) Auto-logging of initialize, render & save | |
2) Auto setting constructor args as attributes on view instances | |
3) Short elm() to access an html element based on it's name attribute | |
""" | |
module.exports = class BadassView extends Backbone.View | |
# Set logging on /off | |
# Why? : During dev it's handy to see the flow your views execute in | |
logging: on |
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
module.exports = | |
initialize: (sessionUserObject) -> | |
(req, res, next) -> | |
passport = @ | |
passport._key = 'passport' | |
passport._userProperty = 'user' | |
passport.serializeUser = (user, done) -> done null, user | |
passport.deserializeUser = (user, done) -> done null, user |
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
module.exports = [ | |
{ "name": "Brunch.io", "shortName": "brunch", "soId": "brunch", "_id": "514825fa2a26ea020000000b", "__v": 0 }, | |
{ "name": "C#", "shortName": "c#", "soId": "c#", "_id": "514825fa2a26ea020000000e", "__v": 0 } ] |
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
web: ./node_modules/.bin/coffee app.coffee |
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
mongoose = require 'mongoose' | |
wipeDbAfterTests = true | |
describe "Your test suite", -> | |
# connect to our mongo test database, note how done is passed to mongoose connect | |
before (done) -> | |
mongoose.connect "mongodb://localhost/airpair_test", done |
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
""" FilteringCollection | |
(1) Holds an original AND a filtered view of it's models | |
(2) Can sort filtered models on any arbitrary attribute | |
- sort can be invoked multiple times with different attributes to get | |
sorted by A then B """ | |
class FilteringCollection extends Backbone.Collection | |
# Use coffee's constructor function so we can enforce initialization code + | |
# let the child class use the standard Backbone initialize function to |
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
render_carousel: -> | |
@$('.carousel-images').append('<img src="'+img.url+'">') for img in images |