Permalink
Browse files

ad

  • Loading branch information...
1 parent 2eb668a commit 03612151376319c25dc9ebf17afe20357a1ec2c5 @chetanankola committed Sep 9, 2012
Showing with 19,628 additions and 3 deletions.
  1. +31 −3 README.md
  2. +56 −0 application.json
  3. +27 −0 assets/core.css
  4. BIN assets/favicon.ico
  5. BIN assets/images/goovepaper.png
  6. BIN assets/images/ruggedbg13.png
  7. BIN assets/images/smallhusk.png
  8. BIN assets/images/subtle_freckles.png
  9. BIN assets/images/subtle_orange_emboss.png
  10. +23 −0 index.js
  11. BIN mojits/.DS_Store
  12. +48 −0 mojits/board/assets/index.css
  13. +126 −0 mojits/board/binders/index.js
  14. +171 −0 mojits/board/controller.server.js
  15. +5 −0 mojits/board/definition.json
  16. +37 −0 mojits/board/models/foo.server.js
  17. +37 −0 mojits/board/tests/binders/index.common-tests.js
  18. +62 −0 mojits/board/tests/controller.server-tests.js
  19. +39 −0 mojits/board/tests/models/foo.server-tests.js
  20. +10 −0 mojits/board/views/index.mu.html
  21. +54 −0 mojits/boardInputBox/assets/index.css
  22. +60 −0 mojits/boardInputBox/binders/index.js
  23. +38 −0 mojits/boardInputBox/controller.server.js
  24. +5 −0 mojits/boardInputBox/definition.json
  25. +37 −0 mojits/boardInputBox/models/foo.server.js
  26. +37 −0 mojits/boardInputBox/tests/binders/index.common-tests.js
  27. +62 −0 mojits/boardInputBox/tests/controller.server-tests.js
  28. +39 −0 mojits/boardInputBox/tests/models/foo.server-tests.js
  29. +6 −0 mojits/boardInputBox/views/index.mu.html
  30. +3 −0 mojits/main/assets/index.css
  31. +42 −0 mojits/main/binders/index.js
  32. +42 −0 mojits/main/controller.server.js
  33. +5 −0 mojits/main/definition.json
  34. +37 −0 mojits/main/models/foo.server.js
  35. +37 −0 mojits/main/tests/binders/index.common-tests.js
  36. +60 −0 mojits/main/tests/controller.server-tests.js
  37. +39 −0 mojits/main/tests/models/foo.server-tests.js
  38. +6 −0 mojits/main/views/index.mu.html
  39. +7 −0 node_modules/mongodb/.tm_properties
  40. +5 −0 node_modules/mongodb/.travis.yml
  41. +75 −0 node_modules/mongodb/Makefile
  42. +410 −0 node_modules/mongodb/Readme.md
  43. +1 −0 node_modules/mongodb/index.js
  44. +40 −0 node_modules/mongodb/install.js
  45. +340 −0 node_modules/mongodb/lib/mongodb/admin.js
  46. +1,627 −0 node_modules/mongodb/lib/mongodb/collection.js
  47. +29 −0 node_modules/mongodb/lib/mongodb/commands/base_command.js
  48. +213 −0 node_modules/mongodb/lib/mongodb/commands/db_command.js
  49. +114 −0 node_modules/mongodb/lib/mongodb/commands/delete_command.js
  50. +83 −0 node_modules/mongodb/lib/mongodb/commands/get_more_command.js
  51. +147 −0 node_modules/mongodb/lib/mongodb/commands/insert_command.js
  52. +98 −0 node_modules/mongodb/lib/mongodb/commands/kill_cursor_command.js
  53. +253 −0 node_modules/mongodb/lib/mongodb/commands/query_command.js
  54. +174 −0 node_modules/mongodb/lib/mongodb/commands/update_command.js
  55. +416 −0 node_modules/mongodb/lib/mongodb/connection/connection.js
  56. +239 −0 node_modules/mongodb/lib/mongodb/connection/connection_pool.js
  57. +23 −0 node_modules/mongodb/lib/mongodb/connection/connection_utils.js
  58. +316 −0 node_modules/mongodb/lib/mongodb/connection/mongos.js
  59. +66 −0 node_modules/mongodb/lib/mongodb/connection/read_preference.js
  60. +1,089 −0 node_modules/mongodb/lib/mongodb/connection/repl_set.js
  61. +839 −0 node_modules/mongodb/lib/mongodb/connection/server.js
  62. +173 −0 node_modules/mongodb/lib/mongodb/connection/strategies/ping_strategy.js
  63. +81 −0 node_modules/mongodb/lib/mongodb/connection/strategies/statistics_strategy.js
  64. +805 −0 node_modules/mongodb/lib/mongodb/cursor.js
  65. +141 −0 node_modules/mongodb/lib/mongodb/cursorstream.js
  66. +2,064 −0 node_modules/mongodb/lib/mongodb/db.js
  67. +213 −0 node_modules/mongodb/lib/mongodb/gridfs/chunk.js
  68. +98 −0 node_modules/mongodb/lib/mongodb/gridfs/grid.js
  69. +1,454 −0 node_modules/mongodb/lib/mongodb/gridfs/gridstore.js
  70. +174 −0 node_modules/mongodb/lib/mongodb/gridfs/readstream.js
  71. +157 −0 node_modules/mongodb/lib/mongodb/index.js
  72. +140 −0 node_modules/mongodb/lib/mongodb/responses/mongo_reply.js
  73. +74 −0 node_modules/mongodb/lib/mongodb/utils.js
  74. +5 −0 node_modules/mongodb/node_modules/bson/.travis.yml
  75. +31 −0 node_modules/mongodb/node_modules/bson/Makefile
  76. 0 node_modules/mongodb/node_modules/bson/README
  77. +130 −0 node_modules/mongodb/node_modules/bson/benchmarks/benchmarks.js
  78. +28 −0 node_modules/mongodb/node_modules/bson/ext/Makefile
  79. +986 −0 node_modules/mongodb/node_modules/bson/ext/bson.cc
  80. +273 −0 node_modules/mongodb/node_modules/bson/ext/bson.h
  81. +20 −0 node_modules/mongodb/node_modules/bson/ext/index.js
  82. +39 −0 node_modules/mongodb/node_modules/bson/ext/wscript
  83. +41 −0 node_modules/mongodb/node_modules/bson/install.js
  84. +336 −0 node_modules/mongodb/node_modules/bson/lib/bson/binary.js
  85. +387 −0 node_modules/mongodb/node_modules/bson/lib/bson/binary_parser.js
  86. +1,499 −0 node_modules/mongodb/node_modules/bson/lib/bson/bson.js
  87. +27 −0 node_modules/mongodb/node_modules/bson/lib/bson/code.js
  88. +33 −0 node_modules/mongodb/node_modules/bson/lib/bson/db_ref.js
  89. +35 −0 node_modules/mongodb/node_modules/bson/lib/bson/double.js
  90. +123 −0 node_modules/mongodb/node_modules/bson/lib/bson/float_parser.js
  91. +74 −0 node_modules/mongodb/node_modules/bson/lib/bson/index.js
  92. +856 −0 node_modules/mongodb/node_modules/bson/lib/bson/long.js
  93. +15 −0 node_modules/mongodb/node_modules/bson/lib/bson/max_key.js
  94. +15 −0 node_modules/mongodb/node_modules/bson/lib/bson/min_key.js
  95. +258 −0 node_modules/mongodb/node_modules/bson/lib/bson/objectid.js
  96. +50 −0 node_modules/mongodb/node_modules/bson/lib/bson/symbol.js
  97. +855 −0 node_modules/mongodb/node_modules/bson/lib/bson/timestamp.js
  98. +53 −0 node_modules/mongodb/node_modules/bson/package.json
