forked from addyosmani/backbone-boilerplates
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding three options for boilerplates
- Loading branch information
1 parent
7704358
commit 8d81282
Showing
81 changed files
with
40,904 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,30 @@ | ||
Another work in progress. | ||
|
||
Todo application boilerplates demonstrating: | ||
|
||
Option 1 | ||
========= | ||
* Backbone | ||
* Node.js | ||
* Express | ||
* Mongoose | ||
* MongoDB | ||
|
||
Option 2 | ||
========= | ||
* Backbone | ||
* Jade | ||
* Node.js | ||
* Express | ||
* Mongoose | ||
* MongoDB | ||
|
||
Option 3 | ||
========== | ||
* Backbone | ||
* Haml | ||
* Ruby | ||
* Sinatra | ||
* MongoDB | ||
|
||
Instructions to come soon. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
var application_root = __dirname, | ||
express = require("express"), | ||
path = require("path"), | ||
mongoose = require('mongoose'); | ||
|
||
var app = express.createServer(); | ||
|
||
// model | ||
mongoose.connect('mongodb://localhost/my_database'); | ||
|
||
var Todo = mongoose.model('Todo', new mongoose.Schema({ | ||
text: String, | ||
done: Boolean, | ||
order: Number | ||
})); | ||
|
||
app.configure(function(){ | ||
app.use(express.bodyParser()); | ||
app.use(express.methodOverride()); | ||
app.use(app.router); | ||
app.use(express.static(path.join(application_root, "public"))); | ||
app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); | ||
app.set('views', path.join(application_root, "views")); | ||
app.set('view engine', 'jade') | ||
}); | ||
|
||
app.get('/', function(req, res){ | ||
res.send('Hello World'); | ||
}); | ||
|
||
app.get('/todo', function(req, res){ | ||
res.render('todo', {title: "MongoDB Backed TODO App"}); | ||
}); | ||
|
||
app.get('/api/todos', function(req, res){ | ||
return Todo.find(function(err, todos) { | ||
return res.send(todos); | ||
}); | ||
}); | ||
|
||
app.get('/api/todos/:id', function(req, res){ | ||
return Todo.findById(req.params.id, function(err, todo) { | ||
if (!err) { | ||
return res.send(todo); | ||
} | ||
}); | ||
}); | ||
|
||
app.put('/api/todos/:id', function(req, res){ | ||
return Todo.findById(req.params.id, function(err, todo) { | ||
todo.text = req.body.text; | ||
todo.done = req.body.done; | ||
todo.order = req.body.order; | ||
return todo.save(function(err) { | ||
if (!err) { | ||
console.log("updated"); | ||
} | ||
return res.send(todo); | ||
}); | ||
}); | ||
}); | ||
|
||
app.post('/api/todos', function(req, res){ | ||
var todo; | ||
todo = new Todo({ | ||
text: req.body.text, | ||
done: req.body.done, | ||
order: req.body.order | ||
}); | ||
todo.save(function(err) { | ||
if (!err) { | ||
return console.log("created"); | ||
} | ||
}); | ||
return res.send(todo); | ||
}); | ||
|
||
app.delete('/api/todos/:id', function(req, res){ | ||
return Todo.findById(req.params.id, function(err, todo) { | ||
return todo.remove(function(err) { | ||
if (!err) { | ||
console.log("removed"); | ||
return res.send('') | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
app.listen(3000); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
npm install express | ||
npm install mongodb --mongodb:native | ||
npm install mongoose | ||
npm install jade |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Page Not Found :(</title> | ||
<style> | ||
body { text-align: center;} | ||
h1 { font-size: 50px; text-align: center } | ||
span[frown] { transform: rotate(90deg); display:inline-block; color: #bbb; } | ||
body { font: 20px Constantia, 'Hoefler Text', "Adobe Caslon Pro", Baskerville, Georgia, Times, serif; color: #999; text-shadow: 2px 2px 2px rgba(200, 200, 200, 0.5); } | ||
::-moz-selection{ background:#FF5E99; color:#fff; } | ||
::selection { background:#FF5E99; color:#fff; } | ||
article {display:block; text-align: left; width: 500px; margin: 0 auto; } | ||
|
||
a { color: rgb(36, 109, 56); text-decoration:none; } | ||
a:hover { color: rgb(96, 73, 141) ; text-shadow: 2px 2px 2px rgba(36, 109, 56, 0.5); } | ||
</style> | ||
</head> | ||
<body> | ||
<article> | ||
<h1>Not found <span frown>:(</span></h1> | ||
<div> | ||
<p>Sorry, but the page you were trying to view does not exist.</p> | ||
<p>It looks like this was the result of either:</p> | ||
<ul> | ||
<li>a mistyped address</li> | ||
<li>an out-of-date link</li> | ||
</ul> | ||
</div> | ||
|
||
<script> | ||
var GOOG_FIXURL_LANG = (navigator.language || '').slice(0,2), | ||
GOOG_FIXURL_SITE = location.host; | ||
</script> | ||
<script src="http://linkhelp.clients.google.com/tbproxy/lh/wm/fixurl.js"></script> | ||
</article> | ||
</body> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0"?> | ||
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"> | ||
<cross-domain-policy> | ||
|
||
|
||
<!-- Read this: www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html --> | ||
|
||
<!-- Most restrictive policy: --> | ||
<site-control permitted-cross-domain-policies="none"/> | ||
|
||
|
||
|
||
<!-- Least restrictive policy: --> | ||
<!-- | ||
<site-control permitted-cross-domain-policies="all"/> | ||
<allow-access-from domain="*" to-ports="*" secure="false"/> | ||
<allow-http-request-headers-from domain="*" headers="*" secure="false"/> | ||
--> | ||
<!-- | ||
If you host a crossdomain.xml file with allow-access-from domain="*" | ||
and don’t understand all of the points described here, you probably | ||
have a nasty security vulnerability. ~ simon willison | ||
--> | ||
|
||
</cross-domain-policy> |
Oops, something went wrong.