Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 76efa4f76fbbf3c778f5e35a8f7ad2f712727ac6 @alduro committed Feb 27, 2012
Showing with 31,687 additions and 0 deletions.
  1. +4 −0 README
  2. +83 −0 app.js
  3. +5 −0 install.sh
  4. +12 −0 node_modules/mongodb/.npmignore
  5. +413 −0 node_modules/mongodb/HISTORY
  6. +67 −0 node_modules/mongodb/Makefile
  7. +413 −0 node_modules/mongodb/Readme.md
  8. +25 −0 node_modules/mongodb/TODO
  9. +45 −0 node_modules/mongodb/external-libs/bson/Makefile
  10. +2,334 −0 node_modules/mongodb/external-libs/bson/bson.cc
  11. +105 −0 node_modules/mongodb/external-libs/bson/bson.h
  12. BIN node_modules/mongodb/external-libs/bson/build/.wafpickle-7
  13. +20 −0 node_modules/mongodb/external-libs/bson/index.js
  14. +349 −0 node_modules/mongodb/external-libs/bson/test/test_bson.js
  15. +218 −0 node_modules/mongodb/external-libs/bson/test/test_full_bson.js
  16. +132 −0 node_modules/mongodb/external-libs/bson/test/test_stackless_bson.js
  17. +39 −0 node_modules/mongodb/external-libs/bson/wscript
  18. +1 −0 node_modules/mongodb/index.js
  19. +41 −0 node_modules/mongodb/install.js
  20. +342 −0 node_modules/mongodb/lib/mongodb/admin.js
  21. +186 −0 node_modules/mongodb/lib/mongodb/bson/binary.js
  22. +392 −0 node_modules/mongodb/lib/mongodb/bson/binary_parser.js
  23. +29 −0 node_modules/mongodb/lib/mongodb/bson/binary_utils.js
  24. +1,344 −0 node_modules/mongodb/lib/mongodb/bson/bson.js
  25. +23 −0 node_modules/mongodb/lib/mongodb/bson/code.js
  26. +29 −0 node_modules/mongodb/lib/mongodb/bson/db_ref.js
  27. +31 −0 node_modules/mongodb/lib/mongodb/bson/double.js
  28. +118 −0 node_modules/mongodb/lib/mongodb/bson/float_parser.js
  29. +852 −0 node_modules/mongodb/lib/mongodb/bson/long.js
  30. +11 −0 node_modules/mongodb/lib/mongodb/bson/max_key.js
  31. +11 −0 node_modules/mongodb/lib/mongodb/bson/min_key.js
  32. +247 −0 node_modules/mongodb/lib/mongodb/bson/objectid.js
  33. +47 −0 node_modules/mongodb/lib/mongodb/bson/symbol.js
  34. +852 −0 node_modules/mongodb/lib/mongodb/bson/timestamp.js
  35. +1,467 −0 node_modules/mongodb/lib/mongodb/collection.js
  36. +31 −0 node_modules/mongodb/lib/mongodb/commands/base_command.js
  37. +207 −0 node_modules/mongodb/lib/mongodb/commands/db_command.js
  38. +113 −0 node_modules/mongodb/lib/mongodb/commands/delete_command.js
  39. +85 −0 node_modules/mongodb/lib/mongodb/commands/get_more_command.js
  40. +143 −0 node_modules/mongodb/lib/mongodb/commands/insert_command.js
  41. +100 −0 node_modules/mongodb/lib/mongodb/commands/kill_cursor_command.js
  42. +212 −0 node_modules/mongodb/lib/mongodb/commands/query_command.js
  43. +176 −0 node_modules/mongodb/lib/mongodb/commands/update_command.js
  44. +417 −0 node_modules/mongodb/lib/mongodb/connection/connection.js
  45. +259 −0 node_modules/mongodb/lib/mongodb/connection/connection_pool.js
  46. +23 −0 node_modules/mongodb/lib/mongodb/connection/connection_utils.js
  47. +968 −0 node_modules/mongodb/lib/mongodb/connection/repl_set_servers.js
  48. +622 −0 node_modules/mongodb/lib/mongodb/connection/server.js
  49. +48 −0 node_modules/mongodb/lib/mongodb/connection/simple_emitter.js
  50. +125 −0 node_modules/mongodb/lib/mongodb/connection/strategies/ping_strategy.js
  51. +40 −0 node_modules/mongodb/lib/mongodb/connection/strategies/statistics_strategy.js
  52. +704 −0 node_modules/mongodb/lib/mongodb/cursor.js
  53. +139 −0 node_modules/mongodb/lib/mongodb/cursorstream.js
  54. +1,707 −0 node_modules/mongodb/lib/mongodb/db.js
  55. +210 −0 node_modules/mongodb/lib/mongodb/gridfs/chunk.js
  56. +95 −0 node_modules/mongodb/lib/mongodb/gridfs/grid.js
  57. +1,094 −0 node_modules/mongodb/lib/mongodb/gridfs/gridstore.js
  58. +167 −0 node_modules/mongodb/lib/mongodb/gridfs/readstream.js
  59. +131 −0 node_modules/mongodb/lib/mongodb/index.js
  60. +133 −0 node_modules/mongodb/lib/mongodb/responses/mongo_reply.js
  61. +44 −0 node_modules/mongodb/lib/mongodb/utils.js
  62. +80 −0 node_modules/mongodb/package.json
  63. +38 −0 public/404.html
  64. +25 −0 public/crossdomain.xml
  65. +581 −0 public/css/bootstrap-responsive.css
  66. +4 −0 public/css/bootstrap-responsive.min.css
  67. +3,496 −0 public/css/bootstrap.css
  68. +632 −0 public/css/bootstrap.min.css
  69. +444 −0 public/css/style.css
  70. BIN public/favicon.ico
  71. +43 −0 public/humans.txt
  72. +2 −0 public/img/.gitignore
  73. BIN public/img/destroy.png
  74. BIN public/img/glyphicons-halflings-white.png
  75. BIN public/img/glyphicons-halflings.png
  76. +42 −0 public/index.html
  77. +15 −0 public/js/app.js
  78. +37 −0 public/js/libs/backbone/backbone-min.js
  79. +3 −0 public/js/libs/backbone/backbone.js
  80. +10 −0 public/js/libs/backbone/loader.js
  81. +4 −0 public/js/libs/jquery/jquery-1.7.1.min.js
  82. +3 −0 public/js/libs/jquery/jquery.js
  83. +4 −0 public/js/libs/modernizr-2.0.6.min.js
  84. +4,515 −0 public/js/libs/require/cs.js
  85. +7 −0 public/js/libs/require/domReady.js
  86. +8 −0 public/js/libs/require/order.js
  87. +33 −0 public/js/libs/require/require.js
  88. +11 −0 public/js/libs/require/text.js
  89. +1,720 −0 public/js/libs/twitter-bootstrap/bootstrap.js
  90. +1 −0 public/js/libs/twitter-bootstrap/bootstrap.min.js
  91. +31 −0 public/js/libs/underscore/underscore-min.js
  92. +3 −0 public/js/libs/underscore/underscore.js
  93. +23 −0 public/js/main.js
  94. +37 −0 public/js/router.js
  95. +55 −0 public/js/templates/home/main.html
  96. +24 −0 public/js/views/home/main.js
  97. +5 −0 public/robots.txt
  98. +31 −0 public/test/index.html
  99. +148 −0 public/test/qunit/qunit.css
  100. +1,265 −0 public/test/qunit/qunit.js
  101. +27 −0 public/test/tests.js
4 README
@@ -0,0 +1,4 @@
+backbone app en base a
+https://github.com/addyosmani/backbone-fundamentals
+https://github.com/addyosmani/backbone-fundamentals/tree/master/practicals/modular-todo-app
+http://backbonetutorials.com/organizing-backbone-using-modules/
83 app.js
@@ -0,0 +1,83 @@
+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.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);
@@ -0,0 +1,5 @@
+#!/bin/bash
+npm install express -g
+npm install mongodb --mongodb:native -g
+npm install mongoose -g
+npm install jade -g

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 76efa4f

Please sign in to comment.