diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..3ca8c7f Binary files /dev/null and b/.DS_Store differ diff --git a/app/js/app.js b/app/js/app.js index bbe72ba..45508f0 100644 --- a/app/js/app.js +++ b/app/js/app.js @@ -1,5 +1,5 @@ // Declare app level module which depends on ngRoute -angular.module('NoteWrangler', ['ngRoute', 'ngResource', 'Gravatar']) +angular.module('NoteWrangler', ['ngRoute', 'ngResource', 'Gravatar', 'firebase']) .config(function($gravatarProvider){ $gravatarProvider.setSize(100); }); diff --git a/app/js/controllers/notes-index-controller.js b/app/js/controllers/notes-index-controller.js index 374d909..bb646d8 100644 --- a/app/js/controllers/notes-index-controller.js +++ b/app/js/controllers/notes-index-controller.js @@ -1,12 +1,17 @@ -angular.module('NoteWrangler').controller('NotesIndexController', function($scope, Note, Session) { +angular.module('NoteWrangler') +.controller('NotesIndexController', function($scope, Note, Session) { // Without NgResource // Note.all().success(function(data) { // $scope.notes = data; // }); - + // With NgResource $scope.notes = Note.query(); + // With Firebase + // $scope.notes = Note(); + + Session.sessionData().success(function(sessionUser) { // Create a new User from the session user data $scope.loggedIn = !!sessionUser; diff --git a/app/js/controllers/users-index-controller.js b/app/js/controllers/users-index-controller.js index c11c062..a8b2a3d 100644 --- a/app/js/controllers/users-index-controller.js +++ b/app/js/controllers/users-index-controller.js @@ -1,13 +1,17 @@ -angular.module('NoteWrangler').controller('UsersIndexController', function($scope, User, $gravatar) { - +angular.module('NoteWrangler') +.controller('UsersIndexController', function($scope, User, $gravatar) { + // Without NgResource // User.all().success(function(data) { // $scope.users = data; // }); - + // With NgResource - $scope.users = User.query(); - + // $scope.users = User.query(); + + // With Firebase + $scope.users = User(); + $scope.gravatarUrl = function(user) { return $gravatar.generate(user.email); } diff --git a/app/js/resources/note.js b/app/js/resources/note.js index a9ab47f..d57cc36 100644 --- a/app/js/resources/note.js +++ b/app/js/resources/note.js @@ -3,8 +3,30 @@ This is a way of handling ajax requests using NgResource, it performs a similar to the Note Service. */ -angular.module('NoteWrangler').factory('Note', function NoteFactory($resource) { - return $resource('/notes/:id', {}, { +// angular.module('NoteWrangler') +// .factory('Note', function NoteFactory($resource) { +// return $resource('/notes/:id', {}, { +// update: { +// method: "PUT" +// } +// }); +// }); + +// Firebase way +// angular.module('NoteWrangler') +// .factory('Note', function NoteFactory($firebaseArray) { +// return function(){ +// // creating the snapshot of our data +// var ref = new Firebase('https://notewrangler.firebaseio.com/notes'); +// // return a synchronized array +// return $firebaseArray(ref); +// }; +// }); + +// Firebase - Normal restful call +angular.module('NoteWrangler') +.factory('Note', function NoteFactory($resource) { + return $resource('https://notewrangler.firebaseio.com/notes/:id.json', {}, { update: { method: "PUT" } diff --git a/app/js/resources/user.js b/app/js/resources/user.js index 4249e7c..8a8b953 100644 --- a/app/js/resources/user.js +++ b/app/js/resources/user.js @@ -3,10 +3,20 @@ This is a way of handling ajax requests using NgResource, it performs a similar to the UserService. */ -angular.module('NoteWrangler').factory('User', function UserFactory($resource) { - return $resource('/users/:id', {}, { - update: { - method: "PUT" - } - }); +// angular.module('NoteWrangler') +// .factory('User', function UserFactory($resource) { +// return $resource('/users/:id', {}, { +// update: { +// method: "PUT" +// } +// }); +// }); +// + +angular.module('NoteWrangler') +.factory('User', function UserFactory($firebaseArray) { + return function(){ + var ref = new Firebase('https://notewrangler.firebaseio.com/users'); + return $firebaseArray(ref); + }; }); diff --git a/app/js/services/note.js b/app/js/services/note.js index a2ea6a5..3c31f1f 100644 --- a/app/js/services/note.js +++ b/app/js/services/note.js @@ -5,6 +5,7 @@ This is for reference only, we favor using Note over this in the app. angular.module('NoteWrangler') .factory('Note', ['$http', function NoteFactory($http) { + return { all: function() { return $http({method: 'GET', url: "/notes"}); diff --git a/app/server/views/index.html b/app/server/views/index.html index c563756..0c795f4 100644 --- a/app/server/views/index.html +++ b/app/server/views/index.html @@ -26,10 +26,10 @@ -
@@ -40,7 +40,7 @@new BufferList([ callback ])
+ * bl.length
+ * bl.append(buffer)
+ * bl.get(index)
+ * bl.slice([ start[, end ] ])
+ * bl.copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ])
+ * bl.duplicate()
+ * bl.consume(bytes)
+ * bl.toString([encoding, [ start, [ end ]]])
+ * bl.readDoubleBE()
, bl.readDoubleLE()
, bl.readFloatBE()
, bl.readFloatLE()
, bl.readInt32BE()
, bl.readInt32LE()
, bl.readUInt32BE()
, bl.readUInt32LE()
, bl.readInt16BE()
, bl.readInt16LE()
, bl.readUInt16BE()
, bl.readUInt16LE()
, bl.readInt8()
, bl.readUInt8()
+ * Streams
+
+--------------------------------------------------------
+
+### new BufferList([ callback | buffer | buffer array ])
+The constructor takes an optional callback, if supplied, the callback will be called with an error argument followed by a reference to the **bl** instance, when `bl.end()` is called (i.e. from a piped stream). This is a convenient method of collecting the entire contents of a stream, particularly when the stream is *chunky*, such as a network stream.
+
+Normally, no arguments are required for the constructor, but you can initialise the list by passing in a single `Buffer` object or an array of `Buffer` object.
+
+`new` is not strictly required, if you don't instantiate a new object, it will be done automatically for you so you can create a new instance simply with:
+
+```js
+var bl = require('bl')
+var myinstance = bl()
+
+// equivilant to:
+
+var BufferList = require('bl')
+var myinstance = new BufferList()
+```
+
+--------------------------------------------------------
+
+### bl.length
+Get the length of the list in bytes. This is the sum of the lengths of all of the buffers contained in the list, minus any initial offset for a semi-consumed buffer at the beginning. Should accurately represent the total number of bytes that can be read from the list.
+
+--------------------------------------------------------
+
+### bl.append(buffer)
+`append(buffer)` adds an additional buffer or BufferList to the internal list.
+
+--------------------------------------------------------
+
+### bl.get(index)
+`get()` will return the byte at the specified index.
+
+--------------------------------------------------------
+
+### bl.slice([ start, [ end ] ])
+`slice()` returns a new `Buffer` object containing the bytes within the range specified. Both `start` and `end` are optional and will default to the beginning and end of the list respectively.
+
+If the requested range spans a single internal buffer then a slice of that buffer will be returned which shares the original memory range of that Buffer. If the range spans multiple buffers then copy operations will likely occur to give you a uniform Buffer.
+
+--------------------------------------------------------
+
+### bl.copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ])
+`copy()` copies the content of the list in the `dest` buffer, starting from `destStart` and containing the bytes within the range specified with `srcStart` to `srcEnd`. `destStart`, `start` and `end` are optional and will default to the beginning of the `dest` buffer, and the beginning and end of the list respectively.
+
+--------------------------------------------------------
+
+### bl.duplicate()
+`duplicate()` performs a **shallow-copy** of the list. The internal Buffers remains the same, so if you change the underlying Buffers, the change will be reflected in both the original and the duplicate. This method is needed if you want to call `consume()` or `pipe()` and still keep the original list.Example:
+
+```js
+var bl = new BufferList()
+
+bl.append('hello')
+bl.append(' world')
+bl.append('\n')
+
+bl.duplicate().pipe(process.stdout, { end: false })
+
+console.log(bl.toString())
+```
+
+--------------------------------------------------------
+
+### bl.consume(bytes)
+`consume()` will shift bytes *off the start of the list*. The number of bytes consumed don't need to line up with the sizes of the internal Buffers—initial offsets will be calculated accordingly in order to give you a consistent view of the data.
+
+--------------------------------------------------------
+
+### bl.toString([encoding, [ start, [ end ]]])
+`toString()` will return a string representation of the buffer. The optional `start` and `end` arguments are passed on to `slice()`, while the `encoding` is passed on to `toString()` of the resulting Buffer. See the [Buffer#toString()](http://nodejs.org/docs/latest/api/buffer.html#buffer_buf_tostring_encoding_start_end) documentation for more information.
+
+--------------------------------------------------------
+
+### bl.readDoubleBE(), bl.readDoubleLE(), bl.readFloatBE(), bl.readFloatLE(), bl.readInt32BE(), bl.readInt32LE(), bl.readUInt32BE(), bl.readUInt32LE(), bl.readInt16BE(), bl.readInt16LE(), bl.readUInt16BE(), bl.readUInt16LE(), bl.readInt8(), bl.readUInt8()
+
+All of the standard byte-reading methods of the `Buffer` interface are implemented and will operate across internal Buffer boundaries transparently.
+
+See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
documentation for how these work.
+
+--------------------------------------------------------
+
+### Streams
+**bl** is a Node **[Duplex Stream](http://nodejs.org/docs/latest/api/stream.html#stream_class_stream_duplex)**, so it can be read from and written to like a standard Node stream. You can also `pipe()` to and from a **bl** instance.
+
+--------------------------------------------------------
+
+## Contributors
+
+**bl** is brought to you by the following hackers:
+
+ * [Rod Vagg](https://github.com/rvagg)
+ * [Matteo Collina](https://github.com/mcollina)
+ * [Jarett Cruger](https://github.com/jcrugzz)
+
+=======
+
+
+## License & copyright
+
+Copyright (c) 2013-2014 bl contributors (listed above).
+
+bl is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.
diff --git a/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/bl/bl.js b/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/bl/bl.js
new file mode 100644
index 0000000..7a2f997
--- /dev/null
+++ b/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/bl/bl.js
@@ -0,0 +1,216 @@
+var DuplexStream = require('readable-stream/duplex')
+ , util = require('util')
+
+function BufferList (callback) {
+ if (!(this instanceof BufferList))
+ return new BufferList(callback)
+
+ this._bufs = []
+ this.length = 0
+
+ if (typeof callback == 'function') {
+ this._callback = callback
+
+ var piper = function (err) {
+ if (this._callback) {
+ this._callback(err)
+ this._callback = null
+ }
+ }.bind(this)
+
+ this.on('pipe', function (src) {
+ src.on('error', piper)
+ })
+ this.on('unpipe', function (src) {
+ src.removeListener('error', piper)
+ })
+ }
+ else if (Buffer.isBuffer(callback))
+ this.append(callback)
+ else if (Array.isArray(callback)) {
+ callback.forEach(function (b) {
+ Buffer.isBuffer(b) && this.append(b)
+ }.bind(this))
+ }
+
+ DuplexStream.call(this)
+}
+
+util.inherits(BufferList, DuplexStream)
+
+BufferList.prototype._offset = function (offset) {
+ var tot = 0, i = 0, _t
+ for (; i < this._bufs.length; i++) {
+ _t = tot + this._bufs[i].length
+ if (offset < _t)
+ return [ i, offset - tot ]
+ tot = _t
+ }
+}
+
+BufferList.prototype.append = function (buf) {
+ var isBuffer = Buffer.isBuffer(buf) ||
+ buf instanceof BufferList
+
+ this._bufs.push(isBuffer ? buf : new Buffer(buf))
+ this.length += buf.length
+ return this
+}
+
+BufferList.prototype._write = function (buf, encoding, callback) {
+ this.append(buf)
+ if (callback)
+ callback()
+}
+
+BufferList.prototype._read = function (size) {
+ if (!this.length)
+ return this.push(null)
+ size = Math.min(size, this.length)
+ this.push(this.slice(0, size))
+ this.consume(size)
+}
+
+BufferList.prototype.end = function (chunk) {
+ DuplexStream.prototype.end.call(this, chunk)
+
+ if (this._callback) {
+ this._callback(null, this.slice())
+ this._callback = null
+ }
+}
+
+BufferList.prototype.get = function (index) {
+ return this.slice(index, index + 1)[0]
+}
+
+BufferList.prototype.slice = function (start, end) {
+ return this.copy(null, 0, start, end)
+}
+
+BufferList.prototype.copy = function (dst, dstStart, srcStart, srcEnd) {
+ if (typeof srcStart != 'number' || srcStart < 0)
+ srcStart = 0
+ if (typeof srcEnd != 'number' || srcEnd > this.length)
+ srcEnd = this.length
+ if (srcStart >= this.length)
+ return dst || new Buffer(0)
+ if (srcEnd <= 0)
+ return dst || new Buffer(0)
+
+ var copy = !!dst
+ , off = this._offset(srcStart)
+ , len = srcEnd - srcStart
+ , bytes = len
+ , bufoff = (copy && dstStart) || 0
+ , start = off[1]
+ , l
+ , i
+
+ // copy/slice everything
+ if (srcStart === 0 && srcEnd == this.length) {
+ if (!copy) // slice, just return a full concat
+ return Buffer.concat(this._bufs)
+
+ // copy, need to copy individual buffers
+ for (i = 0; i < this._bufs.length; i++) {
+ this._bufs[i].copy(dst, bufoff)
+ bufoff += this._bufs[i].length
+ }
+
+ return dst
+ }
+
+ // easy, cheap case where it's a subset of one of the buffers
+ if (bytes <= this._bufs[off[0]].length - start) {
+ return copy
+ ? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes)
+ : this._bufs[off[0]].slice(start, start + bytes)
+ }
+
+ if (!copy) // a slice, we need something to copy in to
+ dst = new Buffer(len)
+
+ for (i = off[0]; i < this._bufs.length; i++) {
+ l = this._bufs[i].length - start
+
+ if (bytes > l) {
+ this._bufs[i].copy(dst, bufoff, start)
+ } else {
+ this._bufs[i].copy(dst, bufoff, start, start + bytes)
+ break
+ }
+
+ bufoff += l
+ bytes -= l
+
+ if (start)
+ start = 0
+ }
+
+ return dst
+}
+
+BufferList.prototype.toString = function (encoding, start, end) {
+ return this.slice(start, end).toString(encoding)
+}
+
+BufferList.prototype.consume = function (bytes) {
+ while (this._bufs.length) {
+ if (bytes > this._bufs[0].length) {
+ bytes -= this._bufs[0].length
+ this.length -= this._bufs[0].length
+ this._bufs.shift()
+ } else {
+ this._bufs[0] = this._bufs[0].slice(bytes)
+ this.length -= bytes
+ break
+ }
+ }
+ return this
+}
+
+BufferList.prototype.duplicate = function () {
+ var i = 0
+ , copy = new BufferList()
+
+ for (; i < this._bufs.length; i++)
+ copy.append(this._bufs[i])
+
+ return copy
+}
+
+BufferList.prototype.destroy = function () {
+ this._bufs.length = 0;
+ this.length = 0;
+ this.push(null);
+}
+
+;(function () {
+ var methods = {
+ 'readDoubleBE' : 8
+ , 'readDoubleLE' : 8
+ , 'readFloatBE' : 4
+ , 'readFloatLE' : 4
+ , 'readInt32BE' : 4
+ , 'readInt32LE' : 4
+ , 'readUInt32BE' : 4
+ , 'readUInt32LE' : 4
+ , 'readInt16BE' : 2
+ , 'readInt16LE' : 2
+ , 'readUInt16BE' : 2
+ , 'readUInt16LE' : 2
+ , 'readInt8' : 1
+ , 'readUInt8' : 1
+ }
+
+ for (var m in methods) {
+ (function (m) {
+ BufferList.prototype[m] = function (offset) {
+ return this.slice(offset, offset + methods[m])[m](0)
+ }
+ }(m))
+ }
+}())
+
+module.exports = BufferList
diff --git a/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/bl/node_modules/readable-stream/.npmignore b/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/bl/node_modules/readable-stream/.npmignore
new file mode 100644
index 0000000..38344f8
--- /dev/null
+++ b/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/bl/node_modules/readable-stream/.npmignore
@@ -0,0 +1,5 @@
+build/
+test/
+examples/
+fs.js
+zlib.js
\ No newline at end of file
diff --git a/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/bl/node_modules/readable-stream/LICENSE b/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/bl/node_modules/readable-stream/LICENSE
new file mode 100644
index 0000000..e3d4e69
--- /dev/null
+++ b/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/bl/node_modules/readable-stream/LICENSE
@@ -0,0 +1,18 @@
+Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.
diff --git a/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/bl/node_modules/readable-stream/README.md b/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/bl/node_modules/readable-stream/README.md
new file mode 100644
index 0000000..3fb3e80
--- /dev/null
+++ b/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/bl/node_modules/readable-stream/README.md
@@ -0,0 +1,15 @@
+# readable-stream
+
+***Node-core streams for userland***
+
+[](https://nodei.co/npm/readable-stream/)
+[](https://nodei.co/npm/readable-stream/)
+
+This package is a mirror of the Streams2 and Streams3 implementations in Node-core.
+
+If you want to guarantee a stable streams base, regardless of what version of Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core.
+
+**readable-stream** comes in two major versions, v1.0.x and v1.1.x. The former tracks the Streams2 implementation in Node 0.10, including bug-fixes and minor improvements as they are added. The latter tracks Streams3 as it develops in Node 0.11; we will likely see a v1.2.x branch for Node 0.12.
+
+**readable-stream** uses proper patch-level versioning so if you pin to `"~1.0.0"` you’ll get the latest Node 0.10 Streams2 implementation, including any fixes and minor non-breaking improvements. The patch-level versions of 1.0.x and 1.1.x should mirror the patch-level versions of Node-core releases. You should prefer the **1.0.x** releases for now and when you’re ready to start using Streams3, pin to `"~1.1.0"`
+
diff --git a/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/bl/node_modules/readable-stream/duplex.js b/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/bl/node_modules/readable-stream/duplex.js
new file mode 100644
index 0000000..ca807af
--- /dev/null
+++ b/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/bl/node_modules/readable-stream/duplex.js
@@ -0,0 +1 @@
+module.exports = require("./lib/_stream_duplex.js")
diff --git a/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/bl/node_modules/readable-stream/lib/_stream_duplex.js b/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/bl/node_modules/readable-stream/lib/_stream_duplex.js
new file mode 100644
index 0000000..b513d61
--- /dev/null
+++ b/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/bl/node_modules/readable-stream/lib/_stream_duplex.js
@@ -0,0 +1,89 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+// a duplex stream is just a stream that is both readable and writable.
+// Since JS doesn't have multiple prototypal inheritance, this class
+// prototypally inherits from Readable, and then parasitically from
+// Writable.
+
+module.exports = Duplex;
+
+/*