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
<?php | |
echo 'Current PHP version: ' . phpversion(); |
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 TodoView = Backbone.View.extend({ | |
tagName: "li", | |
initialize: function(options) { | |
_.bindAll(this, "edit"); | |
this.template = Handlebars.compile(options.template || ""); | |
}, | |
render: function() { | |
$(this.el).html(this.template(this.model.toJSON())); | |
return this; | |
}, |
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 TodoListView = Backbone.View.extend({ | |
tagName: "UL", | |
className: "todos", | |
initialize: function() { | |
_.bindAll(this, "addTodo"); | |
}, | |
render: function() { | |
this.collection.each(this.addTodo); | |
}, | |
addTodo: function(todo) { |
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 Todo = Backbone.Model.extend({ | |
urlRoot: '/todos', | |
defaults: { | |
"priority": 3 | |
}, | |
validate: function(attrs) { | |
if (!attrs.title) { | |
return "cannot have an empty title"; | |
} | |
} |
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 Todos = Backbone.Collection.extend({ | |
url: "/todos", | |
model: Todo, | |
parse: function(res) { | |
return res.response.todos; | |
}, | |
comparator: function (todo) { | |
return todo.get("priority"); | |
} | |
}); |
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 = function(req, res, next) { | |
console.log(req.method, req.path, req.body); | |
next(); | |
} |
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 mongoose = require('mongoose') | |
, Schema = mongoose.Schema | |
, ObjectId = Schema.ObjectId | |
, UserSchema = require('./User').Schema | |
, GameSchema = new Schema({ | |
'name': { type: String }, | |
'player_a': { type: ObjectId, ref: "User" }, | |
'player_b': { type: ObjectId, ref: "User" }, | |
'score': { type: Number, default: 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
var AppRouter = Backbone.Router.extend({ | |
vent: _.extend({}, Backbone.Events), | |
routes: { | |
// TODO: index should games-list | |
"game/:id": "game", | |
"": "index" | |
}, | |
index: function() { | |
var myGames = new Games(); | |
myGames.fetch({ |
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 APIeasy = require('api-easy') | |
, assert = require('assert') | |
, mongoose = require('mongoose'); | |
var suite = APIeasy.describe('Testing the /games RESTful API.'); | |
var game = { | |
_id: new mongoose.Types.ObjectId, | |
name: 'new-game' | |
}; |
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
<div class="row"> | |
<div class="span2"> | |
<div class="btn-group pull-right" data-toggle="buttons-radio"> | |
<button class="btn active">All</button> | |
<button class="btn">Starred</button> | |
</div> | |
</div> | |
<div class="span4"> | |
<form class="form-search"> | |
<div class="input-append"> |
OlderNewer