Sorry, we could not display the entire diff because it was too big.
View
34 README.md
@@ -1,4 +1,32 @@
-mojit-redis-app
-===============
+mojito-redis-app
-node-redis and mojito working together
+
+simple mojito app to talk with redis no sql database
+
+Steps:
+======
+
+ first setup the redis server using instructuon here: http://redis.io/topics/quickstart
+ download http://download.redis.io/redis-stable.tar.gz
+ tar xvzf redis-stable.tar.gz
+ cd redis-stable
+ make
+
+ cd src
+ sudo cp redis-server /usr/local/bin/
+ sudo cp redis-cli /usr/local/bin/
+
+ now you can run your redis server on localhost as
+ `redis-server`
+
+ OR
+
+ $ git clone http://github.com/antirez/redis.git
+ $ cd redis/src
+ $ make
+ $ sudo make install
+ $ cd ../..
+ $ rm -rf redis
+
+
+ -: To add extra external npm packages make sure you do npm install packganame -g or do cd ./node_modules/pkgname/ && npm link
View
56 application.json
@@ -0,0 +1,56 @@
+[
+ {
+ "settings": [ "master" ],
+ "log": {
+ "client": {
+ "level": "warn",
+ "yui": true
+ },
+ "server": {
+ "level": "debug",
+ "yui": true
+ }
+ },
+
+ "appPort": 8002,
+ "staticHandling": {
+ "appName": "mojit-redis-app"
+ },
+ "specs": {
+ "main" : {
+ "type": "HTMLFrameMojit",
+ "config": {
+ "title": "main",
+ "deploy": true,
+ "child": {
+ "type" : "main",
+ "config" : {
+ "children" : {
+ "board": {
+ "base": "board"
+ },
+ "boardInputBox": {
+ "base": "boardInputBox"
+ }
+ }
+ }
+ },
+ "assets": {
+ "top": {
+ "css":[
+ "http://yui.yahooapis.com/3.4.1/build/cssfonts/fonts-min.css",
+ "http://yui.yahooapis.com/3.4.1/build/cssreset/reset-min.css"
+ ]
+ }
+ }
+ }
+ },
+ "boardInputBox": {
+ "type": "boardInputBox"
+ },
+ "board": {
+ "type": "board"
+ }
+ }
+ }
+]
View
27 assets/core.css
@@ -0,0 +1,27 @@
+/* Global */
+
+/* Apply a natural box layout model to all elements */
+* {-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;}
+
+html {background: url(images/goovepaper.png)}
+body {color: #333;}
+a {text-decoration: none; color: #722C84;}
+li {list-style-type: none;}
+.mojit-panel { margin-left:20px; margin-right:20px;margin-top:10px;}
+.simple-panel {
+ border-radius: 3px;
+ margin: 10px;
+ background:#fefefe;
+ padding: 10px;
+ text-align: center;
+ white-space: nowrap;
+}
+
+
+header{-webkit-border-radius:0px;position:relative;margin:0px;padding:8px; }
+.header-style-default {font-size:1.2em;border: 1px solid transparent;color: white;text-shadow: 0 1px #000;background-color: #D14836;background-image: -webkit-gradient(linear,left top,left bottom,from(#DD4B39),to(#D14836));
+/*text-transform: uppercase;*/}
+.debug-console-red {font-size:1.2em;border: 1px solid transparent;color: white;text-shadow: 0 1px #000;text-transform: uppercase;background-color: #D14836;background-image: -webkit-gradient(linear,left top,left bottom,from(#DD4B39),to(#D14836));}
+.header-style-blue{font-size:1.2em;border: 1px solid #3079ed;color: #fff;text-shadow: 0 1px rgba(0,0,0,0.1);background-color: #4d90fe;background-image: -webkit-gradient(linear,left top,left bottom,from(#4d90fe),to(#4787ed)); background-image: -webkit-linear-gradient(top,#4d90fe,#4787ed);background-image: linear-gradient(top,#4d90fe,#4787ed);}
+.header-style-grey{font-size:1.2em;text-shadow: 0px 1px 0 white;color: #444;background: -webkit-gradient(linear, left top, left bottom, from(#ccc), to(#ededed)); }
+.header-style-grey2{background: -webkit-linear-gradient(#829AA8,#405A6A);font-size:1.2em;border: 1px solid #677C89;border-bottom-color: #6B808D;border-radius: 3px 3px 0 0;text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7);color: #fff;text-shadow: 0 1px rgba(0,0,0,0.1);}
View
BIN assets/favicon.ico
Binary file not shown.
View
BIN assets/images/goovepaper.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/images/ruggedbg13.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/images/smallhusk.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/images/subtle_freckles.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN assets/images/subtle_orange_emboss.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
23 index.js
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2011-2012, Yahoo! Inc. All rights reserved.
+ * Copyrights licensed under the New BSD License.
+ * See the accompanying LICENSE file for terms.
+ */
+
+
+/*jslint anon:true, sloppy:true, nomen:true, node:true*/
+
+
+process.chdir(__dirname);
+
+
+/**
+ * @param {object} config The configuration object containing processing params.
+ * @param {object} token Token used to identify the application.
+ */
+module.exports = function(config, token) {
+ var app = require('./server.js');
+
+ // Signal the application is ready, providing the token and app references.
+ process.emit('application-ready', token, app);
+};
View
BIN mojits/.DS_Store
Binary file not shown.
View
48 mojits/board/assets/index.css
@@ -0,0 +1,48 @@
+.board {
+ border-radius: 5px;
+ margin: 5px;
+ font-size:1.0em;
+ word-wrap: break-word;
+ background:#fefefe;
+ border: 1px solid #E9E9E9;
+ box-shadow: 0 1px 3px rgba(0,0,0,0.3);
+ padding: 10px;
+ text-align: center;
+ text-shadow: 1px 1px 0 white;
+}
+
+
+
+
+
+.noborder{
+ border:none;
+ background:red;
+}
+
+.article{
+ cursor:pointer;
+ background:#eee;
+ margin:3px;
+ word-wrap: break-word;
+ text-align:center;
+}
+
+.article:hover {
+ background:#ccc;
+}
+
+.article h2{
+ font-size:3em;
+ word-wrap: break-word;
+ margin:3px;
+}
+
+.btn-delete{
+ border:1px solid #ccc;
+ padding:0px;
+ font-size:1.0em;
+ background:#fff;
+ border-radius:20px;
+ text-align:center;
+}
View
126 mojits/board/binders/index.js
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+/*jslint anon:true, sloppy:true, nomen:true*/
+YUI.add('boardBinderIndex', function (Y, NAME) {
+
+/**
+ * The boardBinderIndex module.
+ *
+ * @module boardBinderIndex
+ */
+
+ /**
+ * Constructor for the boardBinderIndex class.
+ *
+ * @class boardBinderIndex
+ * @constructor
+ */
+ Y.namespace('mojito.binders')[NAME] = {
+
+ /**
+ * Binder initialization method, invoked after all binders on the page
+ * have been constructed.
+ */
+ init: function (mojitProxy) {
+ this.mojitProxy = mojitProxy;
+ },
+
+ /**
+ * The binder method, invoked to allow the mojit to attach DOM event
+ * handlers.
+ *
+ * @param node {Node} The DOM node to which this mojit is attached.
+ */
+
+ onRefreshView: function(node) {
+ var self=this;
+
+ //alert('refreshing');
+ node.all('.article').on('click', function(e){
+ //alert('deleting article:' + e.currentTarget.get('id'));
+ var args = {
+ params: {
+ route: {
+ call:'deleteEntry',
+ id:e.currentTarget.get('id')
+ }
+ }
+ };
+ self.mojitProxy.refreshView(args);
+ });
+
+ },
+
+
+ bind: function (node) {
+ var me = this,
+ self=this;
+ this.node = node;
+ thatNode = node;
+
+ self.mojitProxy.refreshView();
+
+ /*setInterval(function(){
+ var args = {
+ params: {
+ route: {
+ call:'getLastEntry'
+ }
+ }
+ };
+ self.mojitProxy.refreshView(args);
+ }, 5000 );*/
+
+
+ Y.on('SHOW_ALL_ARTICLE', function(){
+ var args = {
+ params: {
+ route: {
+ call:'showAllArticles'
+ }
+ }
+ };
+ self.mojitProxy.refreshView(args);
+ });
+
+ Y.on('GET_LAST_ARTICLE', function(){
+ var args = {
+ params: {
+ route: {
+ call:'getLastEntry'
+ }
+ }
+ };
+ self.mojitProxy.refreshView(args);
+ });
+
+ Y.on('GET_FIRST_ARTICLE', function(){
+ var args = {
+ params: {
+ route: {
+ call:'getFirstEntry'
+ }
+ }
+ };
+ self.mojitProxy.refreshView(args);
+ });
+
+ Y.on('UPDATE_BOARD', function(e, input) {
+ var args = {
+ params: {
+ route: {
+ defer:true,
+ call:'addArticle',
+ boardInputVal:input.val
+ }
+ }
+ };
+ this.mojitProxy.refreshView(args);
+ }, this);
+
+ }
+
+ };
+
+}, '0.0.1', {requires: ['event-mouseenter', 'mojito-client', 'event-key']});
View
171 mojits/board/controller.server.js
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+/*jslint anon:true, sloppy:true, nomen:true*/
+YUI.add('board', function (Y, NAME) {
+
+/**
+ * The board module.
+ *
+ * @module board
+ */
+
+ /**
+ * Constructor for the Controller class.
+ *
+ * @class Controller
+ * @constructor
+ */
+ Y.namespace('mojito.controllers')[NAME] = {
+
+ init: function (config) {
+ this.config = config;
+ this.db = this.config.db || 'mlh';
+ },
+
+ /**
+ * Method corresponding to the 'index' action.
+ *
+ * @param ac {Object} The ActionContext that provides access
+ * to the Mojito API.
+ */
+ index: function (ac) {
+ ac.assets.addCss('./index.css', 'top');
+ if (ac.params.getFromRoute('call') === 'getLastEntry') {
+ return this.getLastEntry(ac);
+ }
+ if (ac.params.getFromRoute('call') === 'getFirstEntry') {
+ return this.getFirstEntry(ac);
+ }
+ if (ac.params.getFromRoute('call') === 'showAllArticles') {
+ return this.showAllArticles(ac);
+ }
+ if (ac.params.getFromRoute('call') === 'addArticle') {
+ return this.addArticle(ac);
+ }
+ if (ac.params.getFromRoute('call') === 'deleteEntry') {
+ return this.deleteEntry(ac, ac.params.getFromRoute('id'));
+ }
+ //return this.deleteEntry(ac, 218);
+ return this.showAllArticles(ac);
+ },
+
+ showAllArticles: function (ac) {
+ var output = [],
+ finalOutput = {},
+ redis = require("redis"),
+ client = redis.createClient(),
+ i,
+ db = this.db;
+
+ client.hvals(db, function (err, replies) {
+ if (err) {
+ ac.done();
+ return console.error("error response - " + err);
+ }
+ for (i = 0; i < replies.length; i++) {
+ output[i] = JSON.parse(replies[i].toString());//JSON.parse(replies[i]);
+ Y.log(output[i], "warn");
+ }
+ if (replies.length === 0) {
+ finalOutput.empty = {msg: 'emptyDb'};
+ }
+ client.quit();
+ finalOutput.output = output;
+ finalOutput.customMsg = {msg: 'meh meh you are a noobe'};
+ ac.done(finalOutput);
+ });
+ },
+
+ addArticle: function (ac) {
+ var redis = require("redis"),
+ client = redis.createClient(),
+ searchTerm,
+ i,
+ self = this,
+ db = this.db;
+
+ client.on("error", function (err) {
+ console.log("error event - " + client.host + ":" + client.port + " - " + err);
+ });
+ client.set("string key", "string val");//, redis.print);
+ //client.hset("cars", "audi", "a5");//, redis.print);
+ searchTerm = ac.params.getFromRoute('boardInputVal');
+ if (searchTerm) {
+ client.incr('nextid', function (err, id) {
+ if (err) {
+ return ac.done();
+ }
+ client.hset(db, 'articleId:' + id, JSON.stringify({
+ key: 'articleId:' + id,
+ id: id,
+ value: searchTerm
+ }));//, redis.print);
+ client.quit();
+ return self.showAllArticles(ac);
+ });
+ } else {
+ client.quit();
+ ac.done();
+ }
+ },
+
+ getFirstEntry: function (ac) {
+ var output = {data: 'empty db'},
+ redis = require("redis"),
+ client = redis.createClient(),
+ db = this.db;
+
+ client.hvals(db, function (err, replies) {
+ if (err) {
+ ac.done();
+ return console.error("error response - " + err);
+ }
+ if (replies.length > 0) {
+ output = JSON.parse(replies[0].toString());
+ }
+ client.quit();
+ ac.done({
+ output: output
+ });
+ });
+ },
+
+ deleteEntry: function (ac, id) {
+ var output,
+ self = this,
+ redis = require("redis"),
+ client = redis.createClient(),
+ db = this.db;
+ client.hdel(db, 'articleId:' + id, function () {
+ return self.showAllArticles(ac);
+ });
+ client.quit();
+ },
+
+ getLastEntry: function (ac) {
+ var output,
+ redis = require("redis"),
+ client = redis.createClient(),
+ db = this.db;
+ client.hvals(db, function (err, replies) {
+ if (err) {
+ ac.done();
+ return console.error("error response - " + err);
+ }
+ if (replies.length <= 0) {
+ return ac.done();
+ }
+ output = replies[replies.length - 1];
+ Y.log(output, 'warn');
+ output = JSON.parse(output.toString());
+ client.quit();
+ ac.done({
+ output: output
+ });
+ });
+ }
+
+ };
+
+}, '0.0.1', {requires: ['mojito', 'boardModelFoo', 'json-parse']});
View
5 mojits/board/definition.json
@@ -0,0 +1,5 @@
+[
+ {
+ "settings": [ "master" ]
+ }
+]
View
37 mojits/board/models/foo.server.js
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+/*jslint anon:true, sloppy:true, nomen:true*/
+YUI.add('boardModelFoo', function(Y, NAME) {
+
+/**
+ * The boardModelFoo module.
+ *
+ * @module board
+ */
+
+ /**
+ * Constructor for the boardModelFoo class.
+ *
+ * @class boardModelFoo
+ * @constructor
+ */
+ Y.namespace('mojito.models')[NAME] = {
+
+ init: function(config) {
+ this.config = config;
+ },
+
+ /**
+ * Method that will be invoked by the mojit controller to obtain data.
+ *
+ * @param callback {function(err,data)} The callback function to call when the
+ * data has been retrieved.
+ */
+ getData: function(callback) {
+ callback(null, { some: 'data' });
+ }
+
+ };
+
+}, '0.0.1', {requires: []});
View
37 mojits/board/tests/binders/index.common-tests.js
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+YUI.add('boardBinderIndex-tests', function(Y, NAME) {
+
+ var suite = new YUITest.TestSuite(NAME),
+ binder,
+ A = YUITest.Assert;
+
+ suite.add(new YUITest.TestCase({
+
+ name: 'board index binder tests',
+
+ setUp: function() {
+ binder = Y.mojito.binders.boardBinderIndex;
+ },
+ tearDown: function() {
+ binder = null;
+ },
+
+ 'TODO: test update id': function() {
+ var node = Y.Node.create("<div id='guid123'></div>");
+ binder.init({
+ _guid: 'guid123'
+ });
+ binder.bind(node);
+
+ // there is nothing to test in the binder initially
+ A.skip();
+
+ }
+
+ }));
+
+ YUITest.TestRunner.add(suite);
+
+}, '0.0.1', {requires: ['mojito-test', 'node', 'boardBinderIndex']});
View
62 mojits/board/tests/controller.server-tests.js
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+
+YUI.add('board-tests', function(Y) {
+
+ var suite = new YUITest.TestSuite('board-tests'),
+ controller = null,
+ A = YUITest.Assert;
+
+ suite.add(new YUITest.TestCase({
+
+ name: 'board user tests',
+
+ setUp: function() {
+ controller = Y.mojito.controllers.board;
+ },
+ tearDown: function() {
+ controller = null;
+ },
+
+ 'test mojit': function() {
+ var ac,
+ modelData,
+ assetsResults,
+ doneResults;
+ modelData = { x:'y' };
+ ac = {
+ assets: {
+ addCss: function(css) {
+ assetsResults = css;
+ }
+ },
+ models: {
+ boardModelFoo: {
+ getData: function(cb) {
+ cb(null, modelData);
+ }
+ }
+ },
+ done: function(data) {
+ doneResults = data;
+ }
+ };
+
+ A.isNotNull(controller);
+ A.isFunction(controller.index);
+ controller.index(ac);
+ A.areSame('./index.css', assetsResults);
+ A.isObject(doneResults);
+ A.areSame('Mojito is working.', doneResults.status);
+ A.isObject(doneResults.data);
+ A.isTrue(doneResults.data.hasOwnProperty('x'));
+ A.areEqual('y', doneResults.data['x']);
+
+ }
+
+ }));
+
+ YUITest.TestRunner.add(suite);
+
+}, '0.0.1', {requires: ['mojito-test', 'board']});
View
39 mojits/board/tests/models/foo.server-tests.js
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+
+YUI.add('boardModelFoo-tests', function(Y, NAME) {
+
+ var suite = new YUITest.TestSuite(NAME),
+ model = null,
+ A = YUITest.Assert;
+
+ suite.add(new YUITest.TestCase({
+
+ name: 'boardModelFoo user tests',
+
+ setUp: function() {
+ model = Y.mojito.models.boardModelFoo;
+ },
+ tearDown: function() {
+ model = null;
+ },
+
+ 'test mojit model': function() {
+ var called = false;
+ A.isNotNull(model);
+ A.isFunction(model.getData);
+ model.getData(function(err, data) {
+ called = true;
+ A.isTrue(!err);
+ A.isObject(data);
+ A.areSame('data', data.some);
+ });
+ A.isTrue(called);
+ }
+
+ }));
+
+ YUITest.TestRunner.add(suite);
+
+}, '0.0.1', {requires: ['mojito-test', 'boardModelFoo']});
View
10 mojits/board/views/index.mu.html
@@ -0,0 +1,10 @@
+<div id="{{mojit_view_id}}" class="board {{#empty}}noborder{{/empty}}">
+ {{#output}}
+ <div class='article' id='{{id}}'>
+ <h2>{{value}} <span class="btn-delete">x</span></h2>
+ <span>{{key}}</span>
+ </div>
+ {{/output}}
+ {{#customMsg}}<h2>{{msg}} </h2>{{/customMsg}}
+ {{#empty}} <h2>{{msg}}</h2>{{/empty}}
+</div>
View
54 mojits/boardInputBox/assets/index.css
@@ -0,0 +1,54 @@
+.boardInputBox{
+ border-radius: 5px;
+ margin: 8px;
+ background:#fefefe;
+ border: 1px solid #E9E9E9;
+ box-shadow: 0 1px 3px rgba(0,0,0,0.3);
+ padding: 10px;
+ text-align: center;
+ text-shadow: 1px 1px 0 white;
+ white-space: nowrap;
+ font-size:3em;
+ word-wrap: break-word;
+}
+
+.btn {
+ margin:10px 53px 10px 53px;
+ word-wrap: break-word;
+ padding:10px;
+ cursor:pointer;
+ background:#eee;
+ border-radius:4px;
+ text-align: center;
+ box-shadow: 0 5px 5px -5px #777;
+}
+
+
+.btn:hover{
+ box-shadow: 0 7px 7px -6px #000;
+ background:#ccc;
+}
+.btn:active{
+ background:#fff;
+ box-shadow: 0 5px 5px -5px #000;
+}
+
+.big-search-box {
+ z-index:1000;
+ border-radius: 6px;
+ border: 4px solid #ddd;
+ width:90%;
+ height:60px;
+ margin:5px;
+ font-size:1.0em;
+ color:#555;
+ font-weight:bold;
+ padding:7px;
+ -webkit-transition:all 0.9s; outline:none;
+}
+
+.big-search-box:focus{
+ box-shadow:inset 0 0 10px #999;
+ border:4px solid #ffffff;
+ -webkit-transition:all 0.9s;
+}
View
60 mojits/boardInputBox/binders/index.js
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+/*jslint anon:true, sloppy:true, nomen:true*/
+YUI.add('boardInputBoxBinderIndex', function(Y, NAME) {
+
+/**
+ * The boardInputBoxBinderIndex module.
+ *
+ * @module boardInputBoxBinderIndex
+ */
+
+ /**
+ * Constructor for the boardInputBoxBinderIndex class.
+ *
+ * @class boardInputBoxBinderIndex
+ * @constructor
+ */
+ Y.namespace('mojito.binders')[NAME] = {
+
+ /**
+ * Binder initialization method, invoked after all binders on the page
+ * have been constructed.
+ */
+ init: function(mojitProxy) {
+ this.mojitProxy = mojitProxy;
+ },
+
+ /**
+ * The binder method, invoked to allow the mojit to attach DOM event
+ * handlers.
+ *
+ * @param node {Node} The DOM node to which this mojit is attached.
+ */
+ bind: function(node) {
+ this.node = node;
+ node.one('#board-input-box').on('key', function(e) {
+ Y.fire('UPDATE_BOARD', {}, {
+ val: node.one('#board-input-box').get('value')
+ });
+ node.one('#board-input-box').set('value','');
+
+ }, 'press:13');
+
+ node.one('.show-all-article').on('click', function(e) {
+ Y.fire('SHOW_ALL_ARTICLE', {}, {});
+ });
+
+ node.one('.show-last-article').on('click', function(e) {
+ Y.fire('GET_LAST_ARTICLE', {}, {});
+ });
+
+ node.one('.show-first-article').on('click', function(e) {
+ Y.fire('GET_FIRST_ARTICLE', {}, {});
+ });
+ }
+
+ };
+
+}, '0.0.1', {requires: ['event-mouseenter', 'mojito-client', 'event-key']});
View
38 mojits/boardInputBox/controller.server.js
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+/*jslint anon:true, sloppy:true, nomen:true*/
+YUI.add('boardInputBox', function(Y, NAME) {
+
+/**
+ * The boardInputBox module.
+ *
+ * @module boardInputBox
+ */
+
+ /**
+ * Constructor for the Controller class.
+ *
+ * @class Controller
+ * @constructor
+ */
+ Y.namespace('mojito.controllers')[NAME] = {
+
+ init: function(config) {
+ this.config = config;
+ },
+
+ /**
+ * Method corresponding to the 'index' action.
+ *
+ * @param ac {Object} The ActionContext that provides access
+ * to the Mojito API.
+ */
+ index: function(ac) {
+ ac.assets.addCss('./index.css', 'top');
+ ac.done();
+ }
+
+ };
+
+}, '0.0.1', {requires: ['mojito', 'boardInputBoxModelFoo']});
View
5 mojits/boardInputBox/definition.json
@@ -0,0 +1,5 @@
+[
+ {
+ "settings": [ "master" ]
+ }
+]
View
37 mojits/boardInputBox/models/foo.server.js
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+/*jslint anon:true, sloppy:true, nomen:true*/
+YUI.add('boardInputBoxModelFoo', function(Y, NAME) {
+
+/**
+ * The boardInputBoxModelFoo module.
+ *
+ * @module boardInputBox
+ */
+
+ /**
+ * Constructor for the boardInputBoxModelFoo class.
+ *
+ * @class boardInputBoxModelFoo
+ * @constructor
+ */
+ Y.namespace('mojito.models')[NAME] = {
+
+ init: function(config) {
+ this.config = config;
+ },
+
+ /**
+ * Method that will be invoked by the mojit controller to obtain data.
+ *
+ * @param callback {function(err,data)} The callback function to call when the
+ * data has been retrieved.
+ */
+ getData: function(callback) {
+ callback(null, { some: 'data' });
+ }
+
+ };
+
+}, '0.0.1', {requires: []});
View
37 mojits/boardInputBox/tests/binders/index.common-tests.js
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+YUI.add('boardInputBoxBinderIndex-tests', function(Y, NAME) {
+
+ var suite = new YUITest.TestSuite(NAME),
+ binder,
+ A = YUITest.Assert;
+
+ suite.add(new YUITest.TestCase({
+
+ name: 'boardInputBox index binder tests',
+
+ setUp: function() {
+ binder = Y.mojito.binders.boardInputBoxBinderIndex;
+ },
+ tearDown: function() {
+ binder = null;
+ },
+
+ 'TODO: test update id': function() {
+ var node = Y.Node.create("<div id='guid123'></div>");
+ binder.init({
+ _guid: 'guid123'
+ });
+ binder.bind(node);
+
+ // there is nothing to test in the binder initially
+ A.skip();
+
+ }
+
+ }));
+
+ YUITest.TestRunner.add(suite);
+
+}, '0.0.1', {requires: ['mojito-test', 'node', 'boardInputBoxBinderIndex']});
View
62 mojits/boardInputBox/tests/controller.server-tests.js
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+
+YUI.add('boardInputBox-tests', function(Y) {
+
+ var suite = new YUITest.TestSuite('boardInputBox-tests'),
+ controller = null,
+ A = YUITest.Assert;
+
+ suite.add(new YUITest.TestCase({
+
+ name: 'boardInputBox user tests',
+
+ setUp: function() {
+ controller = Y.mojito.controllers.boardInputBox;
+ },
+ tearDown: function() {
+ controller = null;
+ },
+
+ 'test mojit': function() {
+ var ac,
+ modelData,
+ assetsResults,
+ doneResults;
+ modelData = { x:'y' };
+ ac = {
+ assets: {
+ addCss: function(css) {
+ assetsResults = css;
+ }
+ },
+ models: {
+ boardInputBoxModelFoo: {
+ getData: function(cb) {
+ cb(null, modelData);
+ }
+ }
+ },
+ done: function(data) {
+ doneResults = data;
+ }
+ };
+
+ A.isNotNull(controller);
+ A.isFunction(controller.index);
+ controller.index(ac);
+ A.areSame('./index.css', assetsResults);
+ A.isObject(doneResults);
+ A.areSame('Mojito is working.', doneResults.status);
+ A.isObject(doneResults.data);
+ A.isTrue(doneResults.data.hasOwnProperty('x'));
+ A.areEqual('y', doneResults.data['x']);
+
+ }
+
+ }));
+
+ YUITest.TestRunner.add(suite);
+
+}, '0.0.1', {requires: ['mojito-test', 'boardInputBox']});
View
39 mojits/boardInputBox/tests/models/foo.server-tests.js
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+
+YUI.add('boardInputBoxModelFoo-tests', function(Y, NAME) {
+
+ var suite = new YUITest.TestSuite(NAME),
+ model = null,
+ A = YUITest.Assert;
+
+ suite.add(new YUITest.TestCase({
+
+ name: 'boardInputBoxModelFoo user tests',
+
+ setUp: function() {
+ model = Y.mojito.models.boardInputBoxModelFoo;
+ },
+ tearDown: function() {
+ model = null;
+ },
+
+ 'test mojit model': function() {
+ var called = false;
+ A.isNotNull(model);
+ A.isFunction(model.getData);
+ model.getData(function(err, data) {
+ called = true;
+ A.isTrue(!err);
+ A.isObject(data);
+ A.areSame('data', data.some);
+ });
+ A.isTrue(called);
+ }
+
+ }));
+
+ YUITest.TestRunner.add(suite);
+
+}, '0.0.1', {requires: ['mojito-test', 'boardInputBoxModelFoo']});
View
6 mojits/boardInputBox/views/index.mu.html
@@ -0,0 +1,6 @@
+<div id="{{mojit_view_id}}" class="boardInputBox">
+ <input type="text" id="board-input-box" class="big-search-box" placeholder="type something and press enter"/>
+ <div class='show-last-article btn'>Show Last Article </div>
+ <div class='show-all-article btn'> Show All Article </div>
+ <div class='show-first-article btn'> Show First Article </div>
+</div>
View
3 mojits/main/assets/index.css
@@ -0,0 +1,3 @@
+#mojitcontainer{border:1px solid #ccc;}
+#mojitcontainer ul {background:#fff;/*width:inherit;*/margin:0; padding:0;-webkit-box-shadow: 0px 0px 10px #000;}
+#mojitcontainer ul li{position: relative; display: inline-block; height: inherit;}
View
42 mojits/main/binders/index.js
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+/*jslint anon:true, sloppy:true, nomen:true*/
+YUI.add('mainBinderIndex', function(Y, NAME) {
+
+/**
+ * The mainBinderIndex module.
+ *
+ * @module mainBinderIndex
+ */
+
+ /**
+ * Constructor for the mainBinderIndex class.
+ *
+ * @class mainBinderIndex
+ * @constructor
+ */
+ Y.namespace('mojito.binders')[NAME] = {
+
+ /**
+ * Binder initialization method, invoked after all binders on the page
+ * have been constructed.
+ */
+ init: function(mojitProxy) {
+ this.mojitProxy = mojitProxy;
+ },
+
+ /**
+ * The binder method, invoked to allow the mojit to attach DOM event
+ * handlers.
+ *
+ * @param node {Node} The DOM node to which this mojit is attached.
+ */
+ bind: function(node) {
+ var me = this;
+ this.node = node;
+ }
+
+ };
+
+}, '0.0.1', {requires: ['event-mouseenter', 'mojito-client']});
View
42 mojits/main/controller.server.js
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+/*jslint anon:true, sloppy:true, nomen:true*/
+YUI.add('main', function(Y, NAME) {
+
+/**
+ * The main module.
+ *
+ * @module main
+ */
+
+ /**
+ * Constructor for the Controller class.
+ *
+ * @class Controller
+ * @constructor
+ */
+ Y.mojito.controllers[NAME] = {
+
+
+
+ init: function(config) {
+ this.config = config;
+ },
+
+ /**
+ * Method corresponding to the 'index' action.
+ *
+ * @param ac {Object} The ActionContext that provides access
+ * to the Mojito API.
+ */
+ index: function(ac) {
+
+
+ ac.assets.addCss('./index.css'); //this is the css of the main htmlframemojit
+ ac.composite.done({template: {}});
+ }
+
+ };
+
+}, '0.0.1', {requires: ['mojito']});
View
5 mojits/main/definition.json
@@ -0,0 +1,5 @@
+[
+ {
+ "settings": [ "master" ]
+ }
+]
View
37 mojits/main/models/foo.server.js
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+/*jslint anon:true, sloppy:true, nomen:true*/
+YUI.add('mainModelFoo', function(Y, NAME) {
+
+/**
+ * The mainModelFoo module.
+ *
+ * @module main
+ */
+
+ /**
+ * Constructor for the mainModelFoo class.
+ *
+ * @class mainModelFoo
+ * @constructor
+ */
+ Y.mojito.models[NAME] = {
+
+ init: function(config) {
+ this.config = config;
+ },
+
+ /**
+ * Method that will be invoked by the mojit controller to obtain data.
+ *
+ * @param callback {function(err,data)} The callback function to call when the
+ * data has been retrieved.
+ */
+ getData: function(callback) {
+ callback(null, { some: 'data' });
+ }
+
+ };
+
+}, '0.0.1', {requires: []});
View
37 mojits/main/tests/binders/index.common-tests.js
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+YUI.add('mainBinderIndex-tests', function(Y, NAME) {
+
+ var suite = new YUITest.TestSuite(NAME),
+ binder,
+ A = YUITest.Assert;
+
+ suite.add(new YUITest.TestCase({
+
+ name: 'main index binder tests',
+
+ setUp: function() {
+ binder = Y.mojito.binders.mainBinderIndex;
+ },
+ tearDown: function() {
+ binder = null;
+ },
+
+ 'TODO: test update id': function() {
+ var node = Y.Node.create("<div id='guid123'></div>");
+ binder.init({
+ _guid: 'guid123'
+ });
+ binder.bind(node);
+
+ // there is nothing to test in the binder initially
+ A.skip();
+
+ }
+
+ }));
+
+ YUITest.TestRunner.add(suite);
+
+}, '0.0.1', {requires: ['mojito-test', 'node', 'mainBinderIndex']});
View
60 mojits/main/tests/controller.server-tests.js
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+
+YUI.add('main-tests', function(Y) {
+
+ var suite = new YUITest.TestSuite('main-tests'),
+ controller = null,
+ A = YUITest.Assert;
+
+ suite.add(new YUITest.TestCase({
+
+ name: 'main user tests',
+
+ setUp: function() {
+ controller = Y.mojito.controllers.main;
+ },
+ tearDown: function() {
+ controller = null;
+ },
+
+ 'test mojit': function() {
+ var ac,
+ modelData,
+ assetsResults,
+ doneResults;
+ modelData = { x:'y' };
+ ac = {
+ assets: {
+ addCss: function(css) {
+ assetsResults = css;
+ }
+ },
+ models: {
+ mainModelFoo: {
+ getData: function(cb) {
+ cb(null, modelData);
+ }
+ }
+ },
+ done: function(data) {
+ doneResults = data;
+ }
+ };
+
+ A.isNotNull(controller);
+ A.isFunction(controller.index);
+ controller.index(ac);
+ A.areSame('./index.css', assetsResults);
+ A.isObject(doneResults);
+ A.areSame('Mojito is working.', doneResults.status);
+ A.areSame('{"x":"y"}', doneResults.data);
+
+ }
+
+ }));
+
+ YUITest.TestRunner.add(suite);
+
+}, '0.0.1', {requires: ['mojito-test', 'main']});
View
39 mojits/main/tests/models/foo.server-tests.js
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2012 Yahoo! Inc. All rights reserved.
+ */
+
+YUI.add('mainModelFoo-tests', function(Y, NAME) {
+
+ var suite = new YUITest.TestSuite(NAME),
+ model = null,
+ A = YUITest.Assert;
+
+ suite.add(new YUITest.TestCase({
+
+ name: 'mainModelFoo user tests',
+
+ setUp: function() {
+ model = Y.mojito.models.mainModelFoo;
+ },
+ tearDown: function() {
+ model = null;
+ },
+
+ 'test mojit model': function() {
+ var called = false;
+ A.isNotNull(model);
+ A.isFunction(model.getData);
+ model.getData(function(err, data) {
+ called = true;
+ A.isTrue(!err);
+ A.isObject(data);
+ A.areSame('data', data.some);
+ });
+ A.isTrue(called);
+ }
+
+ }));
+
+ YUITest.TestRunner.add(suite);
+
+}, '0.0.1', {requires: ['mojito-test', 'mainModelFoo']});
View
6 mojits/main/views/index.mu.html
@@ -0,0 +1,6 @@
+
+<link href='http://fonts.googleapis.com/css?family=Fredericka+the+Great' rel='stylesheet' type='text/css'>
+<div id="{{mojit_view_id}}">
+{{{boardInputBox}}}
+{{{board}}}
+</div>
View
7 node_modules/mongodb/.tm_properties
@@ -0,0 +1,7 @@
+# Settings
+theme = "Reseif"
+fontName = "Courier"
+fontSize = 13
+fileBrowserGlob = "{*,.tm_properties,.htaccess}"
+tabSize = 2
+softTabs = true
View
5 node_modules/mongodb/.travis.yml
@@ -0,0 +1,5 @@
+language: node_js
+node_js:
+ - 0.4
+ - 0.6
+ - 0.7 # development version of 0.8, may be unstable
View
75 node_modules/mongodb/Makefile
@@ -0,0 +1,75 @@
+NODE = node
+NPM = npm
+NODEUNIT = node_modules/nodeunit/bin/nodeunit
+DOX = node_modules/dox/bin/dox
+name = all
+
+total: build_native
+
+build_native:
+ # $(MAKE) -C ./external-libs/bson all
+
+build_native_debug:
+ $(MAKE) -C ./external-libs/bson all_debug
+
+build_native_clang:
+ $(MAKE) -C ./external-libs/bson clang
+
+build_native_clang_debug:
+ $(MAKE) -C ./external-libs/bson clang_debug
+
+clean_native:
+ $(MAKE) -C ./external-libs/bson clean
+
+test: build_native
+ @echo "\n == Run All tests minus replicaset tests=="
+ $(NODE) dev/tools/test_all.js --noreplicaset --boot
+
+test_pure: build_native
+ @echo "\n == Run All tests minus replicaset tests=="
+ $(NODE) dev/tools/test_all.js --noreplicaset --boot --nonative
+
+test_junit: build_native
+ @echo "\n == Run All tests minus replicaset tests=="
+ $(NODE) dev/tools/test_all.js --junit --noreplicaset --nokill
+
+jenkins: build_native
+ @echo "\n == Run All tests minus replicaset tests=="
+ $(NODE) dev/tools/test_all.js --junit --noreplicaset --nokill
+
+test_nodeunit_pure:
+ @echo "\n == Execute Test Suite using Pure JS BSON Parser == "
+ @$(NODEUNIT) test/ test/gridstore test/bson
+
+test_js:
+ @$(NODEUNIT) $(TESTS)
+
+test_nodeunit_replicaset_pure:
+ @echo "\n == Execute Test Suite using Pure JS BSON Parser == "
+ @$(NODEUNIT) test/replicaset
+
+test_nodeunit_native:
+ @echo "\n == Execute Test Suite using Native BSON Parser == "
+ @TEST_NATIVE=TRUE $(NODEUNIT) test/ test/gridstore test/bson
+
+test_nodeunit_replicaset_native:
+ @echo "\n == Execute Test Suite using Native BSON Parser == "
+ @TEST_NATIVE=TRUE $(NODEUNIT) test/replicaset
+
+test_all: build_native
+ @echo "\n == Run All tests =="
+ $(NODE) dev/tools/test_all.js --boot
+
+test_all_junit: build_native
+ @echo "\n == Run All tests =="
+ $(NODE) dev/tools/test_all.js --junit --boot
+
+clean:
+ rm ./external-libs/bson/bson.node
+ rm -r ./external-libs/bson/build
+
+generate_docs:
+ $(NODE) dev/tools/build-docs.js
+ make --directory=./docs/sphinx-docs --file=Makefile html
+
+.PHONY: total
View
410 node_modules/mongodb/Readme.md
@@ -0,0 +1,410 @@
+Up to date documentation
+========================
+
+[Documentation](http://mongodb.github.com/node-mongodb-native/)
+
+Install
+=======
+
+To install the most recent release from npm, run:
+
+ npm install mongodb
+
+That may give you a warning telling you that bugs['web'] should be bugs['url'], it would be safe to ignore it (this has been fixed in the development version)
+
+To install the latest from the repository, run::
+
+ npm install path/to/node-mongodb-native
+
+Community
+=========
+Check out the google group [node-mongodb-native](http://groups.google.com/group/node-mongodb-native) for questions/answers from users of the driver.
+
+Introduction
+============
+
+This is a node.js driver for MongoDB. It's a port (or close to a port) of the library for ruby at http://github.com/mongodb/mongo-ruby-driver/.
+
+A simple example of inserting a document.
+
+ var client = new Db('test', new Server("127.0.0.1", 27017, {})),
+ test = function (err, collection) {
+ collection.insert({a:2}, function(err, docs) {
+
+ collection.count(function(err, count) {
+ test.assertEquals(1, count);
+ });
+
+ // Locate all the entries using find
+ collection.find().toArray(function(err, results) {
+ test.assertEquals(1, results.length);
+ test.assertTrue(results[0].a === 2);
+
+ // Let's close the db
+ client.close();
+ });
+ });
+ };
+
+ client.open(function(err, p_client) {
+ client.collection('test_insert', test);
+ });
+
+Data types
+==========
+
+To store and retrieve the non-JSON MongoDb primitives ([ObjectID](http://www.mongodb.org/display/DOCS/Object+IDs), Long, Binary, [Timestamp](http://www.mongodb.org/display/DOCS/Timestamp+data+type), [DBRef](http://www.mongodb.org/display/DOCS/Database+References#DatabaseReferences-DBRef), Code).
+
+In particular, every document has a unique `_id` which can be almost any type, and by default a 12-byte ObjectID is created. ObjectIDs can be represented as 24-digit hexadecimal strings, but you must convert the string back into an ObjectID before you can use it in the database. For example:
+
+ // Get the objectID type
+ var ObjectID = require('mongodb').ObjectID;
+
+ var idString = '4e4e1638c85e808431000003';
+ collection.findOne({_id: new ObjectID(idString)}, console.log) // ok
+ collection.findOne({_id: idString}, console.log) // wrong! callback gets undefined
+
+Here are the constructors the non-Javascript BSON primitive types:
+
+ // Fetch the library
+ var mongo = require('mongodb');
+ // Create new instances of BSON types
+ new mongo.Long(numberString)
+ new mongo.ObjectID(hexString)
+ new mongo.Timestamp() // the actual unique number is generated on insert.
+ new mongo.DBRef(collectionName, id, dbName)
+ new mongo.Binary(buffer) // takes a string or Buffer
+ new mongo.Code(code, [context])
+ new mongo.Symbol(string)
+ new mongo.MinKey()
+ new mongo.MaxKey()
+ new mongo.Double(number) // Force double storage
+
+The C/C++ bson parser/serializer
+--------------------------------
+
+If you are running a version of this library has the C/C++ parser compiled, to enable the driver to use the C/C++ bson parser pass it the option native_parser:true like below
+
+ // using native_parser:
+ var client = new Db('integration_tests_20',
+ new Server("127.0.0.1", 27017),
+ {native_parser:true});
+
+The C++ parser uses the js objects both for serialization and deserialization.
+
+GitHub information
+==================
+
+The source code is available at http://github.com/mongodb/node-mongodb-native.
+You can either clone the repository or download a tarball of the latest release.
+
+Once you have the source you can test the driver by running
+
+ $ make test
+
+in the main directory. You will need to have a mongo instance running on localhost for the integration tests to pass.
+
+Examples
+========
+
+For examples look in the examples/ directory. You can execute the examples using node.
+
+ $ cd examples
+ $ node queries.js
+
+GridStore
+=========
+
+The GridStore class allows for storage of binary files in mongoDB using the mongoDB defined files and chunks collection definition.
+
+For more information have a look at [Gridstore](https://github.com/mongodb/node-mongodb-native/blob/master/docs/gridfs.md)
+
+Replicasets
+===========
+For more information about how to connect to a replicaset have a look at [Replicasets](https://github.com/mongodb/node-mongodb-native/blob/master/docs/replicaset.md)
+
+Primary Key Factories
+---------------------
+
+Defining your own primary key factory allows you to generate your own series of id's
+(this could f.ex be to use something like ISBN numbers). The generated the id needs to be a 12 byte long "string".
+
+Simple example below
+
+ // Custom factory (need to provide a 12 byte array);
+ CustomPKFactory = function() {}
+ CustomPKFactory.prototype = new Object();
+ CustomPKFactory.createPk = function() {
+ return new ObjectID("aaaaaaaaaaaa");
+ }
+
+ var p_client = new Db('integration_tests_20', new Server("127.0.0.1", 27017, {}), {'pk':CustomPKFactory});
+ p_client.open(function(err, p_client) {
+ p_client.dropDatabase(function(err, done) {
+ p_client.createCollection('test_custom_key', function(err, collection) {
+ collection.insert({'a':1}, function(err, docs) {
+ collection.find({'_id':new ObjectID("aaaaaaaaaaaa")}, function(err, cursor) {
+ cursor.toArray(function(err, items) {
+ test.assertEquals(1, items.length);
+
+ // Let's close the db
+ p_client.close();
+ });
+ });
+ });
+ });
+ });
+ });
+
+Strict mode
+-----------
+
+Each database has an optional strict mode. If it is set then asking for a collection
+that does not exist will return an Error object in the callback. Similarly if you
+attempt to create a collection that already exists. Strict is provided for convenience.
+
+ var error_client = new Db('integration_tests_', new Server("127.0.0.1", 27017, {auto_reconnect: false}), {strict:true});
+ test.assertEquals(true, error_client.strict);
+
+ error_client.open(function(err, error_client) {
+ error_client.collection('does-not-exist', function(err, collection) {
+ test.assertTrue(err instanceof Error);
+ test.assertEquals("Collection does-not-exist does not exist. Currently in strict mode.", err.message);
+ });
+
+ error_client.createCollection('test_strict_access_collection', function(err, collection) {
+ error_client.collection('test_strict_access_collection', function(err, collection) {
+ test.assertTrue(collection instanceof Collection);
+ // Let's close the db
+ error_client.close();
+ });
+ });
+ });
+
+Documentation
+=============
+
+If this document doesn't answer your questions, see the source of
+[Collection](https://github.com/mongodb/node-mongodb-native/blob/master/lib/mongodb/collection.js)
+or [Cursor](https://github.com/mongodb/node-mongodb-native/blob/master/lib/mongodb/cursor.js),
+or the documentation at MongoDB for query and update formats.
+
+Find
+----
+
+The find method is actually a factory method to create
+Cursor objects. A Cursor lazily uses the connection the first time
+you call `nextObject`, `each`, or `toArray`.
+
+The basic operation on a cursor is the `nextObject` method
+that fetches the next matching document from the database. The convenience
+methods `each` and `toArray` call `nextObject` until the cursor is exhausted.
+
+Signatures:
+
+ var cursor = collection.find(query, [fields], options);
+ cursor.sort(fields).limit(n).skip(m).
+
+ cursor.nextObject(function(err, doc) {});
+ cursor.each(function(err, doc) {});
+ cursor.toArray(function(err, docs) {});
+
+ cursor.rewind() // reset the cursor to its initial state.
+
+Useful chainable methods of cursor. These can optionally be options of `find` instead of method calls:
+
+* `.limit(n).skip(m)` to control paging.
+* `.sort(fields)` Order by the given fields. There are several equivalent syntaxes:
+ * `.sort({field1: -1, field2: 1})` descending by field1, then ascending by field2.
+ * `.sort([['field1', 'desc'], ['field2', 'asc']])` same as above
+ * `.sort([['field1', 'desc'], 'field2'])` same as above
+ * `.sort('field1')` ascending by field1
+
+Other options of `find`:
+
+* `fields` the fields to fetch (to avoid transferring the entire document)
+* `tailable` if true, makes the cursor [tailable](http://www.mongodb.org/display/DOCS/Tailable+Cursors).
+* `batchSize` The number of the subset of results to request the database
+to return for every request. This should initially be greater than 1 otherwise
+the database will automatically close the cursor. The batch size can be set to 1
+with `batchSize(n, function(err){})` after performing the initial query to the database.
+* `hint` See [Optimization: hint](http://www.mongodb.org/display/DOCS/Optimization#Optimization-Hint).
+* `explain` turns this into an explain query. You can also call
+`explain()` on any cursor to fetch the explanation.
+* `snapshot` prevents documents that are updated while the query is active
+from being returned multiple times. See more
+[details about query snapshots](http://www.mongodb.org/display/DOCS/How+to+do+Snapshotted+Queries+in+the+Mongo+Database).
+* `timeout` if false, asks MongoDb not to time out this cursor after an
+inactivity period.
+
+
+For information on how to create queries, see the
+[MongoDB section on querying](http://www.mongodb.org/display/DOCS/Querying).
+
+ var mongodb = require('mongodb');
+ var server = new mongodb.Server("127.0.0.1", 27017, {});
+ new mongodb.Db('test', server, {}).open(function (error, client) {
+ if (error) throw error;
+ var collection = new mongodb.Collection(client, 'test_collection');
+ collection.find({}, {limit:10}).toArray(function(err, docs) {
+ console.dir(docs);
+ });
+ });
+
+Insert
+------
+
+Signature:
+
+ collection.insert(docs, options, [callback]);
+
+where `docs` can be a single document or an array of documents.
+
+Useful options:
+
+* `safe:true` Should always set if you have a callback.
+
+See also: [MongoDB docs for insert](http://www.mongodb.org/display/DOCS/Inserting).
+
+ var mongodb = require('mongodb');
+ var server = new mongodb.Server("127.0.0.1", 27017, {});
+ new mongodb.Db('test', server, {}).open(function (error, client) {
+ if (error) throw error;
+ var collection = new mongodb.Collection(client, 'test_collection');
+ collection.insert({hello: 'world'}, {safe:true},
+ function(err, objects) {
+ if (err) console.warn(err.message);
+ if (err && err.message.indexOf('E11000 ') !== -1) {
+ // this _id was already inserted in the database
+ }
+ });
+ });
+
+Note that there's no reason to pass a callback to the insert or update commands
+unless you use the `safe:true` option. If you don't specify `safe:true`, then
+your callback will be called immediately.
+
+Update; update and insert (upsert)
+----------------------------------
+
+The update operation will update the first document that matches your query
+(or all documents that match if you use `multi:true`).
+If `safe:true`, `upsert` is not set, and no documents match, your callback will return 0 documents updated.
+
+See the [MongoDB docs](http://www.mongodb.org/display/DOCS/Updating) for
+the modifier (`$inc`, `$set`, `$push`, etc.) formats.
+
+Signature:
+
+ collection.update(criteria, objNew, options, [callback]);
+
+Useful options:
+
+* `safe:true` Should always set if you have a callback.
+* `multi:true` If set, all matching documents are updated, not just the first.
+* `upsert:true` Atomically inserts the document if no documents matched.
+
+Example for `update`:
+
+ var mongodb = require('mongodb');
+ var server = new mongodb.Server("127.0.0.1", 27017, {});
+ new mongodb.Db('test', server, {}).open(function (error, client) {
+ if (error) throw error;
+ var collection = new mongodb.Collection(client, 'test_collection');
+ collection.update({hi: 'here'}, {$set: {hi: 'there'}}, {safe:true},
+ function(err) {
+ if (err) console.warn(err.message);
+ else console.log('successfully updated');
+ });
+ });
+
+Find and modify
+---------------
+
+`findAndModify` is like `update`, but it also gives the updated document to
+your callback. But there are a few key differences between findAndModify and
+update:
+
+ 1. The signatures differ.
+ 2. You can only findAndModify a single item, not multiple items.
+
+Signature:
+
+ collection.findAndModify(query, sort, update, options, callback)
+
+The sort parameter is used to specify which object to operate on, if more than
+one document matches. It takes the same format as the cursor sort (see
+Connection.find above).
+
+See the
+[MongoDB docs for findAndModify](http://www.mongodb.org/display/DOCS/findAndModify+Command)
+for more details.
+
+Useful options:
+
+* `remove:true` set to a true to remove the object before returning
+* `new:true` set to true if you want to return the modified object rather than the original. Ignored for remove.
+* `upsert:true` Atomically inserts the document if no documents matched.
+
+Example for `findAndModify`:
+
+ var mongodb = require('mongodb');
+ var server = new mongodb.Server("127.0.0.1", 27017, {});
+ new mongodb.Db('test', server, {}).open(function (error, client) {
+ if (error) throw error;
+ var collection = new mongodb.Collection(client, 'test_collection');
+ collection.findAndModify({hello: 'world'}, [['_id','asc']], {$set: {hi: 'there'}}, {},
+ function(err, object) {
+ if (err) console.warn(err.message);
+ else console.dir(object); // undefined if no matching object exists.
+ });
+ });
+
+Save
+----
+
+The `save` method is a shorthand for upsert if the document contains an
+`_id`, or an insert if there is no `_id`.
+
+Sponsors
+========
+Just as Felix Geisendörfer I'm also working on the driver for my own startup and this driver is a big project that also benefits other companies who are using MongoDB.
+
+If your company could benefit from a even better-engineered node.js mongodb driver I would appreciate any type of sponsorship you may be able to provide. All the sponsors will get a lifetime display in this readme, priority support and help on problems and votes on the roadmap decisions for the driver. If you are interested contact me on [christkv AT g m a i l.com](mailto:christkv@gmail.com) for details.
+
+And I'm very thankful for code contributions. If you are interested in working on features please contact me so we can discuss API design and testing.
+
+Release Notes
+=============
+
+See HISTORY
+
+Credits
+=======
+
+1. [10gen](http://github.com/mongodb/mongo-ruby-driver/)
+2. [Google Closure Library](http://code.google.com/closure/library/)
+3. [Jonas Raoni Soares Silva](http://jsfromhell.com/classes/binary-parser)
+
+Contributors
+============
+
+Aaron Heckmann, Christoph Pojer, Pau Ramon Revilla, Nathan White, Emmerman, Seth LaForge, Boris Filipov, Stefan Schärmeli, Tedde Lundgren, renctan, Sergey Ukustov, Ciaran Jessup, kuno, srimonti, Erik Abele, Pratik Daga, Slobodan Utvic, Kristina Chodorow, Yonathan Randolph, Brian Noguchi, Sam Epstein, James Harrison Fisher, Vladimir Dronnikov, Ben Hockey, Henrik Johansson, Simon Weare, Alex Gorbatchev, Shimon Doodkin, Kyle Mueller, Eran Hammer-Lahav, Marcin Ciszak, François de Metz, Vinay Pulim, nstielau, Adam Wiggins, entrinzikyl, Jeremy Selier, Ian Millington, Public Keating, andrewjstone, Christopher Stott, Corey Jewett, brettkiefer, Rob Holland, Senmiao Liu, heroic, gitfy
+
+License
+=======
+
+ Copyright 2009 - 2012 Christian Amor Kvalheim.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
View
1 node_modules/mongodb/index.js
@@ -0,0 +1 @@
+module.exports = require('./lib/mongodb');
View
40 node_modules/mongodb/install.js
@@ -0,0 +1,40 @@
+var spawn = require('child_process').spawn,
+ exec = require('child_process').exec;
+
+process.stdout.write("================================================================================\n");
+process.stdout.write("= =\n");
+process.stdout.write("= To install with C++ bson parser do <npm install mongodb --mongodb:native> =\n");
+process.stdout.write("= =\n");
+process.stdout.write("================================================================================\n");
+
+// Check if we want to build the native code
+var build_native = process.env['npm_package_config_native'] != null ? process.env['npm_package_config_native'] : 'false';
+build_native = build_native == 'true' ? true : false;
+// If we are building the native bson extension ensure we use gmake if available
+if(build_native) {
+ // Check if we need to use gmake
+ exec('which gmake', function(err, stdout, stderr) {
+ // Set up spawn command
+ var make = null;
+ // No gmake build using make
+ if(err != null) {
+ make = spawn('make', ['total']);
+ } else {
+ make = spawn('gmake', ['total']);
+ }
+
+ // Execute spawn
+ make.stdout.on('data', function(data) {
+ process.stdout.write(data);
+ })
+
+ make.stderr.on('data', function(data) {
+ process.stdout.write(data);
+ })
+
+ make.on('exit', function(code) {
+ process.stdout.write('child process exited with code ' + code + "\n");
+ })
+ });
+}
+
View
340 node_modules/mongodb/lib/mongodb/admin.js
@@ -0,0 +1,340 @@
+/*!
+ * Module dependencies.
+ */
+var Collection = require('./collection').Collection,
+ Cursor = require('./cursor').Cursor,
+ DbCommand = require('./commands/db_command').DbCommand;
+
+/**
+ * Allows the user to access the admin functionality of MongoDB
+ *
+ * @class Represents the Admin methods of MongoDB.
+ * @param {Object} db Current db instance we wish to perform Admin operations on.
+ * @return {Function} Constructor for Admin type.
+ */
+function Admin(db) {
+ if(!(this instanceof Admin)) return new Admin(db);
+ this.db = db;
+};
+
+/**
+ * Retrieve the server information for the current
+ * instance of the db client
+ *
+ * @param {Function} callback Callback function of format `function(err, result) {}`.
+ * @return {null} Returns no result
+ * @api public
+ */
+Admin.prototype.buildInfo = function(callback) {
+ this.serverInfo(callback);
+}
+
+/**
+ * Retrieve the server information for the current
+ * instance of the db client
+ *
+ * @param {Function} callback Callback function of format `function(err, result) {}`.
+ * @return {null} Returns no result
+ * @api private
+ */
+Admin.prototype.serverInfo = function(callback) {
+ this.db.executeDbAdminCommand({buildinfo:1}, function(err, doc) {
+ if(err != null) return callback(err, null);
+ return callback(null, doc.documents[0]);
+ });
+}
+
+/**
+ * Retrieve this db's server status.
+ *
+ * @param {Function} callback returns the server status.
+ * @return {null}
+ * @api public
+ */
+Admin.prototype.serverStatus = function(callback) {
+ var self = this;
+
+ this.db.executeDbAdminCommand({serverStatus: 1}, function(err, doc) {
+ if(err == null && doc.documents[0].ok === 1) {
+ callback(null, doc.documents[0]);
+ } else {
+ if(err) return callback(err, false);
+ return callback(self.wrap(doc.documents[0]), false);
+ }
+ });
+};
+
+/**
+ * Retrieve the current profiling Level for MongoDB
+ *
+ * @param {Function} callback Callback function of format `function(err, result) {}`.
+ * @return {null} Returns no result
+ * @api public
+ */
+Admin.prototype.profilingLevel = function(callback) {
+ var self = this;
+
+ this.db.executeDbAdminCommand({profile:-1}, function(err, doc) {
+ doc = doc.documents[0];
+
+ if(err == null && doc.ok === 1) {
+ var was = doc.was;
+ if(was == 0) return callback(null, "off");
+ if(was == 1) return callback(null, "slow_only");
+ if(was == 2) return callback(null, "all");
+ return callback(new Error("Error: illegal profiling level value " + was), null);
+ } else {
+ err != null ? callback(err, null) : callback(new Error("Error with profile command"), null);
+ }
+ });
+};
+
+/**
+ * Ping the MongoDB server and retrieve results
+ *
+ * @param {Function} callback Callback function of format `function(err, result) {}`.
+ * @return {null} Returns no result
+ * @api public
+ */
+Admin.prototype.ping = function(options, callback) {
+ // Unpack calls
+ var args = Array.prototype.slice.call(arguments, 0);
+ callback = args.pop();
+
+ this.db.executeDbAdminCommand({ping: 1}, callback);
+}
+
+/**
+ * Authenticate against MongoDB
+ *
+ * @param {String} username The user name for the authentication.
+ * @param {String} password The password for the authentication.
+ * @param {Function} callback Callback function of format `function(err, result) {}`.
+ * @return {null} Returns no result
+ * @api public
+ */
+Admin.prototype.authenticate = function(username, password, callback) {
+ this.db.authenticate(username, password, {authdb: 'admin'}, function(err, doc) {
+ return callback(err, doc);
+ })
+}
+
+/**
+ * Logout current authenticated user
+ *
+ * @param {Object} [options] Optional parameters to the command.
+ * @param {Function} callback Callback function of format `function(err, result) {}`.
+ * @return {null} Returns no result
+ * @api public
+ */
+Admin.prototype.logout = function(callback) {
+ this.db.logout({authdb: 'admin'}, function(err, doc) {
+ return callback(err, doc);
+ })
+}
+
+/**
+ * Add a user to the MongoDB server, if the user exists it will
+ * overwrite the current password
+ *
+ * Options
+ * - **safe** {true | {w:n, wtimeout:n} | {fsync:true}, default:false}, executes with a getLastError command returning the results of the command on MongoDB.
+ *
+ * @param {String} username The user name for the authentication.
+ * @param {String} password The password for the authentication.
+ * @param {Object} [options] additional options during update.
+ * @param {Function} callback Callback function of format `function(err, result) {}`.
+ * @return {null} Returns no result
+ * @api public
+ */
+Admin.prototype.addUser = function(username, password, options, callback) {
+ var args = Array.prototype.slice.call(arguments, 2);
+ callback = args.pop();
+ options = args.length ? args.shift() : {};
+
+ options.dbName = 'admin';
+ // Add user
+ this.db.addUser(username, password, options, function(err, doc) {
+ return callback(err, doc);
+ })
+}
+
+/**
+ * Remove a user from the MongoDB server
+ *
+ * Options
+ * - **safe** {true | {w:n, wtimeout:n} | {fsync:true}, default:false}, executes with a getLastError command returning the results of the command on MongoDB.
+ *
+ * @param {String} username The user name for the authentication.
+ * @param {Object} [options] additional options during update.
+ * @param {Function} callback Callback function of format `function(err, result) {}`.
+ * @return {null} Returns no result
+ * @api public
+ */
+Admin.prototype.removeUser = function(username, options, callback) {
+ var self = this;
+ var args = Array.prototype.slice.call(arguments, 1);
+ callback = args.pop();
+ options = args.length ? args.shift() : {};
+ options.dbName = 'admin';
+
+ this.db.removeUser(username, options, function(err, doc) {
+ return callback(err, doc);
+ })
+}
+
+/**
+ * Set the current profiling level of MongoDB
+ *
+ * @param {String} level The new profiling level (off, slow_only, all)
+ * @param {Function} callback Callback function of format `function(err, result) {}`.
+ * @return {null} Returns no result
+ * @api public
+ */
+Admin.prototype.setProfilingLevel = function(level, callback) {
+ var self = this;
+ var command = {};
+ var profile = 0;
+
+ if(level == "off") {
+ profile = 0;
+ } else if(level == "slow_only") {
+ profile = 1;
+ } else if(level == "all") {
+ profile = 2;
+ } else {
+ return callback(new Error("Error: illegal profiling level value " + level));
+ }
+
+ // Set up the profile number
+ command['profile'] = profile;
+
+ this.db.executeDbAdminCommand(command, function(err, doc) {
+ doc = doc.documents[0];
+
+ if(err == null && doc.ok === 1)
+ return callback(null, level);
+ return err != null ? callback(err, null) : callback(new Error("Error with profile command"), null);
+ });
+};
+
+/**
+ * Retrive the current profiling information for MongoDB
+ *
+ * @param {Function} callback Callback function of format `function(err, result) {}`.